diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-10-03 16:57:20 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-10-03 16:57:20 +0000 |
commit | 761ee868a58c00a34301fdec74db471e56907e48 (patch) | |
tree | 8ddb568e05130fdcb58b4f0938c2d8abd6020381 /clang/lib/StaticAnalyzer | |
parent | 9db2d9adef9111fd004ec555b12cfa114c3e172b (diff) | |
download | bcm5719-llvm-761ee868a58c00a34301fdec74db471e56907e48.tar.gz bcm5719-llvm-761ee868a58c00a34301fdec74db471e56907e48.zip |
[analyzer] Replace bug category magic strings with shared constants.
One small functionality change is to bring the sizeof-pointer checker in
line with the other checkers by making its category be "Logic error"
instead of just "Logic". There should be no other functionality changes.
Patch by Daniel Marjamäki!
llvm-svn: 191910
Diffstat (limited to 'clang/lib/StaticAnalyzer')
3 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index ba1d9b9ff6b..e642c2974ea 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -231,7 +231,7 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return NULL; if (!BT_Null) - BT_Null.reset(new BuiltinBug("Unix API", + BT_Null.reset(new BuiltinBug(categories::UnixAPI, "Null pointer argument in call to byte string function")); SmallString<80> buf; @@ -525,7 +525,7 @@ void CStringChecker::emitOverlapBug(CheckerContext &C, ProgramStateRef state, return; if (!BT_Overlap) - BT_Overlap.reset(new BugType("Unix API", "Improper arguments")); + BT_Overlap.reset(new BugType(categories::UnixAPI, "Improper arguments")); // Generate a report for this bug. BugReport *report = @@ -702,7 +702,7 @@ SVal CStringChecker::getCStringLength(CheckerContext &C, ProgramStateRef &state, if (ExplodedNode *N = C.addTransition(state)) { if (!BT_NotCString) - BT_NotCString.reset(new BuiltinBug("Unix API", + BT_NotCString.reset(new BuiltinBug(categories::UnixAPI, "Argument is not a null-terminated string.")); SmallString<120> buf; @@ -762,7 +762,7 @@ SVal CStringChecker::getCStringLength(CheckerContext &C, ProgramStateRef &state, if (ExplodedNode *N = C.addTransition(state)) { if (!BT_NotCString) - BT_NotCString.reset(new BuiltinBug("Unix API", + BT_NotCString.reset(new BuiltinBug(categories::UnixAPI, "Argument is not a null-terminated string.")); SmallString<120> buf; diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp index f2c50501a65..3eeb948798e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp @@ -65,7 +65,7 @@ void WalkAST::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { PathDiagnosticLocation::createBegin(E, BR.getSourceManager(), AC); BR.EmitBasicReport(AC->getDecl(), "Potential unintended use of sizeof() on pointer type", - "Logic", + categories::LogicError, "The code calls sizeof() on a pointer type. " "This can produce an unexpected result.", ELoc, &R, 1); diff --git a/clang/lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp b/clang/lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp index e2a8ea61661..c53e98f6312 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp @@ -11,6 +11,7 @@ namespace clang { namespace ento { namespace categories { const char *CoreFoundationObjectiveC = "Core Foundation/Objective-C"; +const char *LogicError = "Logic error"; const char *MemoryCoreFoundationObjectiveC = "Memory (Core Foundation/Objective-C)"; const char *UnixAPI = "Unix API"; |