From: Argyrios Kyrtzidis Date: Tue, 20 Sep 2011 22:14:48 +0000 (+0000) Subject: The location of the name in MacroDefinition is the beginning of its range, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de4e0a8e57e643bbe78ad37ad6023c45a8a9f7e2;p=clang The location of the name in MacroDefinition is the beginning of its range, don't store an extra location for it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140190 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h index bf1bb5301b..c76224d124 100644 --- a/include/clang/Lex/PreprocessingRecord.h +++ b/include/clang/Lex/PreprocessingRecord.h @@ -138,21 +138,16 @@ namespace clang { class MacroDefinition : public PreprocessingDirective { /// \brief The name of the macro being defined. const IdentifierInfo *Name; - - /// \brief The location of the macro name in the macro definition. - SourceLocation Location; public: - explicit MacroDefinition(const IdentifierInfo *Name, SourceLocation Location, - SourceRange Range) - : PreprocessingDirective(MacroDefinitionKind, Range), Name(Name), - Location(Location) { } + explicit MacroDefinition(const IdentifierInfo *Name, SourceRange Range) + : PreprocessingDirective(MacroDefinitionKind, Range), Name(Name) { } /// \brief Retrieve the name of the macro being defined. const IdentifierInfo *getName() const { return Name; } /// \brief Retrieve the location of the macro name in the definition. - SourceLocation getLocation() const { return Location; } + SourceLocation getLocation() const { return getSourceRange().getBegin(); } // Implement isa/cast/dyncast/etc. static bool classof(const PreprocessedEntity *PE) { diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp index a4315b78d5..2368b38981 100644 --- a/lib/Lex/PreprocessingRecord.cpp +++ b/lib/Lex/PreprocessingRecord.cpp @@ -229,9 +229,7 @@ void PreprocessingRecord::MacroDefined(const Token &Id, const MacroInfo *MI) { SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc()); MacroDefinition *Def - = new (*this) MacroDefinition(Id.getIdentifierInfo(), - MI->getDefinitionLoc(), - R); + = new (*this) MacroDefinition(Id.getIdentifierInfo(), R); addPreprocessedEntity(Def); MacroDefinitions[MI] = getPPEntityID(PreprocessedEntities.size()-1, /*isLoaded=*/false); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 25b86876b3..392658d48e 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1404,7 +1404,6 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { IdentifierInfo *II = getLocalIdentifier(F, Record[3]); MacroDefinition *MD = new (PPRec) MacroDefinition(II, - ReadSourceLocation(F, Record[4]), SourceRange( ReadSourceLocation(F, Record[1]), ReadSourceLocation(F, Record[2]))); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 2aa1e6c4e3..f646c59ebd 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1759,7 +1759,6 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { AddSourceLocation(MD->getSourceRange().getBegin(), Record); AddSourceLocation(MD->getSourceRange().getEnd(), Record); AddIdentifierRef(MD->getName(), Record); - AddSourceLocation(MD->getLocation(), Record); Stream.EmitRecord(PPD_MACRO_DEFINITION, Record); continue; }