diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-25 19:13:18 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-25 19:13:18 +0000 |
commit | c21c7e9c2cded68f91be15be6847c9649242dc17 (patch) | |
tree | 4cf47abb0058f7ada5262a133ee3aa859ab6df4a /lib/AST/TypeLoc.cpp | |
parent | 0691a5c83246604a89654e0dfc25870e742035b4 (diff) |
Teach TemplateSpecializationTypeLoc::initializeArgLocs() to actually
generate meaningful [*] template argument location information.
[*] Well, as meaningful as possible, given that this entire code path
is a hack for when we've lost type-source information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124211 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TypeLoc.cpp')
-rw-r--r-- | lib/AST/TypeLoc.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index 08fe267b1d..0680acb1c5 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -77,14 +77,15 @@ TypeLoc TypeLoc::getNextTypeLocImpl(TypeLoc TL) { /// \brief Initializes a type location, and all of its children /// recursively, as if the entire tree had been written in the /// given location. -void TypeLoc::initializeImpl(TypeLoc TL, SourceLocation Loc) { +void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL, + SourceLocation Loc) { while (true) { switch (TL.getTypeLocClass()) { #define ABSTRACT_TYPELOC(CLASS, PARENT) #define TYPELOC(CLASS, PARENT) \ case CLASS: { \ CLASS##TypeLoc TLCasted = cast<CLASS##TypeLoc>(TL); \ - TLCasted.initializeLocal(Loc); \ + TLCasted.initializeLocal(Context, Loc); \ TL = TLCasted.getNextTypeLoc(); \ if (!TL) return; \ continue; \ @@ -229,3 +230,38 @@ TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) { TL = PTL->getInnerLoc(); return TL; } + +void TemplateSpecializationTypeLoc::initializeArgLocs(ASTContext &Context, + unsigned NumArgs, + const TemplateArgument *Args, + TemplateArgumentLocInfo *ArgInfos, + SourceLocation Loc) { + for (unsigned i = 0, e = NumArgs; i != e; ++i) { + switch (Args[i].getKind()) { + case TemplateArgument::Null: + case TemplateArgument::Declaration: + case TemplateArgument::Integral: + case TemplateArgument::Pack: + case TemplateArgument::Expression: + // FIXME: Can we do better for declarations and integral values? + ArgInfos[i] = TemplateArgumentLocInfo(); + break; + + case TemplateArgument::Type: + ArgInfos[i] = TemplateArgumentLocInfo( + Context.getTrivialTypeSourceInfo(Args[i].getAsType(), + Loc)); + break; + + case TemplateArgument::Template: + ArgInfos[i] = TemplateArgumentLocInfo(SourceRange(Loc), Loc, + SourceLocation()); + break; + + case TemplateArgument::TemplateExpansion: + ArgInfos[i] = TemplateArgumentLocInfo(SourceRange(Loc), Loc, Loc); + break; + } + } +} + |