diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-05-18 02:26:50 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-05-18 02:26:50 +0000 |
commit | 433b0f5455416fb61ee81d4cb26f2e64678a6ecd (patch) | |
tree | 6a1cfc2857e82f04b4664b9e5b3a25cd2c6dfbb8 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp | |
parent | 5ba473afb005343f7676723a05186233a6f1906f (diff) | |
download | bcm5719-llvm-433b0f5455416fb61ee81d4cb26f2e64678a6ecd.tar.gz bcm5719-llvm-433b0f5455416fb61ee81d4cb26f2e64678a6ecd.zip |
Revert "[analyzer; alternate edges] improve support for edges with PseudoObjectExprs."
Ted and I spent a long time discussing this today and found out that neither
the existing code nor the new code was doing what either of us thought it
was, which is never good. The good news is we found a much simpler way to
fix the motivating test case (an ObjCSubscriptExpr).
This reverts r182083, but pieces of it will come back in subsequent commits.
llvm-svn: 182185
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 111 |
1 files changed, 4 insertions, 107 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index ab3464507de..519555396dd 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1873,78 +1873,9 @@ static bool isIncrementOrInitInForLoop(const Stmt *S, const Stmt *FL) { typedef llvm::DenseSet<const PathDiagnosticCallPiece *> OptimizedCallsSet; -typedef llvm::DenseMap<const Stmt *, - Optional<const PseudoObjectExpr *> > - PseudoObjectExprMap; - -/// Return the PseudoObjectExpr that contains this statement (if any). -static const PseudoObjectExpr * -getContainingPseudoObjectExpr(PseudoObjectExprMap &PEM, - ParentMap &PM, - const Stmt *S) { - if (!S) - return 0; - - Optional<const PseudoObjectExpr *> &Entry = PEM[S]; - if (!Entry.hasValue()) { - const Stmt *Parent = PM.getParentIgnoreParens(S); - if (const PseudoObjectExpr *PE = dyn_cast_or_null<PseudoObjectExpr>(Parent)) - Entry = PE; - else - Entry = getContainingPseudoObjectExpr(PEM, PM, Parent); - } - return Entry.getValue(); -} - -#if 0 -static void printPath(PathPieces &path, ParentMap &PM) { - unsigned index = 0; - for (PathPieces::iterator I = path.begin(), E = path.end(); I != E; ++I ) { - llvm::errs() << "[" << index++ << "]\n"; - if (isa<PathDiagnosticCallPiece>(*I)) { - llvm::errs() << " CALL\n"; - continue; - } - if (isa<PathDiagnosticEventPiece>(*I)) { - llvm::errs() << " EVENT\n"; - continue; - } - if (const PathDiagnosticControlFlowPiece *CP = dyn_cast<PathDiagnosticControlFlowPiece>(*I)) { - llvm::errs() << " CONTROL\n"; - const Stmt *s1Start = getLocStmt(CP->getStartLocation()); - const Stmt *s1End = getLocStmt(CP->getEndLocation()); - if (s1Start) { - s1Start->dump(); - llvm::errs() << "PARENT: \n"; - const Stmt *Parent = getStmtParent(s1Start, PM); - if (Parent) { - Parent->dump(); - } - } - else { - llvm::errs() << "NULL\n"; - } - llvm::errs() << " --------- ===== ----- \n"; - if (s1End) { - s1End->dump(); - llvm::errs() << "PARENT: \n"; - const Stmt *Parent = getStmtParent(s1End, PM); - if (Parent) { - Parent->dump(); - } - } - else { - llvm::errs() << "NULL\n"; - } - } - } -} -#endif - static bool optimizeEdges(PathPieces &path, SourceManager &SM, OptimizedCallsSet &OCS, - LocationContextMap &LCM, - PseudoObjectExprMap &PEM) { + LocationContextMap &LCM) { bool hasChanges = false; const LocationContext *LC = LCM[&path]; assert(LC); @@ -1959,7 +1890,7 @@ static bool optimizeEdges(PathPieces &path, SourceManager &SM, // Record the fact that a call has been optimized so we only do the // effort once. if (!OCS.count(CallI)) { - while (optimizeEdges(CallI->path, SM, OCS, LCM, PEM)) {} + while (optimizeEdges(CallI->path, SM, OCS, LCM)) {} OCS.insert(CallI); } ++I; @@ -1975,7 +1906,7 @@ static bool optimizeEdges(PathPieces &path, SourceManager &SM, continue; } - ParentMap &PM = LC->getSemanticParentMap(); + ParentMap &PM = LC->getParentMap(); const Stmt *s1Start = getLocStmt(PieceI->getStartLocation()); const Stmt *s1End = getLocStmt(PieceI->getEndLocation()); const Stmt *level1 = getStmtParent(s1Start, PM); @@ -2002,39 +1933,6 @@ static bool optimizeEdges(PathPieces &path, SourceManager &SM, } } - // Prune out edges for pseudo object expressions. - // - // Case 1: incoming into a pseudo expr. - // - // An edge into a subexpression of a pseudo object expression - // should be replaced with an edge to the pseudo object expression - // itself. - const PseudoObjectExpr *PE = getContainingPseudoObjectExpr(PEM, PM, s1End); - if (PE) { - PathDiagnosticLocation L(PE, SM, LC); - PieceI->setEndLocation(L); - // Do not increment the iterator. It is possible we will match again. - hasChanges = true; - continue; - } - - // Prune out edges for pseudo object expressions. - // - // Case 2: outgoing from a pseudo expr. - // - // An edge into a subexpression of a pseudo object expression - // should be replaced with an edge to the pseudo object expression - // itself. - PE = getContainingPseudoObjectExpr(PEM, PM, s1Start); - if (PE) { - PathDiagnosticLocation L(PE, SM, LC); - PieceI->setStartLocation(L); - // Do not increment the iterator. It is possible we will match again. - hasChanges = true; - continue; - } - - // Pattern match on two edges after this point. PathPieces::iterator NextI = I; ++NextI; if (NextI == E) break; @@ -2884,8 +2782,7 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD, // to an aesthetically pleasing subset that conveys the // necessary information. OptimizedCallsSet OCS; - PseudoObjectExprMap PEM; - while (optimizeEdges(PD.getMutablePieces(), SM, OCS, LCM, PEM)) {} + while (optimizeEdges(PD.getMutablePieces(), SM, OCS, LCM)) {} // Adjust edges into loop conditions to make them more uniform // and aesthetically pleasing. |