From 7291666cd9cb122d313a98784c207922daca0473 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 24 May 2013 21:43:05 +0000 Subject: [analyzer; new edges] Properly set location after exiting an inlined call. The new edge algorithm would keep track of the previous location in each location context, so that it could draw arrows coming in and out of each inlined call. However, it tried to access the location of the call before it was actually set (at the CallEnter node). This only affected unterminated calls at the end of a path; calls with visible exit nodes already had a valid location. This patch ditches the location context map, since we're processing the nodes in order anyway, and just unconditionally updates the PrevLoc variable after popping out of an inlined call. llvm-svn: 182676 --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 29 +++++++-------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp') diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 50a1e8cbac6..b45d051322f 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1588,11 +1588,7 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, StackDiagVector CallStack; InterestingExprs IE; - // Record the last location for a given visited stack frame. - llvm::DenseMap - PrevLocMap; - PrevLocMap[N->getLocationContext()->getCurrentStackFrame()] = - PD.getLocation(); + PathDiagnosticLocation PrevLoc = PD.getLocation(); const ExplodedNode *NextNode = N->getFirstPred(); while (NextNode) { @@ -1633,17 +1629,16 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, // If this is the first item in the active path, record // the new mapping from active path to location context. const LocationContext *&NewLC = LCM[&PD.getActivePath()]; - if (!NewLC) { + if (!NewLC) NewLC = N->getLocationContext(); - } - PDB.LC = NewLC; - // Update the previous location in the active path - // since we just created the call piece lazily. - PrevLocMap[PDB.LC->getCurrentStackFrame()] = C->getLocation(); + PDB.LC = NewLC; } C->setCallee(*CE, SM); + // Update the previous location in the active path. + PrevLoc = C->getLocation(); + if (!CallStack.empty()) { assert(CallStack.back().first == C); CallStack.pop_back(); @@ -1655,12 +1650,6 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, // as processing CallEnter may change the active path. PDB.LC = N->getLocationContext(); - // Get the previous location for the current active - // location context. All edges will be based on this - // location, and it will be updated in place. - PathDiagnosticLocation &PrevLoc = - PrevLocMap[PDB.LC->getCurrentStackFrame()]; - // Record the mapping from the active path to the location // context. assert(!LCM[&PD.getActivePath()] || @@ -1688,6 +1677,7 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, // Add the edge to the return site. addEdgeToPath(PD.getActivePath(), PrevLoc, C->callReturn, PDB.LC); PD.getActivePath().push_front(C); + PrevLoc.invalidate(); // Make the contents of the call the active path for now. PD.pushActivePath(&C->path); @@ -1802,11 +1792,6 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, if (!NextNode) continue; - // Since the active path may have been updated prior - // to this point, query the active location context now. - PathDiagnosticLocation &PrevLoc = - PrevLocMap[PDB.LC->getCurrentStackFrame()]; - // Add pieces from custom visitors. for (ArrayRef::iterator I = visitors.begin(), E = visitors.end(); -- cgit v1.2.3