[cfe-commits] r86208 - in /cfe/trunk: include/clang/Analysis/PathSensitive/BugType.h lib/Analysis/DereferenceChecker.cpp lib/Analysis/DivZeroChecker.cpp lib/Analysis/UndefinedArgChecker.cpp lib/Analysis/UndefinedAssignmentChecker.cpp lib/Analysis/VLASizeChecker.cpp

Ted Kremenek kremenek at apple.com
Thu Nov 5 16:44:33 PST 2009


Author: kremenek
Date: Thu Nov  5 18:44:32 2009
New Revision: 86208

URL: http://llvm.org/viewvc/llvm-project?rev=86208&view=rev
Log:
Minor cleanup: use BuiltinBug (which will soon be renamed) for DeferenceChecker and friends so that they always report the same bug type.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h
    cfe/trunk/lib/Analysis/DereferenceChecker.cpp
    cfe/trunk/lib/Analysis/DivZeroChecker.cpp
    cfe/trunk/lib/Analysis/UndefinedArgChecker.cpp
    cfe/trunk/lib/Analysis/UndefinedAssignmentChecker.cpp
    cfe/trunk/lib/Analysis/VLASizeChecker.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h?rev=86208&r1=86207&r2=86208&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h Thu Nov  5 18:44:32 2009
@@ -59,21 +59,27 @@
 };
 
 class BuiltinBug : public BugType {
-  GRExprEngine &Eng;
+  GRExprEngine *Eng;
 protected:
   const std::string desc;
 public:
+  BuiltinBug(const char *name, const char *description)
+    : BugType(name, "Logic error"), Eng(0), desc(description) {}
+  
+  BuiltinBug(const char *name)
+    : BugType(name, "Logic error"), Eng(0), desc(name) {}
+  
   BuiltinBug(GRExprEngine *eng, const char* n, const char* d)
-    : BugType(n, "Logic error"), Eng(*eng), desc(d) {}
+    : BugType(n, "Logic error"), Eng(eng), desc(d) {}
 
   BuiltinBug(GRExprEngine *eng, const char* n)
-    : BugType(n, "Logic error"), Eng(*eng), desc(n) {}
+    : BugType(n, "Logic error"), Eng(eng), desc(n) {}
 
   const std::string &getDescription() const { return desc; }
 
   virtual void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {}
 
-  void FlushReports(BugReporter& BR) { FlushReportsImpl(BR, Eng); }
+  void FlushReports(BugReporter& BR) { FlushReportsImpl(BR, *Eng); }
 
   virtual void registerInitialVisitors(BugReporterContext& BRC,
                                        const ExplodedNode* N,

Modified: cfe/trunk/lib/Analysis/DereferenceChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/DereferenceChecker.cpp?rev=86208&r1=86207&r2=86208&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/DereferenceChecker.cpp Thu Nov  5 18:44:32 2009
@@ -51,12 +51,11 @@
       
       if (!NotNullState) { // Explicit null case.
         if (!BT)
-          BT = new BuiltinBug(NULL, "Null dereference",
-                              "Dereference of null pointer");
+          BT = new BuiltinBug("Null dereference","Dereference of null pointer");
 
         EnhancedBugReport *R =
           new EnhancedBugReport(*BT, BT->getDescription().c_str(), N);
-        
+
         R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
                              bugreporter::GetDerefExpr(N));
         

Modified: cfe/trunk/lib/Analysis/DivZeroChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/DivZeroChecker.cpp?rev=86208&r1=86207&r2=86208&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/DivZeroChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/DivZeroChecker.cpp Thu Nov  5 18:44:32 2009
@@ -50,7 +50,7 @@
   if (stateZero && !stateNotZero) {
     if (ExplodedNode *N = C.GenerateNode(B, stateZero, true)) {
       if (!BT)
-        BT = new BuiltinBug(0, "Division by zero");
+        BT = new BuiltinBug("Division by zero");
 
       EnhancedBugReport *R = 
         new EnhancedBugReport(*BT, BT->getDescription().c_str(), N);

Modified: cfe/trunk/lib/Analysis/UndefinedArgChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UndefinedArgChecker.cpp?rev=86208&r1=86207&r2=86208&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/UndefinedArgChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/UndefinedArgChecker.cpp Thu Nov  5 18:44:32 2009
@@ -29,8 +29,8 @@
     if (C.getState()->getSVal(*I).isUndef()) {
       if (ExplodedNode *N = C.GenerateNode(CE, true)) {
         if (!BT)
-          BT = new BugType("Pass-by-value argument in function call is "
-                           "undefined", "Logic error");
+          BT = new BuiltinBug("Pass-by-value argument in function call is "
+                              "undefined");
         // Generate a report for this bug.
         EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getName().c_str(),
                                                      N);

Modified: cfe/trunk/lib/Analysis/UndefinedAssignmentChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UndefinedAssignmentChecker.cpp?rev=86208&r1=86207&r2=86208&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/UndefinedAssignmentChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/UndefinedAssignmentChecker.cpp Thu Nov  5 18:44:32 2009
@@ -36,8 +36,7 @@
     return;
 
   if (!BT)
-    BT = new BugType("Assigned value is garbage or undefined",
-                     "Logic error");
+    BT = new BuiltinBug("Assigned value is garbage or undefined");
 
   // Generate a report for this bug.
   EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getName().c_str(), N);

Modified: cfe/trunk/lib/Analysis/VLASizeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/VLASizeChecker.cpp?rev=86208&r1=86207&r2=86208&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/VLASizeChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/VLASizeChecker.cpp Thu Nov  5 18:44:32 2009
@@ -38,8 +38,8 @@
       if (ExplodedNode* N = Builder.generateNode(S, state, Pred)) {
         N->markAsSink();
         if (!BT)
-          BT = new BugType("Declared variable-length array (VLA) uses a garbage"
-                           " value as its size", "Logic error");
+          BT = new BuiltinBug("Declared variable-length array (VLA) uses a "
+                              "garbage value as its size");
 
         EnhancedBugReport *R =
                           new EnhancedBugReport(*BT, BT->getName().c_str(), N);





More information about the cfe-commits mailing list