[cfe-dev] r161350 breaks the intention of ParentMap::addStmt
Olaf Krzikalla
Olaf.Krzikalla at tu-dresden.de
Tue Sep 25 04:01:26 PDT 2012
The first patch was wrong, when it comes to an update of a
PseudoObjectExpr. I have to test S instead of Parent. Overall that
simplified the code.
Best Olaf
-------------- next part --------------
Index: lib/AST/ParentMap.cpp
===================================================================
--- lib/AST/ParentMap.cpp (revision 164365)
+++ lib/AST/ParentMap.cpp (working copy)
@@ -21,15 +21,14 @@
typedef llvm::DenseMap<Stmt*, Stmt*> MapTy;
static void BuildParentMap(MapTy& M, Stmt* S) {
+ const PseudoObjectExpr* POE = dyn_cast<PseudoObjectExpr>(S);
for (Stmt::child_range I = S->children(); I; ++I)
- if (*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);
- }
+ if (*I &&
+ // For PseudoObjectExprs only the syntactic form is a parent.
+ // The second test ensures a proper updating of PseudoObjectExprs.
+ (POE == 0 || POE->getSyntacticForm() == *I)) {
+ M[*I] = S;
+ BuildParentMap(M, *I);
}
// Also include the source expr tree of an OpaqueValueExpr in the map.
More information about the cfe-dev
mailing list