aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ParentMap.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-08-06 21:28:11 +0000
committerJordan Rose <jordan_rose@apple.com>2012-08-06 21:28:11 +0000
commit2b1b025fa6e848ec36c0554924d7d63342aa80e4 (patch)
tree54df35faab59d3b193ce90c3b05881f4004b2e8e /lib/AST/ParentMap.cpp
parent15d18e15384c9e992bd294fc56f4fdf770763d71 (diff)
[analyzer] Improve arrow locations for PseudoObjectExprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ParentMap.cpp')
-rw-r--r--lib/AST/ParentMap.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp
index 64016d9cdd..fa87afd0fa 100644
--- a/lib/AST/ParentMap.cpp
+++ b/lib/AST/ParentMap.cpp
@@ -23,13 +23,20 @@ typedef llvm::DenseMap<Stmt*, Stmt*> MapTy;
static void BuildParentMap(MapTy& M, Stmt* S) {
for (Stmt::child_range I = S->children(); I; ++I)
if (*I) {
- M[*I] = S;
- BuildParentMap(M, *I);
+ // Prefer the first time we see this statement in the traversal.
+ // This is important for PseudoObjectExprs.
+ Stmt *&Parent = M[*I];
+ if (!Parent) {
+ Parent = S;
+ BuildParentMap(M, *I);
+ }
}
// Also include the source expr tree of an OpaqueValueExpr in the map.
- if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(S))
+ if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(S)) {
+ M[OVE->getSourceExpr()] = S;
BuildParentMap(M, OVE->getSourceExpr());
+ }
}
ParentMap::ParentMap(Stmt* S) : Impl(0) {