From: Abramo Bagnara Date: Sun, 6 Mar 2011 16:09:14 +0000 (+0000) Subject: Completed source ranges fixes for all classes inheriting from TypeDecl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a868c3799b739781db325c1bd2c6afd182bc9bd6;p=clang Completed source ranges fixes for all classes inheriting from TypeDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127120 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 6665b27d10..2ee330b4f8 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -2038,7 +2038,6 @@ protected: bool IsFixed : 1; private: - SourceLocation TagKeywordLoc; SourceLocation RBraceLoc; // A struct representing syntactic qualifier info, @@ -2061,8 +2060,8 @@ private: protected: TagDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - TagDecl *PrevDecl, SourceLocation TKL = SourceLocation()) - : TypeDecl(DK, DC, L, Id), DeclContext(DK), TagKeywordLoc(TKL), + TagDecl *PrevDecl, SourceLocation StartL) + : TypeDecl(DK, DC, L, Id, StartL), DeclContext(DK), TypedefDeclOrQualifier((TypedefDecl*) 0) { assert((DK != Enum || TK == TTK_Enum) && "EnumDecl not matched with TTK_Enum"); @@ -2093,12 +2092,9 @@ public: SourceLocation getRBraceLoc() const { return RBraceLoc; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } - SourceLocation getTagKeywordLoc() const { return TagKeywordLoc; } - void setTagKeywordLoc(SourceLocation TKL) { TagKeywordLoc = TKL; } - /// getInnerLocStart - Return SourceLocation representing start of source /// range ignoring outer template declarations. - virtual SourceLocation getInnerLocStart() const { return TagKeywordLoc; } + virtual SourceLocation getInnerLocStart() const { return getLocStart(); } /// getOuterLocStart - Return SourceLocation representing start of source /// range taking into account any outer template declarations. @@ -2261,17 +2257,18 @@ class EnumDecl : public TagDecl { }; EnumDecl(DeclContext *DC, SourceLocation L, - IdentifierInfo *Id, EnumDecl *PrevDecl, SourceLocation TKL, + IdentifierInfo *Id, EnumDecl *PrevDecl, SourceLocation StartL, bool Scoped, bool ScopedUsingClassTag, bool Fixed) - : TagDecl(Enum, TTK_Enum, DC, L, Id, PrevDecl, TKL), InstantiatedFrom(0) { - assert(Scoped || !ScopedUsingClassTag); - IntegerType = (const Type*)0; - NumNegativeBits = 0; - NumPositiveBits = 0; - IsScoped = Scoped; - IsScopedUsingClassTag = ScopedUsingClassTag; - IsFixed = Fixed; - } + : TagDecl(Enum, TTK_Enum, DC, L, Id, PrevDecl, StartL), + InstantiatedFrom(0) { + assert(Scoped || !ScopedUsingClassTag); + IntegerType = (const Type*)0; + NumNegativeBits = 0; + NumPositiveBits = 0; + IsScoped = Scoped; + IsScopedUsingClassTag = ScopedUsingClassTag; + IsFixed = Fixed; + } public: EnumDecl *getCanonicalDecl() { return cast(TagDecl::getCanonicalDecl()); @@ -2289,7 +2286,7 @@ public: static EnumDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - SourceLocation TKL, EnumDecl *PrevDecl, + SourceLocation StartL, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed); static EnumDecl *Create(ASTContext &C, EmptyShell Empty); @@ -2445,12 +2442,12 @@ class RecordDecl : public TagDecl { protected: RecordDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - RecordDecl *PrevDecl, SourceLocation TKL); + RecordDecl *PrevDecl, SourceLocation StartL); public: static RecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - SourceLocation TKL = SourceLocation(), + SourceLocation StartL = SourceLocation(), RecordDecl* PrevDecl = 0); static RecordDecl *Create(const ASTContext &C, EmptyShell Empty); diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 302aac739f..0473ae0455 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -451,7 +451,7 @@ protected: CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, CXXRecordDecl *PrevDecl, - SourceLocation TKL = SourceLocation()); + SourceLocation StartL = SourceLocation()); public: /// base_class_iterator - Iterator that traverses the base classes @@ -495,7 +495,7 @@ public: static CXXRecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - SourceLocation TKL = SourceLocation(), + SourceLocation StartL = SourceLocation(), CXXRecordDecl* PrevDecl=0, bool DelayTypeCreation = false); static CXXRecordDecl *Create(const ASTContext &C, EmptyShell Empty); @@ -2225,15 +2225,15 @@ class UnresolvedUsingTypenameDecl : public TypeDecl { NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, IdentifierInfo *TargetName) - : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName), - UsingLocation(UsingLoc), TypenameLocation(TypenameLoc), - QualifierLoc(QualifierLoc) { } + : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName, + UsingLoc), + TypenameLocation(TypenameLoc), QualifierLoc(QualifierLoc) { } friend class ASTDeclReader; public: /// \brief Returns the source location of the 'using' keyword. - SourceLocation getUsingLoc() const { return UsingLocation; } + SourceLocation getUsingLoc() const { return getLocStart(); } /// \brief Returns the source location of the 'typename' keyword. SourceLocation getTypenameLoc() const { return TypenameLocation; } @@ -2252,10 +2252,6 @@ public: SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName); - SourceRange getSourceRange() const { - return SourceRange(UsingLocation, getLocation()); - } - static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const UnresolvedUsingTypenameDecl *D) { return true; } static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; } diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 41de4bb695..c1c9736e30 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2095,7 +2095,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) { // Create the enum declaration. EnumDecl *D2 = EnumDecl::Create(Importer.getToContext(), DC, Loc, Name.getAsIdentifierInfo(), - Importer.Import(D->getTagKeywordLoc()), 0, + Importer.Import(D->getLocStart()), 0, D->isScoped(), D->isScopedUsingClassTag(), D->isFixed()); // Import the qualifier, if any. @@ -2214,14 +2214,14 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { D->getTagKind(), DC, Loc, Name.getAsIdentifierInfo(), - Importer.Import(D->getTagKeywordLoc())); + Importer.Import(D->getLocStart())); D2 = D2CXX; D2->setAccess(D->getAccess()); } else { D2 = RecordDecl::Create(Importer.getToContext(), D->getTagKind(), DC, Loc, Name.getAsIdentifierInfo(), - Importer.Import(D->getTagKeywordLoc())); + Importer.Import(D->getLocStart())); } D2->setQualifierInfo(Importer.Import(D->getQualifierLoc())); @@ -3575,7 +3575,7 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { DC, Importer.Import(DTemplated->getLocation()), Name.getAsIdentifierInfo(), - Importer.Import(DTemplated->getTagKeywordLoc())); + Importer.Import(DTemplated->getLocStart())); D2Templated->setAccess(DTemplated->getAccess()); D2Templated->setQualifierInfo(Importer.Import(DTemplated->getQualifierLoc())); D2Templated->setLexicalDeclContext(LexicalDC); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index a2f23e83e4..20e9be023a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -6649,7 +6649,7 @@ void Sema::ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagD, = CXXRecordDecl::Create(Context, Record->getTagKind(), CurContext, Record->getLocation(), Record->getIdentifier(), - Record->getTagKeywordLoc(), + Record->getLocStart(), /*PrevDecl=*/0, /*DelayTypeCreation=*/true); Context.getTypeDeclType(InjectedClassName, Record); diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 0650e45827..0b46642f87 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -533,7 +533,7 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) { Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner, D->getLocation(), D->getIdentifier(), - D->getTagKeywordLoc(), + D->getLocStart(), /*PrevDecl=*/0, D->isScoped(), D->isScopedUsingClassTag(), D->isFixed()); if (D->isFixed()) { @@ -759,7 +759,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { CXXRecordDecl *RecordInst = CXXRecordDecl::Create(SemaRef.Context, Pattern->getTagKind(), DC, Pattern->getLocation(), Pattern->getIdentifier(), - Pattern->getTagKeywordLoc(), PrevDecl, + Pattern->getLocStart(), PrevDecl, /*DelayTypeCreation=*/true); if (QualifierLoc) @@ -901,7 +901,7 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { CXXRecordDecl *Record = CXXRecordDecl::Create(SemaRef.Context, D->getTagKind(), Owner, D->getLocation(), D->getIdentifier(), - D->getTagKeywordLoc(), PrevDecl); + D->getLocStart(), PrevDecl); // Substitute the nested name specifier, if any. if (SubstQualifier(D, Record)) diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index a519aa6f72..b145d5b3e7 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -248,7 +248,6 @@ void ASTDeclReader::VisitTagDecl(TagDecl *TD) { TD->setDefinition(Record[Idx++]); TD->setEmbeddedInDeclarator(Record[Idx++]); TD->setRBraceLoc(ReadSourceLocation(Record, Idx)); - TD->setTagKeywordLoc(ReadSourceLocation(Record, Idx)); if (Record[Idx++]) { // hasExtInfo TagDecl::ExtInfo *Info = new (*Reader.getContext()) TagDecl::ExtInfo(); ReadQualifierInfo(*Info, Record, Idx); @@ -815,7 +814,6 @@ void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( UnresolvedUsingTypenameDecl *D) { VisitTypeDecl(D); - D->UsingLocation = ReadSourceLocation(Record, Idx); D->TypenameLocation = ReadSourceLocation(Record, Idx); D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); } diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 99b9fc22cf..96b26e8bf7 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -175,7 +175,6 @@ void ASTDeclWriter::VisitTagDecl(TagDecl *D) { Record.push_back(D->isDefinition()); Record.push_back(D->isEmbeddedInDeclarator()); Writer.AddSourceLocation(D->getRBraceLoc(), Record); - Writer.AddSourceLocation(D->getTagKeywordLoc(), Record); Record.push_back(D->hasExtInfo()); if (D->hasExtInfo()) Writer.AddQualifierInfo(*D->getExtInfo(), Record); @@ -744,7 +743,6 @@ void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl( UnresolvedUsingTypenameDecl *D) { VisitTypeDecl(D); - Writer.AddSourceLocation(D->getUsingLoc(), Record); Writer.AddSourceLocation(D->getTypenameLoc(), Record); Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record); Code = serialization::DECL_UNRESOLVED_USING_TYPENAME;