summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-05-24 21:43:05 +0000
committerJordan Rose <jordan_rose@apple.com>2013-05-24 21:43:05 +0000
commit7291666cd9cb122d313a98784c207922daca0473 (patch)
tree8d8eb938f4ec747065900cb2e1d46f805f0d51c8 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp
parent8c3984008780600a81cff25d5b020ff0ffe4bdce (diff)
downloadbcm5719-llvm-7291666cd9cb122d313a98784c207922daca0473.tar.gz
bcm5719-llvm-7291666cd9cb122d313a98784c207922daca0473.zip
[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. <rdar://problem/13983470> llvm-svn: 182676
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp29
1 files changed, 7 insertions, 22 deletions
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<const StackFrameContext *, PathDiagnosticLocation>
- 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<BugReporterVisitor *>::iterator I = visitors.begin(),
E = visitors.end();
OpenPOWER on IntegriCloud