diff options
author | John McCall <rjmccall@apple.com> | 2009-10-29 08:12:44 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-10-29 08:12:44 +0000 |
commit | 833ca991c1bfc967f0995974ca86f66ba1f666b5 (patch) | |
tree | 54ce834e6510eae21e5cff09573c986e6ee7ca12 /lib/AST/TemplateBase.cpp | |
parent | 275c10a8a4a43219f67d8d2c912ec6294d9d9af2 (diff) |
Track source information for template arguments and template specialization
types. Preserve it through template instantiation. Preserve it through PCH,
although TSTs themselves aren't serializable, so that's pretty much meaningless.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85500 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TemplateBase.cpp')
-rw-r--r-- | lib/AST/TemplateBase.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index 3b3ec2b530..b136fe0d38 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -16,6 +16,7 @@ #include "clang/AST/TemplateBase.h" #include "clang/AST/DeclBase.h" #include "clang/AST/Expr.h" +#include "clang/AST/TypeLoc.h" using namespace clang; @@ -23,11 +24,6 @@ using namespace clang; // TemplateArgument Implementation //===----------------------------------------------------------------------===// -TemplateArgument::TemplateArgument(Expr *E) : Kind(Expression) { - TypeOrValue = reinterpret_cast<uintptr_t>(E); - StartLoc = E->getSourceRange().getBegin(); -} - /// \brief Construct a template argument pack. void TemplateArgument::setArgumentPack(TemplateArgument *args, unsigned NumArgs, bool CopyArgs) { @@ -77,3 +73,25 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID, Args.Args[I].Profile(ID, Context); } } + +//===----------------------------------------------------------------------===// +// TemplateArgumentLoc Implementation +//===----------------------------------------------------------------------===// + +SourceLocation TemplateArgumentLoc::getLocation() const { + switch (Argument.getKind()) { + case TemplateArgument::Expression: + return getSourceExpression()->getExprLoc(); + case TemplateArgument::Type: + return getSourceDeclaratorInfo()-> + getTypeLoc().getFullSourceRange().getBegin(); + case TemplateArgument::Declaration: + case TemplateArgument::Integral: + case TemplateArgument::Pack: + case TemplateArgument::Null: + return SourceLocation(); + } + + // Silence bonus gcc warning. + return SourceLocation(); +} |