[cfe-commits] r69191 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp

Douglas Gregor dgregor at apple.com
Wed Apr 15 11:05:10 PDT 2009


Author: dgregor
Date: Wed Apr 15 13:05:10 2009
New Revision: 69191

URL: http://llvm.org/viewvc/llvm-project?rev=69191&view=rev
Log:
For source location entries that describe instantiations, encode the
token length in the PCH file rather than trying (and failing) to
reconstruct it be getting the spelling token's length.

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Frontend/PCHWriter.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=69191&r1=69190&r2=69191&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed Apr 15 13:05:10 2009
@@ -635,6 +635,8 @@
     return SLocEntryTable[FID.ID];
   }
 
+  unsigned getNextOffset() const { return NextOffset; }
+
 private:
   friend class SrcMgr::ContentCache; // Used for deserialization.
   

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69191&r1=69190&r2=69191&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Apr 15 13:05:10 2009
@@ -612,9 +612,7 @@
                               SpellingLoc,
                               SourceLocation::getFromRawEncoding(Record[2]),
                               SourceLocation::getFromRawEncoding(Record[3]),
-                              Lexer::MeasureTokenLength(SpellingLoc, 
-                                                        SourceMgr,
-                                                        PP.getLangOptions()));
+                              Record[4]);
       break;
     }
 

Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69191&r1=69190&r2=69191&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Apr 15 13:05:10 2009
@@ -736,6 +736,7 @@
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Spelling location
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Start location
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // End location
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
   return S.EmitAbbrev(Abbrev);
 }
 
@@ -818,6 +819,13 @@
       Record.push_back(Inst.getInstantiationLocStart().getRawEncoding());
       Record.push_back(Inst.getInstantiationLocEnd().getRawEncoding());
 
+      // Compute the token length for this macro expansion.
+      unsigned NextOffset = SourceMgr.getNextOffset();
+      SourceManager::sloc_entry_iterator NextSLoc = SLoc;
+      if (++NextSLoc != SLocEnd)
+        NextOffset = NextSLoc->getOffset();
+      Record.push_back(NextOffset - SLoc->getOffset() - 1);
+
       if (SLocInstantiationAbbrv == -1)
         SLocInstantiationAbbrv = CreateSLocInstantiationAbbrev(S);
       S.EmitRecordWithAbbrev(SLocInstantiationAbbrv, Record);





More information about the cfe-commits mailing list