]> granicus.if.org Git - clang/commitdiff
Minor cleanup: use BuiltinBug (which will soon be renamed) for DeferenceChecker and...
authorTed Kremenek <kremenek@apple.com>
Fri, 6 Nov 2009 00:44:32 +0000 (00:44 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 6 Nov 2009 00:44:32 +0000 (00:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86208 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 242b8e9afebe18aa16df7da2f17c044514ed5f47..1526fbb38c649238e32d8b009d83f1cb68f787ec 100644 (file)
@@ -59,21 +59,27 @@ public:
 };
 
 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,
index 33c85d50746341f9de760f873ba7ba118dab2104..b7233419ef366cefa39b075b1b449681eb14353e 100644 (file)
@@ -51,12 +51,11 @@ ExplodedNode *NullDerefChecker::CheckLocation(const Stmt *S, ExplodedNode *Pred,
       
       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));
         
index 9c2359f3b075cf3ca9522459526aaeae368303b8..c90c0ab4931f70623519abce8c42e68641814ff9 100644 (file)
@@ -50,7 +50,7 @@ void DivZeroChecker::PreVisitBinaryOperator(CheckerContext &C,
   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);
index a229f55ff6d9e0c1f06fa37614cbbdaa688a956d..549c3b5fe96801b849c4eb9ab132d9bf208d7051 100644 (file)
@@ -29,8 +29,8 @@ void UndefinedArgChecker::PreVisitCallExpr(CheckerContext &C,
     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);
index 2e3ac34913ab805a562856ba70f2fda644134125..26f9ee30d44d6fbe38750ee4cdbf85edbb37e3f3 100644 (file)
@@ -36,8 +36,7 @@ void UndefinedAssignmentChecker::PreVisitBind(CheckerContext &C,
     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);
index 0e731902f4bb402dcb8fab0359962c5bd5d6f5a2..6184a77cf39104df2628705972bd17257a5d6afc 100644 (file)
@@ -38,8 +38,8 @@ ExplodedNode *UndefSizedVLAChecker::CheckType(QualType T, ExplodedNode *Pred,
       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);