diff options
| author | John McCall <rjmccall@apple.com> | 2009-10-16 22:31:57 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2009-10-16 22:31:57 +0000 |
| commit | 1f1a097f660c1dbbd02c4bdbde4f9815cef91794 (patch) | |
| tree | c1f6076718cbed4d9a2fbde3fc33cd31b845ad58 /clang/lib/AST | |
| parent | 1a015acf698029e9414da408eded5910a56b9715 (diff) | |
| download | bcm5719-llvm-1f1a097f660c1dbbd02c4bdbde4f9815cef91794.tar.gz bcm5719-llvm-1f1a097f660c1dbbd02c4bdbde4f9815cef91794.zip | |
Allow TypeLocs to be fully initialized with a single SourceLocation. This
will be the keystone of converting existing rewrites to be rewrites on TypeLocs.
llvm-svn: 84286
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/TypeLoc.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp index 04e708370af..c216a29e644 100644 --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/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()); } //===----------------------------------------------------------------------===// |

