Hello!

Based on previous reviews on other patches I created this patch.

This replaces magic strings for bug categories with constants.

As far as I see all tests runs fine (if the string categories::LogicError is 
replaced to anything other than "Logic error" there are assertions).

There is a minor change in behaviour. In CheckSizeofPointer.cpp the bug 
category is changed from "Logic" to "Logic error". Other than this.. there 
should be no change in behaviour anywhere.

Best regards,
Daniel Marjamäki

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 [email protected]

www.evidente.se
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp	(revision 191839)
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp	(arbetskopia)
@@ -231,7 +231,7 @@
       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 @@
     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 @@
 
       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 @@
 
     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;
Index: lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp	(revision 191839)
+++ lib/StaticAnalyzer/Checkers/CommonBugCategories.cpp	(arbetskopia)
@@ -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";
Index: lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp	(revision 191839)
+++ lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp	(arbetskopia)
@@ -65,7 +65,7 @@
       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);
Index: include/clang/StaticAnalyzer/Checkers/CommonBugCategories.h
===================================================================
--- include/clang/StaticAnalyzer/Checkers/CommonBugCategories.h	(revision 191839)
+++ include/clang/StaticAnalyzer/Checkers/CommonBugCategories.h	(arbetskopia)
@@ -15,6 +15,7 @@
   namespace ento {
     namespace categories {
       extern const char *CoreFoundationObjectiveC;
+      extern const char *LogicError;
       extern const char *MemoryCoreFoundationObjectiveC;
       extern const char *UnixAPI;
     }
Index: include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
===================================================================
--- include/clang/StaticAnalyzer/Core/BugReporter/BugType.h	(revision 191839)
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugType.h	(arbetskopia)
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_ANALYSIS_BUGTYPE
 
 #include "clang/Basic/LLVM.h"
+#include "clang/StaticAnalyzer/Checkers/CommonBugCategories.h"
 #include "llvm/ADT/FoldingSet.h"
 #include <string>
 
@@ -54,10 +55,10 @@
   const std::string desc;
 public:
   BuiltinBug(const char *name, const char *description)
-    : BugType(name, "Logic error"), desc(description) {}
+    : BugType(name, categories::LogicError), desc(description) {}
   
   BuiltinBug(const char *name)
-    : BugType(name, "Logic error"), desc(name) {}
+    : BugType(name, categories::LogicError), desc(name) {}
   
   StringRef getDescription() const { return desc; }
 };
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to