summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/GRExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-06-20 21:45:25 +0000
committerTed Kremenek <kremenek@apple.com>2008-06-20 21:45:25 +0000
commit34a691734e8363ceb214c839b80d8ee393520226 (patch)
treed6d1f88065b9fbe51d61e17a05f34c8dc78ee6d7 /clang/lib/Analysis/GRExprEngine.cpp
parentefc67e78d7ae9eaf657901612843e8b5b7112172 (diff)
downloadbcm5719-llvm-34a691734e8363ceb214c839b80d8ee393520226.tar.gz
bcm5719-llvm-34a691734e8363ceb214c839b80d8ee393520226.zip
Modified the dead stores checker to...
1) Check if a dead store appears as a subexpression. For such cases, we emit a verbose diagnostic so that users aren't confused. This addresses: <rdar://problem/5968508> checker gives misleading report for dead store in loop 2) Don't emit a dead store warning when assigning a null value to a pointer. This is a common form of defensive programming. We may wish to make this an option to the the checker one day. This addresses the feature request in the following email: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-June/001978.html llvm-svn: 52555
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index e8c1ec57a98..9abfe6f79f3 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -13,6 +13,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/AST/ParentMap.h"
#include "clang/Analysis/PathSensitive/GRExprEngine.h"
#include "clang/Analysis/PathSensitive/BugReporter.h"
#include "clang/Basic/SourceManager.h"
@@ -41,6 +42,7 @@ static inline Selector GetNullarySelector(const char* name, ASTContext& Ctx) {
GRExprEngine::GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx)
: CoreEngine(cfg, CD, Ctx, *this),
G(CoreEngine.getGraph()),
+ Parents(0),
Liveness(G.getCFG()),
Builder(NULL),
StateMgr(G.getContext(), G.getAllocator()),
@@ -56,7 +58,7 @@ GRExprEngine::GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx)
Liveness.runOnAllBlocks(G.getCFG(), NULL, true);
}
-GRExprEngine::~GRExprEngine() {
+GRExprEngine::~GRExprEngine() {
for (BugTypeSet::iterator I = BugTypes.begin(), E = BugTypes.end(); I!=E; ++I)
delete *I;
@@ -69,6 +71,17 @@ GRExprEngine::~GRExprEngine() {
delete *I;
delete [] NSExceptionInstanceRaiseSelectors;
+
+ delete Parents;
+}
+
+ParentMap& GRExprEngine::getParentMap() {
+ if (!Parents) {
+ Stmt* Body = getGraph().getCodeDecl().getCodeBody();
+ Parents = new ParentMap(Body);
+ }
+
+ return *Parents;
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud