From 38a42916cb07fd368d9e2ae1e7915fa896f9ec06 Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Mon, 6 Feb 2012 19:09:27 +0000 Subject: [PATCH] Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149889 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/TypeLoc.h | 37 ++++++++++++++------------------- lib/AST/TypeLoc.cpp | 4 ++-- lib/Sema/SemaDecl.cpp | 2 +- lib/Sema/SemaDeclCXX.cpp | 6 +++--- lib/Sema/SemaTemplate.cpp | 12 +++++------ lib/Sema/SemaType.cpp | 16 +++++++------- lib/Sema/TreeTransform.h | 12 +++++------ lib/Serialization/ASTReader.cpp | 4 ++-- lib/Serialization/ASTWriter.cpp | 4 ++-- 9 files changed, 46 insertions(+), 51 deletions(-) diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 06834eded7..657f949b1f 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1492,10 +1492,8 @@ class AutoTypeLoc : public InheritingConcreteTypeLoc { public: - SourceLocation getKeywordLoc() const { - return this->getLocalData()->KeywordLoc; + SourceLocation getElaboratedKeywordLoc() const { + return this->getLocalData()->ElaboratedKWLoc; } - void setKeywordLoc(SourceLocation Loc) { - this->getLocalData()->KeywordLoc = Loc; + void setElaboratedKeywordLoc(SourceLocation Loc) { + this->getLocalData()->ElaboratedKWLoc = Loc; } NestedNameSpecifierLoc getQualifierLoc() const { @@ -1524,11 +1522,12 @@ public: } SourceRange getLocalSourceRange() const { - if (getKeywordLoc().isValid()) + if (getElaboratedKeywordLoc().isValid()) if (getQualifierLoc()) - return SourceRange(getKeywordLoc(), getQualifierLoc().getEndLoc()); + return SourceRange(getElaboratedKeywordLoc(), + getQualifierLoc().getEndLoc()); else - return SourceRange(getKeywordLoc()); + return SourceRange(getElaboratedKeywordLoc()); else return getQualifierLoc().getSourceRange(); } @@ -1554,9 +1553,6 @@ public: // type is some sort of TypeDeclTypeLoc. struct DependentNameLocInfo : ElaboratedLocInfo { SourceLocation NameLoc; - - /// \brief Data associated with the nested-name-specifier location. - void *QualifierData; }; class DependentNameTypeLoc : public ConcreteTypeLoc { public: - SourceLocation getKeywordLoc() const { - return this->getLocalData()->KeywordLoc; + SourceLocation getElaboratedKeywordLoc() const { + return this->getLocalData()->ElaboratedKWLoc; } - void setKeywordLoc(SourceLocation Loc) { - this->getLocalData()->KeywordLoc = Loc; + void setElaboratedKeywordLoc(SourceLocation Loc) { + this->getLocalData()->ElaboratedKWLoc = Loc; } NestedNameSpecifierLoc getQualifierLoc() const { @@ -1591,8 +1587,8 @@ public: } SourceRange getLocalSourceRange() const { - if (getKeywordLoc().isValid()) - return SourceRange(getKeywordLoc(), getNameLoc()); + if (getElaboratedKeywordLoc().isValid()) + return SourceRange(getElaboratedKeywordLoc(), getNameLoc()); else return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc()); } @@ -1607,7 +1603,6 @@ public: }; struct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { - SourceLocation ElaboratedKWLoc; SourceLocation LAngleLoc; SourceLocation RAngleLoc; // followed by a TemplateArgumentLocInfo[] diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index 6a13f75bff..753fdbbae3 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -254,7 +254,7 @@ TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) { void ElaboratedTypeLoc::initializeLocal(ASTContext &Context, SourceLocation Loc) { - setKeywordLoc(Loc); + setElaboratedKeywordLoc(Loc); NestedNameSpecifierLocBuilder Builder; Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc); setQualifierLoc(Builder.getWithLocInContext(Context)); @@ -262,7 +262,7 @@ void ElaboratedTypeLoc::initializeLocal(ASTContext &Context, void DependentNameTypeLoc::initializeLocal(ASTContext &Context, SourceLocation Loc) { - setKeywordLoc(Loc); + setElaboratedKeywordLoc(Loc); NestedNameSpecifierLocBuilder Builder; Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc); setQualifierLoc(Builder.getWithLocInContext(Context)); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 172e931153..7f5bf1d633 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -287,7 +287,7 @@ ParsedType Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, T = getElaboratedType(ETK_None, *SS, T); ElaboratedTypeLoc ElabTL = Builder.push(T); - ElabTL.setKeywordLoc(SourceLocation()); + ElabTL.setElaboratedKeywordLoc(SourceLocation()); ElabTL.setQualifierLoc(SS->getWithLocInContext(Context)); return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); } else { diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 10883af4b4..68f6caad0b 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -10086,12 +10086,12 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, TypeSourceInfo *TSI = Context.CreateTypeSourceInfo(T); if (isa(T)) { DependentNameTypeLoc TL = cast(TSI->getTypeLoc()); - TL.setKeywordLoc(TagLoc); + TL.setElaboratedKeywordLoc(TagLoc); TL.setQualifierLoc(QualifierLoc); TL.setNameLoc(NameLoc); } else { ElaboratedTypeLoc TL = cast(TSI->getTypeLoc()); - TL.setKeywordLoc(TagLoc); + TL.setElaboratedKeywordLoc(TagLoc); TL.setQualifierLoc(QualifierLoc); cast(TL.getNamedTypeLoc()).setNameLoc(NameLoc); } @@ -10114,7 +10114,7 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, QualType T = Context.getDependentNameType(ETK, SS.getScopeRep(), Name); TypeSourceInfo *TSI = Context.CreateTypeSourceInfo(T); DependentNameTypeLoc TL = cast(TSI->getTypeLoc()); - TL.setKeywordLoc(TagLoc); + TL.setElaboratedKeywordLoc(TagLoc); TL.setQualifierLoc(SS.getWithLocInContext(Context)); TL.setNameLoc(NameLoc); diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index ec50782cf3..e4c2fc41ec 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2104,7 +2104,7 @@ Sema::ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, // Create an elaborated-type-specifier containing the nested-name-specifier. Result = Context.getElaboratedType(ETK_None, SS.getScopeRep(), Result); ElaboratedTypeLoc ElabTL = TLB.push(Result); - ElabTL.setKeywordLoc(SourceLocation()); + ElabTL.setElaboratedKeywordLoc(SourceLocation()); ElabTL.setQualifierLoc(SS.getWithLocInContext(Context)); } @@ -2197,7 +2197,7 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK, // and tag keyword. Result = Context.getElaboratedType(Keyword, SS.getScopeRep(), Result); ElaboratedTypeLoc ElabTL = TLB.push(Result); - ElabTL.setKeywordLoc(TagLoc); + ElabTL.setElaboratedKeywordLoc(TagLoc); ElabTL.setQualifierLoc(SS.getWithLocInContext(Context)); return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result)); } @@ -6587,7 +6587,7 @@ Sema::ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // Create type-source location information for this type. TypeLocBuilder TLB; DependentNameTypeLoc TL = TLB.push(Result); - TL.setKeywordLoc(TagLoc); + TL.setElaboratedKeywordLoc(TagLoc); TL.setQualifierLoc(SS.getWithLocInContext(Context)); TL.setNameLoc(NameLoc); return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result)); @@ -6616,12 +6616,12 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, TypeSourceInfo *TSI = Context.CreateTypeSourceInfo(T); if (isa(T)) { DependentNameTypeLoc TL = cast(TSI->getTypeLoc()); - TL.setKeywordLoc(TypenameLoc); + TL.setElaboratedKeywordLoc(TypenameLoc); TL.setQualifierLoc(QualifierLoc); TL.setNameLoc(IdLoc); } else { ElaboratedTypeLoc TL = cast(TSI->getTypeLoc()); - TL.setKeywordLoc(TypenameLoc); + TL.setElaboratedKeywordLoc(TypenameLoc); TL.setQualifierLoc(QualifierLoc); cast(TL.getNamedTypeLoc()).setNameLoc(IdLoc); } @@ -6692,7 +6692,7 @@ Sema::ActOnTypenameType(Scope *S, T = Context.getElaboratedType(ETK_Typename, SS.getScopeRep(), T); ElaboratedTypeLoc TL = Builder.push(T); - TL.setKeywordLoc(TypenameLoc); + TL.setElaboratedKeywordLoc(TypenameLoc); TL.setQualifierLoc(SS.getWithLocInContext(Context)); TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 48b0a5cab3..5102e698b7 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2921,9 +2921,9 @@ namespace { return; } } - TL.setKeywordLoc(Keyword != ETK_None - ? DS.getTypeSpecTypeLoc() - : SourceLocation()); + TL.setElaboratedKeywordLoc(Keyword != ETK_None + ? DS.getTypeSpecTypeLoc() + : SourceLocation()); const CXXScopeSpec& SS = DS.getTypeSpecScope(); TL.setQualifierLoc(SS.getWithLocInContext(Context)); Visit(TL.getNextTypeLoc().getUnqualifiedLoc()); @@ -2939,9 +2939,9 @@ namespace { return; } } - TL.setKeywordLoc(Keyword != ETK_None - ? DS.getTypeSpecTypeLoc() - : SourceLocation()); + TL.setElaboratedKeywordLoc(Keyword != ETK_None + ? DS.getTypeSpecTypeLoc() + : SourceLocation()); const CXXScopeSpec& SS = DS.getTypeSpecScope(); TL.setQualifierLoc(SS.getWithLocInContext(Context)); TL.setNameLoc(DS.getTypeSpecTypeNameLoc()); @@ -3027,7 +3027,7 @@ namespace { assert(isa(ClsTy) && "Unexpected TypeLoc"); { DependentNameTypeLoc DNTLoc = cast(ClsTL); - DNTLoc.setKeywordLoc(SourceLocation()); + DNTLoc.setElaboratedKeywordLoc(SourceLocation()); DNTLoc.setQualifierLoc(NNSLoc.getPrefix()); DNTLoc.setNameLoc(NNSLoc.getLocalBeginLoc()); } @@ -3037,7 +3037,7 @@ namespace { case NestedNameSpecifier::TypeSpecWithTemplate: if (isa(ClsTy)) { ElaboratedTypeLoc ETLoc = *cast(&ClsTL); - ETLoc.setKeywordLoc(SourceLocation()); + ETLoc.setElaboratedKeywordLoc(SourceLocation()); ETLoc.setQualifierLoc(NNSLoc.getPrefix()); TypeLoc NamedTL = ETLoc.getNamedTypeLoc(); NamedTL.initializeFullCopy(NNSLoc.getTypeLoc()); diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index ceadd421fc..29b28c16a1 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -4711,7 +4711,7 @@ TreeTransform::TransformElaboratedType(TypeLocBuilder &TLB, if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() || NamedT != T->getNamedType()) { - Result = getDerived().RebuildElaboratedType(TL.getKeywordLoc(), + Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(), T->getKeyword(), QualifierLoc, NamedT); if (Result.isNull()) @@ -4719,7 +4719,7 @@ TreeTransform::TransformElaboratedType(TypeLocBuilder &TLB, } ElaboratedTypeLoc NewTL = TLB.push(Result); - NewTL.setKeywordLoc(TL.getKeywordLoc()); + NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); NewTL.setQualifierLoc(QualifierLoc); return Result; } @@ -4795,7 +4795,7 @@ QualType TreeTransform::TransformDependentNameType(TypeLocBuilder &TLB, QualType Result = getDerived().RebuildDependentNameType(T->getKeyword(), - TL.getKeywordLoc(), + TL.getElaboratedKeywordLoc(), QualifierLoc, T->getIdentifier(), TL.getNameLoc()); @@ -4807,11 +4807,11 @@ QualType TreeTransform::TransformDependentNameType(TypeLocBuilder &TLB, TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc()); ElaboratedTypeLoc NewTL = TLB.push(Result); - NewTL.setKeywordLoc(TL.getKeywordLoc()); + NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); NewTL.setQualifierLoc(QualifierLoc); } else { DependentNameTypeLoc NewTL = TLB.push(Result); - NewTL.setKeywordLoc(TL.getKeywordLoc()); + NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); NewTL.setQualifierLoc(QualifierLoc); NewTL.setNameLoc(TL.getNameLoc()); } @@ -4876,7 +4876,7 @@ TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, // Copy information relevant to the elaborated type. ElaboratedTypeLoc NewTL = TLB.push(Result); - NewTL.setKeywordLoc(TL.getElaboratedKeywordLoc()); + NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); NewTL.setQualifierLoc(QualifierLoc); } else if (isa(Result)) { DependentTemplateSpecializationTypeLoc SpecTL diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 6e0583b102..64ffb1525f 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -4330,14 +4330,14 @@ void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) { TL.setRParenLoc(ReadSourceLocation(Record, Idx)); } void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { - TL.setKeywordLoc(ReadSourceLocation(Record, Idx)); + TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx)); TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx)); } void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { TL.setNameLoc(ReadSourceLocation(Record, Idx)); } void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { - TL.setKeywordLoc(ReadSourceLocation(Record, Idx)); + TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx)); TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx)); TL.setNameLoc(ReadSourceLocation(Record, Idx)); } diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index c808886d6b..53890cbd46 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -566,14 +566,14 @@ void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) { Writer.AddSourceLocation(TL.getRParenLoc(), Record); } void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { - Writer.AddSourceLocation(TL.getKeywordLoc(), Record); + Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record); Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record); } void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); } void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { - Writer.AddSourceLocation(TL.getKeywordLoc(), Record); + Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record); Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record); Writer.AddSourceLocation(TL.getNameLoc(), Record); } -- 2.40.0