aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TypeLoc.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-10-16 22:31:57 +0000
committerJohn McCall <rjmccall@apple.com>2009-10-16 22:31:57 +0000
commit4ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71a (patch)
tree6fc0ca0158a571bbcdf14e6cda9079ab90d74cf0 /lib/AST/TypeLoc.cpp
parent1cad602ee0283947dbf103f13d9a7c098649dfe3 (diff)
Allow TypeLocs to be fully initialized with a single SourceLocation. This
will be the keystone of converting existing rewrites to be rewrites on TypeLocs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TypeLoc.cpp')
-rw-r--r--lib/AST/TypeLoc.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp
index 04e708370a..c216a29e64 100644
--- a/lib/AST/TypeLoc.cpp
+++ b/lib/AST/TypeLoc.cpp
@@ -91,7 +91,7 @@ public:
TypeLoc VisitTypeSpecLoc(TypeLoc TyLoc) { return TypeLoc(); }
TypeLoc VisitObjCProtocolListLoc(ObjCProtocolListLoc TL);
TypeLoc VisitQualifiedLoc(QualifiedLoc TyLoc) {
- return TyLoc.getUnqualifiedLoc();
+ return TyLoc.getNextTypeLoc();
}
TypeLoc VisitTypeLoc(TypeLoc TyLoc) {
@@ -103,35 +103,50 @@ public:
}
TypeLoc NextLoc::VisitObjCProtocolListLoc(ObjCProtocolListLoc TL) {
- return TL.getBaseTypeLoc();
+ return TL.getNextTypeLoc();
}
TypeLoc NextLoc::VisitPointerLoc(PointerLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getNextTypeLoc();
}
TypeLoc NextLoc::VisitMemberPointerLoc(MemberPointerLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getNextTypeLoc();
}
TypeLoc NextLoc::VisitBlockPointerLoc(BlockPointerLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getNextTypeLoc();
}
TypeLoc NextLoc::VisitReferenceLoc(ReferenceLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getNextTypeLoc();
}
TypeLoc NextLoc::VisitFunctionLoc(FunctionLoc TL) {
- return TL.getResultLoc();
+ return TL.getNextTypeLoc();
}
TypeLoc NextLoc::VisitArrayLoc(ArrayLoc TL) {
- return TL.getElementLoc();
+ return TL.getNextTypeLoc();
}
/// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
/// TypeLoc is a PointerLoc and next TypeLoc is for "int".
TypeLoc TypeLoc::getNextTypeLoc() const {
- //llvm::errs() << "getNextTypeLoc: Ty=" << Ty << ", Data=" << Data << "\n";
- TypeLoc Tmp = NextLoc().Visit(*this);
- //llvm::errs() << " result: Ty=" << Tmp.Ty << ", Data=" << Tmp.Data << "\n";
- return Tmp;
+ return NextLoc().Visit(*this);
+}
+
+namespace {
+struct TypeLocInitializer : public TypeLocVisitor<TypeLocInitializer> {
+ SourceLocation Loc;
+ TypeLocInitializer(SourceLocation Loc) : Loc(Loc) {}
+
+#define ABSTRACT_TYPELOC(CLASS)
+#define TYPELOC(CLASS, PARENT) \
+ void Visit##CLASS(CLASS TyLoc) { TyLoc.initializeLocal(Loc); }
+#include "clang/AST/TypeLocNodes.def"
+};
+}
+
+void TypeLoc::initializeImpl(TypeLoc TL, SourceLocation Loc) {
+ do {
+ TypeLocInitializer(Loc).Visit(TL);
+ } while (TL = TL.getNextTypeLoc());
}
//===----------------------------------------------------------------------===//