[cfe-commits] r136057 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp lib/Lex/Lexer.cpp lib/Serialization/ASTWriter.cpp

Chandler Carruth chandlerc at gmail.com
Mon Jul 25 21:56:51 PDT 2011


Author: chandlerc
Date: Mon Jul 25 23:56:51 2011
New Revision: 136057

URL: http://llvm.org/viewvc/llvm-project?rev=136057&view=rev
Log:
Migrate 'Instantiation' data and API bits of SLocEntry to 'Expansion'
etc. With this I think essentially all of the SourceManager APIs are
converted. Comments and random other bits of cleanup should be all thats
left.

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Basic/SourceManager.cpp
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=136057&r1=136056&r2=136057&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jul 25 23:56:51 2011
@@ -312,22 +312,22 @@
     unsigned Offset;   // low bit is set for instantiation info.
     union {
       FileInfo File;
-      ExpansionInfo Instantiation;
+      ExpansionInfo Expansion;
     };
   public:
     unsigned getOffset() const { return Offset >> 1; }
 
-    bool isInstantiation() const { return Offset & 1; }
-    bool isFile() const { return !isInstantiation(); }
+    bool isExpansion() const { return Offset & 1; }
+    bool isFile() const { return !isExpansion(); }
 
     const FileInfo &getFile() const {
       assert(isFile() && "Not a file SLocEntry!");
       return File;
     }
 
-    const ExpansionInfo &getInstantiation() const {
-      assert(isInstantiation() && "Not an instantiation SLocEntry!");
-      return Instantiation;
+    const ExpansionInfo &getExpansion() const {
+      assert(isExpansion() && "Not a macro expansion SLocEntry!");
+      return Expansion;
     }
 
     static SLocEntry get(unsigned Offset, const FileInfo &FI) {
@@ -340,7 +340,7 @@
     static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) {
       SLocEntry E;
       E.Offset = (Offset << 1) | 1;
-      E.Instantiation = Expansion;
+      E.Expansion = Expansion;
       return E;
     }
   };

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=136057&r1=136056&r2=136057&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Jul 25 23:56:51 2011
@@ -669,7 +669,7 @@
 
       // If this isn't an instantiation, remember it.  We have good locality
       // across FileID lookups.
-      if (!I->isInstantiation())
+      if (!I->isExpansion())
         LastFileIDLookup = Res;
       NumLinearScans += NumProbes+1;
       return Res;
@@ -708,9 +708,9 @@
     if (isOffsetInFileID(FileID::get(MiddleIndex), SLocOffset)) {
       FileID Res = FileID::get(MiddleIndex);
 
-      // If this isn't an instantiation, remember it.  We have good locality
+      // If this isn't a macro expansion, remember it.  We have good locality
       // across FileID lookups.
-      if (!LocalSLocEntryTable[MiddleIndex].isInstantiation())
+      if (!LocalSLocEntryTable[MiddleIndex].isExpansion())
         LastFileIDLookup = Res;
       NumBinaryProbes += NumProbes;
       return Res;
@@ -746,7 +746,7 @@
     if (E.getOffset() <= SLocOffset) {
       FileID Res = FileID::get(-int(I) - 2);
 
-      if (!E.isInstantiation())
+      if (!E.isExpansion())
         LastFileIDLookup = Res;
       NumLinearScans += NumProbes + 1;
       return Res;
@@ -773,7 +773,7 @@
 
     if (isOffsetInFileID(FileID::get(-int(MiddleIndex) - 2), SLocOffset)) {
       FileID Res = FileID::get(-int(MiddleIndex) - 2);
-      if (!E.isInstantiation())
+      if (!E.isExpansion())
         LastFileIDLookup = Res;
       NumBinaryProbes += NumProbes;
       return Res;
@@ -788,12 +788,11 @@
   do {
     // Note: If Loc indicates an offset into a token that came from a macro
     // expansion (e.g. the 5th character of the token) we do not want to add
-    // this offset when going to the instantiation location.  The expansion
+    // this offset when going to the expansion location.  The expansion
     // location is the macro invocation, which the offset has nothing to do
     // with.  This is unlike when we get the spelling loc, because the offset
     // directly correspond to the token whose spelling we're inspecting.
-    Loc = getSLocEntry(getFileID(Loc)).getInstantiation()
-                   .getExpansionLocStart();
+    Loc = getSLocEntry(getFileID(Loc)).getExpansion().getExpansionLocStart();
   } while (!Loc.isFileID());
 
   return Loc;
@@ -802,7 +801,7 @@
 SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const {
   do {
     std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
-    Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
+    Loc = getSLocEntry(LocInfo.first).getExpansion().getSpellingLoc();
     Loc = Loc.getFileLocWithOffset(LocInfo.second);
   } while (!Loc.isFileID());
   return Loc;
@@ -818,7 +817,7 @@
   SourceLocation Loc;
   unsigned Offset;
   do {
-    Loc = E->getInstantiation().getExpansionLocStart();
+    Loc = E->getExpansion().getExpansionLocStart();
 
     FID = getFileID(Loc);
     E = &getSLocEntry(FID);
@@ -836,7 +835,7 @@
   FileID FID;
   SourceLocation Loc;
   do {
-    Loc = E->getInstantiation().getSpellingLoc();
+    Loc = E->getExpansion().getSpellingLoc();
 
     FID = getFileID(Loc);
     E = &getSLocEntry(FID);
@@ -853,7 +852,7 @@
 SourceLocation SourceManager::getImmediateSpellingLoc(SourceLocation Loc) const{
   if (Loc.isFileID()) return Loc;
   std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
-  Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
+  Loc = getSLocEntry(LocInfo.first).getExpansion().getSpellingLoc();
   return Loc.getFileLocWithOffset(LocInfo.second);
 }
 
@@ -863,8 +862,7 @@
 std::pair<SourceLocation,SourceLocation>
 SourceManager::getImmediateExpansionRange(SourceLocation Loc) const {
   assert(Loc.isMacroID() && "Not an instantiation loc!");
-  const ExpansionInfo &Expansion =
-    getSLocEntry(getFileID(Loc)).getInstantiation();
+  const ExpansionInfo &Expansion = getSLocEntry(getFileID(Loc)).getExpansion();
   return Expansion.getExpansionLocRange();
 }
 
@@ -891,7 +889,7 @@
 
   FileID FID = getFileID(Loc);
   const SrcMgr::SLocEntry *E = &getSLocEntry(FID);
-  const SrcMgr::ExpansionInfo &Expansion = E->getInstantiation();
+  const SrcMgr::ExpansionInfo &Expansion = E->getExpansion();
   return Expansion.isMacroArgExpansion();
 }
 
@@ -1466,8 +1464,8 @@
                                    const SourceManager &SM) {
   SourceLocation UpperLoc;
   const SrcMgr::SLocEntry &Entry = SM.getSLocEntry(Loc.first);
-  if (Entry.isInstantiation())
-    UpperLoc = Entry.getInstantiation().getExpansionLocStart();
+  if (Entry.isExpansion())
+    UpperLoc = Entry.getExpansion().getExpansionLocStart();
   else
     UpperLoc = Entry.getFile().getIncludeLoc();
   

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=136057&r1=136056&r2=136057&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Mon Jul 25 23:56:51 2011
@@ -713,8 +713,7 @@
     return false; // Does not point at the start of token.
 
   SourceLocation expansionLoc =
-    SM.getSLocEntry(infoLoc.first)
-      .getInstantiation().getExpansionLocStart();
+    SM.getSLocEntry(infoLoc.first).getExpansion().getExpansionLocStart();
   if (expansionLoc.isFileID())
     return true; // No other macro expansions, this is the first.
 
@@ -744,7 +743,7 @@
     return false; // Still in the same FileID, does not point to the last token.
   
   SourceLocation expansionLoc =
-    SM.getSLocEntry(FID).getInstantiation().getExpansionLocEnd();
+    SM.getSLocEntry(FID).getExpansion().getExpansionLocEnd();
   if (expansionLoc.isFileID())
     return true; // No other macro expansions.
 

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=136057&r1=136056&r2=136057&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Jul 25 23:56:51 2011
@@ -1505,7 +1505,7 @@
       }
     } else {
       // The source location entry is a macro expansion.
-      const SrcMgr::ExpansionInfo &Expansion = SLoc->getInstantiation();
+      const SrcMgr::ExpansionInfo &Expansion = SLoc->getExpansion();
       Record.push_back(Expansion.getSpellingLoc().getRawEncoding());
       Record.push_back(Expansion.getExpansionLocStart().getRawEncoding());
       Record.push_back(Expansion.getExpansionLocEnd().getRawEncoding());





More information about the cfe-commits mailing list