diff options
| author | Ted Kremenek <kremenek@apple.com> | 2009-11-06 00:44:32 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2009-11-06 00:44:32 +0000 |
| commit | 2980b975eeb8a37d8ca597938819bd47a92f3108 (patch) | |
| tree | d0127f13f1707e7928ed6b8ab91db8bacde79fb4 | |
| parent | 5582451e914f4bdfb4754ad6dd4ed8b457d34d01 (diff) | |
| download | bcm5719-llvm-2980b975eeb8a37d8ca597938819bd47a92f3108.tar.gz bcm5719-llvm-2980b975eeb8a37d8ca597938819bd47a92f3108.zip | |
Minor cleanup: use BuiltinBug (which will soon be renamed) for DeferenceChecker and friends so that they always report the same bug type.
llvm-svn: 86208
| -rw-r--r-- | clang/include/clang/Analysis/PathSensitive/BugType.h | 14 | ||||
| -rw-r--r-- | clang/lib/Analysis/DereferenceChecker.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Analysis/DivZeroChecker.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Analysis/UndefinedArgChecker.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Analysis/UndefinedAssignmentChecker.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Analysis/VLASizeChecker.cpp | 4 |
6 files changed, 18 insertions, 14 deletions
diff --git a/clang/include/clang/Analysis/PathSensitive/BugType.h b/clang/include/clang/Analysis/PathSensitive/BugType.h index 242b8e9afeb..1526fbb38c6 100644 --- a/clang/include/clang/Analysis/PathSensitive/BugType.h +++ b/clang/include/clang/Analysis/PathSensitive/BugType.h @@ -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, diff --git a/clang/lib/Analysis/DereferenceChecker.cpp b/clang/lib/Analysis/DereferenceChecker.cpp index 33c85d50746..b7233419ef3 100644 --- a/clang/lib/Analysis/DereferenceChecker.cpp +++ b/clang/lib/Analysis/DereferenceChecker.cpp @@ -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)); diff --git a/clang/lib/Analysis/DivZeroChecker.cpp b/clang/lib/Analysis/DivZeroChecker.cpp index 9c2359f3b07..c90c0ab4931 100644 --- a/clang/lib/Analysis/DivZeroChecker.cpp +++ b/clang/lib/Analysis/DivZeroChecker.cpp @@ -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); diff --git a/clang/lib/Analysis/UndefinedArgChecker.cpp b/clang/lib/Analysis/UndefinedArgChecker.cpp index a229f55ff6d..549c3b5fe96 100644 --- a/clang/lib/Analysis/UndefinedArgChecker.cpp +++ b/clang/lib/Analysis/UndefinedArgChecker.cpp @@ -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); diff --git a/clang/lib/Analysis/UndefinedAssignmentChecker.cpp b/clang/lib/Analysis/UndefinedAssignmentChecker.cpp index 2e3ac34913a..26f9ee30d44 100644 --- a/clang/lib/Analysis/UndefinedAssignmentChecker.cpp +++ b/clang/lib/Analysis/UndefinedAssignmentChecker.cpp @@ -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); diff --git a/clang/lib/Analysis/VLASizeChecker.cpp b/clang/lib/Analysis/VLASizeChecker.cpp index 0e731902f4b..6184a77cf39 100644 --- a/clang/lib/Analysis/VLASizeChecker.cpp +++ b/clang/lib/Analysis/VLASizeChecker.cpp @@ -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); |

