aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Silverstein <csilvers2000@yahoo.com>2010-07-09 15:19:34 +0000
committerCraig Silverstein <csilvers2000@yahoo.com>2010-07-09 15:19:34 +0000
commit6b3f1ebce775499aff03845193de78128671262f (patch)
tree144195ae0395f586892eebb777c470a92fb8ade5
parentab9e2f5aa498a5e0a67db4c823de3e995b86688e (diff)
Move traverseunqualifiedtypeloc over to the 'main' typeloc tree.
Note that this is a move -- we pretend that we were really looking at the unqualified typeloc all along -- rather than a recursion, so we don't follow the normal CRTP plan of going through getDerived().TraverseTypeLoc. If we did, we'd be traversing twice for the same type (once as a QualifiedTypeLoc version of the type, once as an UnqualifiedTypeLoc version of the type), which in effect means we'd call VisitTypeLoc twice with the 'same' type. This solves that problem, at the cost of never seeing the qualified version of the type (unless the client subclasses TraverseQualifiedTypeLoc themselves). It's not a perfect solution. A perfect solution probably requires making QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a wrapper around Type* -- rather than being its own class in the type hierarchy. Reviewed by wan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107973 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index bc4ad2a065..cf17f53ddc 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -747,8 +747,22 @@ DEF_TRAVERSE_TYPE(ObjCObjectPointerType, {
template<typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(
QualifiedTypeLoc TL) {
- // Move this over to the 'main' typeloc tree.
- return getDerived().TraverseTypeLoc(TL.getUnqualifiedLoc());
+ // Move this over to the 'main' typeloc tree. Note that this is a
+ // move -- we pretend that we were really looking at the unqualified
+ // typeloc all along -- rather than a recursion, so we don't follow
+ // the normal CRTP plan of going through
+ // getDerived().TraverseTypeLoc. If we did, we'd be traversing
+ // twice for the same type (once as a QualifiedTypeLoc version of
+ // the type, once as an UnqualifiedTypeLoc version of the type),
+ // which in effect means we'd call VisitTypeLoc twice with the
+ // 'same' type. This solves that problem, at the cost of never
+ // seeing the qualified version of the type (unless the client
+ // subclasses TraverseQualifiedTypeLoc themselves). It's not a
+ // perfect solution. A perfect solution probably requires making
+ // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
+ // wrapper around Type* -- rather than being its own class in the
+ // type hierarchy.
+ return TraverseTypeLoc(TL.getUnqualifiedLoc());
}
DEF_TRAVERSE_TYPELOC(BuiltinType, { })