Skip to content

Commit e6ef134

Browse files
author
Balazs Benics
committed
[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
1 parent 97f1bf1 commit e6ef134

File tree

5 files changed

+33
-45
lines changed

5 files changed

+33
-45
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class IdentifierInfo;
2828
namespace clang {
2929
namespace ento {
3030

31-
enum CallDescriptionFlags : int {
31+
enum CallDescriptionFlags : unsigned {
32+
CDF_None = 0,
33+
3234
/// Describes a C standard function that is sometimes implemented as a macro
3335
/// that expands to a compiler builtin with some __builtin prefix.
3436
/// The builtin may as well have a few extra arguments on top of the requested
@@ -61,7 +63,8 @@ class CallDescription {
6163
/// @param RequiredArgs The number of arguments that is expected to match a
6264
/// call. Omit this parameter to match every occurrence of call with a given
6365
/// name regardless the number of arguments.
64-
CallDescription(int Flags, ArrayRef<const char *> QualifiedName,
66+
CallDescription(CallDescriptionFlags Flags,
67+
ArrayRef<const char *> QualifiedName,
6568
MaybeUInt RequiredArgs = None,
6669
MaybeUInt RequiredParams = None);
6770

clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,42 +72,27 @@ class ContainerModeling
7272
SVal) const;
7373

7474
CallDescriptionMap<NoItParamFn> NoIterParamFunctions = {
75-
{{0, "clear", 0},
76-
&ContainerModeling::handleClear},
77-
{{0, "assign", 2},
78-
&ContainerModeling::handleAssign},
79-
{{0, "push_back", 1},
80-
&ContainerModeling::handlePushBack},
81-
{{0, "emplace_back", 1},
82-
&ContainerModeling::handlePushBack},
83-
{{0, "pop_back", 0},
84-
&ContainerModeling::handlePopBack},
85-
{{0, "push_front", 1},
86-
&ContainerModeling::handlePushFront},
87-
{{0, "emplace_front", 1},
88-
&ContainerModeling::handlePushFront},
89-
{{0, "pop_front", 0},
90-
&ContainerModeling::handlePopFront},
75+
{{"clear", 0}, &ContainerModeling::handleClear},
76+
{{"assign", 2}, &ContainerModeling::handleAssign},
77+
{{"push_back", 1}, &ContainerModeling::handlePushBack},
78+
{{"emplace_back", 1}, &ContainerModeling::handlePushBack},
79+
{{"pop_back", 0}, &ContainerModeling::handlePopBack},
80+
{{"push_front", 1}, &ContainerModeling::handlePushFront},
81+
{{"emplace_front", 1}, &ContainerModeling::handlePushFront},
82+
{{"pop_front", 0}, &ContainerModeling::handlePopFront},
9183
};
92-
84+
9385
CallDescriptionMap<OneItParamFn> OneIterParamFunctions = {
94-
{{0, "insert", 2},
95-
&ContainerModeling::handleInsert},
96-
{{0, "emplace", 2},
97-
&ContainerModeling::handleInsert},
98-
{{0, "erase", 1},
99-
&ContainerModeling::handleErase},
100-
{{0, "erase_after", 1},
101-
&ContainerModeling::handleEraseAfter},
86+
{{"insert", 2}, &ContainerModeling::handleInsert},
87+
{{"emplace", 2}, &ContainerModeling::handleInsert},
88+
{{"erase", 1}, &ContainerModeling::handleErase},
89+
{{"erase_after", 1}, &ContainerModeling::handleEraseAfter},
10290
};
103-
91+
10492
CallDescriptionMap<TwoItParamFn> TwoIterParamFunctions = {
105-
{{0, "erase", 2},
106-
&ContainerModeling::handleErase},
107-
{{0, "erase_after", 2},
108-
&ContainerModeling::handleEraseAfter},
93+
{{"erase", 2}, &ContainerModeling::handleErase},
94+
{{"erase_after", 2}, &ContainerModeling::handleEraseAfter},
10995
};
110-
11196
};
11297

11398
bool isBeginCall(const FunctionDecl *Func);

clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class DebugContainerModeling
4141
CheckerContext &) const;
4242

4343
CallDescriptionMap<FnCheck> Callbacks = {
44-
{{0, "clang_analyzer_container_begin", 1},
45-
&DebugContainerModeling::analyzerContainerBegin},
46-
{{0, "clang_analyzer_container_end", 1},
47-
&DebugContainerModeling::analyzerContainerEnd},
44+
{{"clang_analyzer_container_begin", 1},
45+
&DebugContainerModeling::analyzerContainerBegin},
46+
{{"clang_analyzer_container_end", 1},
47+
&DebugContainerModeling::analyzerContainerEnd},
4848
};
4949

5050
public:

clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class DebugIteratorModeling
4242
CheckerContext &) const;
4343

4444
CallDescriptionMap<FnCheck> Callbacks = {
45-
{{0, "clang_analyzer_iterator_position", 1},
46-
&DebugIteratorModeling::analyzerIteratorPosition},
47-
{{0, "clang_analyzer_iterator_container", 1},
48-
&DebugIteratorModeling::analyzerIteratorContainer},
49-
{{0, "clang_analyzer_iterator_validity", 1},
50-
&DebugIteratorModeling::analyzerIteratorValidity},
45+
{{"clang_analyzer_iterator_position", 1},
46+
&DebugIteratorModeling::analyzerIteratorPosition},
47+
{{"clang_analyzer_iterator_container", 1},
48+
&DebugIteratorModeling::analyzerIteratorContainer},
49+
{{"clang_analyzer_iterator_validity", 1},
50+
&DebugIteratorModeling::analyzerIteratorValidity},
5151
};
5252

5353
public:

clang/lib/StaticAnalyzer/Core/CallDescription.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static MaybeUInt readRequiredParams(MaybeUInt RequiredArgs,
3434
return None;
3535
}
3636

37-
ento::CallDescription::CallDescription(int Flags,
37+
ento::CallDescription::CallDescription(CallDescriptionFlags Flags,
3838
ArrayRef<const char *> QualifiedName,
3939
MaybeUInt RequiredArgs /*= None*/,
4040
MaybeUInt RequiredParams /*= None*/)
@@ -50,7 +50,7 @@ ento::CallDescription::CallDescription(int Flags,
5050
ento::CallDescription::CallDescription(ArrayRef<const char *> QualifiedName,
5151
MaybeUInt RequiredArgs /*= None*/,
5252
MaybeUInt RequiredParams /*= None*/)
53-
: CallDescription(0, QualifiedName, RequiredArgs, RequiredParams) {}
53+
: CallDescription(CDF_None, QualifiedName, RequiredArgs, RequiredParams) {}
5454

5555
bool ento::CallDescription::matches(const CallEvent &Call) const {
5656
// FIXME: Add ObjC Message support.

0 commit comments

Comments
 (0)