]> granicus.if.org Git - clang/commitdiff
The location of the name in MacroDefinition is the beginning of its range,
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 20 Sep 2011 22:14:48 +0000 (22:14 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 20 Sep 2011 22:14:48 +0000 (22:14 +0000)
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

include/clang/Lex/PreprocessingRecord.h
lib/Lex/PreprocessingRecord.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp

index bf1bb5301b69dcb0d231e8bffb563ac12ecee97e..c76224d1244abf28754ba3ec77e1f98b6f2e16a6 100644 (file)
@@ -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) {
index a4315b78d5bb5c910300b52710e850f10a46fb41..2368b389810ca1bd0290751392cf8a763f292a62 100644 (file)
@@ -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);
index 25b86876b3d44f08a5526dc1a48ab7b2052ac6f5..392658d48e86c9e74300dc6a6988f8e851cd2235 100644 (file)
@@ -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])));
index 2aa1e6c4e3f242e70dfde35a51bc47e7f69dd940..f646c59ebddf6fde5242471bb71eafe9e94e1721 100644 (file)
@@ -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;
     }