diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-06 21:28:11 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-06 21:28:11 +0000 |
commit | e32e153f7d455a12879865cad94239be08532b2c (patch) | |
tree | 86bc7c58b23a51ac619b8b0bcef900a8b33c0104 /clang/lib/AST/ParentMap.cpp | |
parent | 1c715609df9821dcc7021f4c1c544a118849f647 (diff) | |
download | bcm5719-llvm-e32e153f7d455a12879865cad94239be08532b2c.tar.gz bcm5719-llvm-e32e153f7d455a12879865cad94239be08532b2c.zip |
[analyzer] Improve arrow locations for PseudoObjectExprs.
llvm-svn: 161350
Diffstat (limited to 'clang/lib/AST/ParentMap.cpp')
-rw-r--r-- | clang/lib/AST/ParentMap.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp index 64016d9cdd6..fa87afd0fa2 100644 --- a/clang/lib/AST/ParentMap.cpp +++ b/clang/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) { |