diff options
author | Balazs Benics <balazs.benics@sigmatechnology.se> | 2021-11-19 18:32:13 +0100 |
---|---|---|
committer | Balazs Benics <balazs.benics@sigmatechnology.se> | 2021-11-19 18:32:13 +0100 |
commit | e6ef134f3c77005438f9fb7c1d17d3c30747844e (patch) | |
tree | e8923cbcc30124451ffe912b718e473e0fa7b7a3 | |
parent | 97f1bf15b154ef32608fe17b82f2f312401d150c (diff) | |
download | llvm-e6ef134f3c77005438f9fb7c1d17d3c30747844e.tar.gz |
[analyzer][NFC] Use enum for CallDescription flags
Yeah, let's prefer a slightly stronger type representing this.
Reviewed By: martong, xazax.hun
Differential Revision: https://reviews.llvm.org/D113595
5 files changed, 33 insertions, 45 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h index 88f67a03acfe..67db652a1e52 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h @@ -28,7 +28,9 @@ class IdentifierInfo; namespace clang { namespace ento { -enum CallDescriptionFlags : int { +enum CallDescriptionFlags : unsigned { + CDF_None = 0, + /// Describes a C standard function that is sometimes implemented as a macro /// that expands to a compiler builtin with some __builtin prefix. /// The builtin may as well have a few extra arguments on top of the requested @@ -61,7 +63,8 @@ public: /// @param RequiredArgs The number of arguments that is expected to match a /// call. Omit this parameter to match every occurrence of call with a given /// name regardless the number of arguments. - CallDescription(int Flags, ArrayRef<const char *> QualifiedName, + CallDescription(CallDescriptionFlags Flags, + ArrayRef<const char *> QualifiedName, MaybeUInt RequiredArgs = None, MaybeUInt RequiredParams = None); diff --git a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp index c46a564f50b4..77a3218f55fb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp @@ -72,42 +72,27 @@ public: SVal) const; CallDescriptionMap<NoItParamFn> NoIterParamFunctions = { - {{0, "clear", 0}, - &ContainerModeling::handleClear}, - {{0, "assign", 2}, - &ContainerModeling::handleAssign}, - {{0, "push_back", 1}, - &ContainerModeling::handlePushBack}, - {{0, "emplace_back", 1}, - &ContainerModeling::handlePushBack}, - {{0, "pop_back", 0}, - &ContainerModeling::handlePopBack}, - {{0, "push_front", 1}, - &ContainerModeling::handlePushFront}, - {{0, "emplace_front", 1}, - &ContainerModeling::handlePushFront}, - {{0, "pop_front", 0}, - &ContainerModeling::handlePopFront}, + {{"clear", 0}, &ContainerModeling::handleClear}, + {{"assign", 2}, &ContainerModeling::handleAssign}, + {{"push_back", 1}, &ContainerModeling::handlePushBack}, + {{"emplace_back", 1}, &ContainerModeling::handlePushBack}, + {{"pop_back", 0}, &ContainerModeling::handlePopBack}, + {{"push_front", 1}, &ContainerModeling::handlePushFront}, + {{"emplace_front", 1}, &ContainerModeling::handlePushFront}, + {{"pop_front", 0}, &ContainerModeling::handlePopFront}, }; - + CallDescriptionMap<OneItParamFn> OneIterParamFunctions = { - {{0, "insert", 2}, - &ContainerModeling::handleInsert}, - {{0, "emplace", 2}, - &ContainerModeling::handleInsert}, - {{0, "erase", 1}, - &ContainerModeling::handleErase}, - {{0, "erase_after", 1}, - &ContainerModeling::handleEraseAfter}, + {{"insert", 2}, &ContainerModeling::handleInsert}, + {{"emplace", 2}, &ContainerModeling::handleInsert}, + {{"erase", 1}, &ContainerModeling::handleErase}, + {{"erase_after", 1}, &ContainerModeling::handleEraseAfter}, }; - + CallDescriptionMap<TwoItParamFn> TwoIterParamFunctions = { - {{0, "erase", 2}, - &ContainerModeling::handleErase}, - {{0, "erase_after", 2}, - &ContainerModeling::handleEraseAfter}, + {{"erase", 2}, &ContainerModeling::handleErase}, + {{"erase_after", 2}, &ContainerModeling::handleEraseAfter}, }; - }; bool isBeginCall(const FunctionDecl *Func); diff --git a/clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp index b49027783a90..47fd57c7db9b 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp @@ -41,10 +41,10 @@ class DebugContainerModeling CheckerContext &) const; CallDescriptionMap<FnCheck> Callbacks = { - {{0, "clang_analyzer_container_begin", 1}, - &DebugContainerModeling::analyzerContainerBegin}, - {{0, "clang_analyzer_container_end", 1}, - &DebugContainerModeling::analyzerContainerEnd}, + {{"clang_analyzer_container_begin", 1}, + &DebugContainerModeling::analyzerContainerBegin}, + {{"clang_analyzer_container_end", 1}, + &DebugContainerModeling::analyzerContainerEnd}, }; public: diff --git a/clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp index 132fea94c286..6add9a007a87 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp @@ -42,12 +42,12 @@ class DebugIteratorModeling CheckerContext &) const; CallDescriptionMap<FnCheck> Callbacks = { - {{0, "clang_analyzer_iterator_position", 1}, - &DebugIteratorModeling::analyzerIteratorPosition}, - {{0, "clang_analyzer_iterator_container", 1}, - &DebugIteratorModeling::analyzerIteratorContainer}, - {{0, "clang_analyzer_iterator_validity", 1}, - &DebugIteratorModeling::analyzerIteratorValidity}, + {{"clang_analyzer_iterator_position", 1}, + &DebugIteratorModeling::analyzerIteratorPosition}, + {{"clang_analyzer_iterator_container", 1}, + &DebugIteratorModeling::analyzerIteratorContainer}, + {{"clang_analyzer_iterator_validity", 1}, + &DebugIteratorModeling::analyzerIteratorValidity}, }; public: diff --git a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp index 9274f8a41165..36c50e96311f 100644 --- a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp @@ -34,7 +34,7 @@ static MaybeUInt readRequiredParams(MaybeUInt RequiredArgs, return None; } -ento::CallDescription::CallDescription(int Flags, +ento::CallDescription::CallDescription(CallDescriptionFlags Flags, ArrayRef<const char *> QualifiedName, MaybeUInt RequiredArgs /*= None*/, MaybeUInt RequiredParams /*= None*/) @@ -50,7 +50,7 @@ ento::CallDescription::CallDescription(int Flags, ento::CallDescription::CallDescription(ArrayRef<const char *> QualifiedName, MaybeUInt RequiredArgs /*= None*/, MaybeUInt RequiredParams /*= None*/) - : CallDescription(0, QualifiedName, RequiredArgs, RequiredParams) {} + : CallDescription(CDF_None, QualifiedName, RequiredArgs, RequiredParams) {} bool ento::CallDescription::matches(const CallEvent &Call) const { // FIXME: Add ObjC Message support. |