diff options
Diffstat (limited to 'clang/lib/AST/ParentMap.cpp')
-rw-r--r-- | clang/lib/AST/ParentMap.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp index 113592860b7..735926d81df 100644 --- a/clang/lib/AST/ParentMap.cpp +++ b/clang/lib/AST/ParentMap.cpp @@ -25,7 +25,7 @@ enum OpaqueValueMode { OV_Opaque }; -static void BuildParentMap(MapTy& M, Stmt* S, +static void BuildParentMap(MapTy& M, Stmt* S, bool isSemantic, OpaqueValueMode OVMode = OV_Transparent) { switch (S->getStmtClass()) { @@ -33,14 +33,17 @@ static void BuildParentMap(MapTy& M, Stmt* S, assert(OVMode == OV_Transparent && "Should not appear alongside OVEs"); PseudoObjectExpr *POE = cast<PseudoObjectExpr>(S); - M[POE->getSyntacticForm()] = S; - BuildParentMap(M, POE->getSyntacticForm(), OV_Transparent); + if (!isSemantic) { + M[POE->getSyntacticForm()] = S; + BuildParentMap(M, POE->getSyntacticForm(), OV_Transparent); + } for (PseudoObjectExpr::semantics_iterator I = POE->semantics_begin(), E = POE->semantics_end(); I != E; ++I) { M[*I] = S; - BuildParentMap(M, *I, OV_Opaque); + BuildParentMap(M, *I, isSemantic, + isSemantic ? OV_Transparent : OV_Opaque); } break; } @@ -49,16 +52,16 @@ static void BuildParentMap(MapTy& M, Stmt* S, BinaryConditionalOperator *BCO = cast<BinaryConditionalOperator>(S); M[BCO->getCommon()] = S; - BuildParentMap(M, BCO->getCommon(), OV_Transparent); + BuildParentMap(M, BCO->getCommon(), isSemantic, OV_Transparent); M[BCO->getCond()] = S; - BuildParentMap(M, BCO->getCond(), OV_Opaque); + BuildParentMap(M, BCO->getCond(), isSemantic, OV_Opaque); M[BCO->getTrueExpr()] = S; - BuildParentMap(M, BCO->getTrueExpr(), OV_Opaque); + BuildParentMap(M, BCO->getTrueExpr(), isSemantic, OV_Opaque); M[BCO->getFalseExpr()] = S; - BuildParentMap(M, BCO->getFalseExpr(), OV_Transparent); + BuildParentMap(M, BCO->getFalseExpr(), isSemantic, OV_Transparent); break; } @@ -66,24 +69,25 @@ static void BuildParentMap(MapTy& M, Stmt* S, if (OVMode == OV_Transparent) { OpaqueValueExpr *OVE = cast<OpaqueValueExpr>(S); M[OVE->getSourceExpr()] = S; - BuildParentMap(M, OVE->getSourceExpr(), OV_Transparent); + BuildParentMap(M, OVE->getSourceExpr(), isSemantic, OV_Transparent); } break; default: for (Stmt::child_range I = S->children(); I; ++I) { if (*I) { M[*I] = S; - BuildParentMap(M, *I, OVMode); + BuildParentMap(M, *I, isSemantic, OVMode); } } break; } } -ParentMap::ParentMap(Stmt* S) : Impl(0) { +ParentMap::ParentMap(Stmt* S, bool isSemantic) : Impl(0), + IsSemantic(isSemantic) { if (S) { MapTy *M = new MapTy(); - BuildParentMap(*M, S); + BuildParentMap(*M, S, isSemantic); Impl = M; } } @@ -94,7 +98,7 @@ ParentMap::~ParentMap() { void ParentMap::addStmt(Stmt* S) { if (S) { - BuildParentMap(*(MapTy*) Impl, S); + BuildParentMap(*(MapTy*) Impl, S, IsSemantic); } } |