diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-01 18:12:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-01 18:12:44 +0000 |
commit | 9e876876afc13aa671cc11a17c19907c599b9ab9 (patch) | |
tree | 68df752f2a2f51b95147c6a1abcb047a4cb7e956 /include/clang/AST/TypeLoc.h | |
parent | 451f8caf37fb6691936f9003833e857e1d1dc987 (diff) |
Reinstate the introduction of source-location information for
nested-name-speciciers within elaborated type names, e.g.,
enum clang::NestedNameSpecifier::SpecifierKind
Fixes in this iteration include:
(1) Compute the type-source range properly for a dependent template
specialization type that starts with "template template-id ::", as
in a member access expression
dep->template f<T>::f()
This is a latent bug I triggered with this change (because now we're
checking the computed source ranges for dependent template
specialization types). But the real problem was...
(2) Make sure to set the qualifier range on a dependent template
specialization type appropriately. This will go away once we push
nested-name-specifier locations into dependent template
specialization types, but it was the source of the
valgrind errors on the buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/TypeLoc.h')
-rw-r--r-- | include/clang/AST/TypeLoc.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index a724f29fb0..591af2a02f 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1388,7 +1388,10 @@ class AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, struct ElaboratedLocInfo { SourceLocation KeywordLoc; - SourceRange QualifierRange; + + /// \brief Opaque data pointer used to reconstruct a nested-name-specifier + /// from + void *QualifierData; }; class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, @@ -1403,27 +1406,29 @@ public: this->getLocalData()->KeywordLoc = Loc; } - SourceRange getQualifierRange() const { - return this->getLocalData()->QualifierRange; + NestedNameSpecifierLoc getQualifierLoc() const { + return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), + getLocalData()->QualifierData); } - void setQualifierRange(SourceRange Range) { - this->getLocalData()->QualifierRange = Range; + + void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { + assert(QualifierLoc.getNestedNameSpecifier() + == getTypePtr()->getQualifier() && + "Inconsistent nested-name-specifier pointer"); + getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); } SourceRange getLocalSourceRange() const { if (getKeywordLoc().isValid()) - if (getQualifierRange().getEnd().isValid()) - return SourceRange(getKeywordLoc(), getQualifierRange().getEnd()); + if (getQualifierLoc()) + return SourceRange(getKeywordLoc(), getQualifierLoc().getEndLoc()); else return SourceRange(getKeywordLoc()); else - return getQualifierRange(); + return getQualifierLoc().getSourceRange(); } - void initializeLocal(ASTContext &Context, SourceLocation Loc) { - setKeywordLoc(Loc); - setQualifierRange(SourceRange(Loc)); - } + void initializeLocal(ASTContext &Context, SourceLocation Loc); TypeLoc getNamedTypeLoc() const { return getInnerTypeLoc(); @@ -1496,9 +1501,10 @@ public: void initializeLocal(ASTContext &Context, SourceLocation Loc); }; -// This is exactly the structure of an ElaboratedTypeLoc whose inner -// type is some sort of TemplateSpecializationTypeLoc. -struct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { +struct DependentTemplateSpecializationLocInfo { + SourceLocation KeywordLoc; + SourceLocation NameLoc; + SourceRange QualifierRange; SourceLocation LAngleLoc; SourceLocation RAngleLoc; // followed by a TemplateArgumentLocInfo[] @@ -1563,8 +1569,10 @@ public: SourceRange getLocalSourceRange() const { if (getKeywordLoc().isValid()) return SourceRange(getKeywordLoc(), getRAngleLoc()); - else + else if (getQualifierRange().isValid()) return SourceRange(getQualifierRange().getBegin(), getRAngleLoc()); + else + return SourceRange(getNameLoc(), getRAngleLoc()); } void copy(DependentTemplateSpecializationTypeLoc Loc) { |