From 0dd15d78fb0c99faa5df724139ba4c16a9a345c6 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sun, 24 Feb 2013 07:20:53 +0000 Subject: Add "KnownSVal" to represent SVals that cannot be UnknownSVal. This provides a few sundry cleanups, and allows us to provide a compile-time check for a case that was a runtime assertion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175987 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/StaticAnalyzer/Core/BugReporterVisitors.cpp') diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 5dc8dfc8de..f59458ca6e 100644 --- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -354,7 +354,7 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ, BugReporterContext &BRC, BugReport &BR) { - if (satisfied) + if (Satisfied) return NULL; const ExplodedNode *StoreSite = 0; @@ -410,7 +410,7 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ, if (!StoreSite) return NULL; - satisfied = true; + Satisfied = true; // If we have an expression that provided the value, try to track where it // came from. @@ -449,8 +449,9 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ, if (const BlockDataRegion *BDR = dyn_cast_or_null(V.getAsRegion())) { if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) { - V = State->getSVal(OriginalR); - BR.addVisitor(new FindLastStoreBRVisitor(V, OriginalR)); + if (Optional KV = + State->getSVal(OriginalR).getAs()) + BR.addVisitor(new FindLastStoreBRVisitor(*KV, OriginalR)); } } } @@ -698,7 +699,8 @@ bool bugreporter::trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, report.addVisitor(ConstraintTracker); } - report.addVisitor(new FindLastStoreBRVisitor(V, R)); + if (Optional KV = V.getAs()) + report.addVisitor(new FindLastStoreBRVisitor(*KV, R)); return true; } } @@ -711,7 +713,6 @@ bool bugreporter::trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, // Uncomment this to find cases where we aren't properly getting the // base value that was dereferenced. // assert(!V.isUnknownOrUndef()); - // Is it a symbolic value? if (Optional L = V.getAs()) { // At this point we are dealing with the region's LValue. @@ -743,14 +744,11 @@ FindLastStoreBRVisitor::createVisitorObject(const ExplodedNode *N, assert(R && "The memory region is null."); ProgramStateRef state = N->getState(); - SVal V = state->getSVal(R); - if (V.isUnknown()) - return 0; - - return new FindLastStoreBRVisitor(V, R); + if (Optional KV = state->getSVal(R).getAs()) + return new FindLastStoreBRVisitor(*KV, R); + return 0; } - PathDiagnosticPiece *NilReceiverBRVisitor::VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, @@ -808,7 +806,7 @@ void FindLastStoreBRVisitor::registerStatementVarDecls(BugReport &BR, if (V.getAs() || V.getAs()) { // Register a new visitor with the BugReport. - BR.addVisitor(new FindLastStoreBRVisitor(V, R)); + BR.addVisitor(new FindLastStoreBRVisitor(V.castAs(), R)); } } } -- cgit v1.2.3-18-g5258