diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /lib/AST/ParentMap.cpp | |
parent | bb67ca86b31f67faee50bd10c3b036d65751745a (diff) | |
download | FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.zip FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.tar.gz |
Vendor import of clang trunk r161861:
http://llvm.org/svn/llvm-project/cfe/trunk@161861
Diffstat (limited to 'lib/AST/ParentMap.cpp')
-rw-r--r-- | lib/AST/ParentMap.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp index 64016d9..fa87afd 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) { |