summaryrefslogtreecommitdiff
path: root/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
commit5a6fb20841220488f8be7254fbea8ba7233ebcd3 (patch)
tree6daa7dc6e42d08a67c0c88098541f483c61741bb /lib/StaticAnalyzer/Core/BugReporter.cpp
parent9779fdd271bb6a938bdee93f901e4ef7b1a88610 (diff)
downloadclang-5a6fb20841220488f8be7254fbea8ba7233ebcd3.tar.gz
clang-5a6fb20841220488f8be7254fbea8ba7233ebcd3.tar.bz2
clang-5a6fb20841220488f8be7254fbea8ba7233ebcd3.tar.xz
[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> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp29
1 files changed, 7 insertions, 22 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 50a1e8cbac..b45d051322 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/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();