[cfe-commits] r135138 - in /cfe/trunk: include/clang/Lex/Lexer.h include/clang/Lex/Preprocessor.h lib/ARCMigrate/TransformActions.cpp lib/ARCMigrate/Transforms.cpp lib/Lex/Lexer.cpp lib/Parse/ParseExpr.cpp

Chandler Carruth chandlerc at gmail.com
Thu Jul 14 01:20:40 PDT 2011


Author: chandlerc
Date: Thu Jul 14 03:20:40 2011
New Revision: 135138

URL: http://llvm.org/viewvc/llvm-project?rev=135138&view=rev
Log:
Convert terminology in the Lexer from 'instantiate' and variants to
'expand'. Also update the public API it provides to the new term, and
propagate that update to the various clients.

No functionality changed.

Modified:
    cfe/trunk/include/clang/Lex/Lexer.h
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/ARCMigrate/TransformActions.cpp
    cfe/trunk/lib/ARCMigrate/Transforms.cpp
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=135138&r1=135137&r2=135138&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Thu Jul 14 03:20:40 2011
@@ -95,8 +95,8 @@
   /// _Pragma expansion.  This has a variety of magic semantics that this method
   /// sets up.  It returns a new'd Lexer that must be delete'd when done.
   static Lexer *Create_PragmaLexer(SourceLocation SpellingLoc,
-                                   SourceLocation InstantiationLocStart,
-                                   SourceLocation InstantiationLocEnd,
+                                   SourceLocation ExpansionLocStart,
+                                   SourceLocation ExpansionLocEnd,
                                    unsigned TokLen, Preprocessor &PP);
 
 
@@ -241,8 +241,8 @@
   /// is not necessary to copy any data, then the returned string may
   /// not point into the provided buffer.
   ///
-  /// This method lexes at the instantiation depth of the given
-  /// location and does not jump to the instantiation or spelling
+  /// This method lexes at the expansion depth of the given
+  /// location and does not jump to the expansion or spelling
   /// location.
   static llvm::StringRef getSpelling(SourceLocation loc,
                                      llvm::SmallVectorImpl<char> &buffer,
@@ -295,14 +295,14 @@
                                             const LangOptions &Features);
 
   /// \brief Returns true if the given MacroID location points at the first
-  /// token of the macro instantiation.
-  static bool isAtStartOfMacroInstantiation(SourceLocation loc,
+  /// token of the macro expansion.
+  static bool isAtStartOfMacroExpansion(SourceLocation loc,
                                             const SourceManager &SM,
                                             const LangOptions &LangOpts);
 
   /// \brief Returns true if the given MacroID location points at the last
-  /// token of the macro instantiation.
-  static bool isAtEndOfMacroInstantiation(SourceLocation loc,
+  /// token of the macro expansion.
+  static bool isAtEndOfMacroExpansion(SourceLocation loc,
                                           const SourceManager &SM,
                                           const LangOptions &LangOpts);
 

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=135138&r1=135137&r2=135138&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jul 14 03:20:40 2011
@@ -755,14 +755,14 @@
 
   /// \brief Returns true if the given MacroID location points at the first
   /// token of the macro instantiation.
-  bool isAtStartOfMacroInstantiation(SourceLocation loc) const {
-    return Lexer::isAtStartOfMacroInstantiation(loc, SourceMgr, Features);
+  bool isAtStartOfMacroExpansion(SourceLocation loc) const {
+    return Lexer::isAtStartOfMacroExpansion(loc, SourceMgr, Features);
   }
 
   /// \brief Returns true if the given MacroID location points at the last
   /// token of the macro instantiation.
-  bool isAtEndOfMacroInstantiation(SourceLocation loc) const {
-    return Lexer::isAtEndOfMacroInstantiation(loc, SourceMgr, Features);
+  bool isAtEndOfMacroExpansion(SourceLocation loc) const {
+    return Lexer::isAtEndOfMacroExpansion(loc, SourceMgr, Features);
   }
 
   /// DumpToken - Print the token to stderr, used for debugging.

Modified: cfe/trunk/lib/ARCMigrate/TransformActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransformActions.cpp?rev=135138&r1=135137&r2=135138&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransformActions.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransformActions.cpp Thu Jul 14 03:20:40 2011
@@ -388,7 +388,7 @@
 
   if (loc.isFileID())
     return true;
-  return PP.isAtStartOfMacroInstantiation(loc);
+  return PP.isAtStartOfMacroExpansion(loc);
 }
 
 bool TransformActionsImpl::canInsertAfterToken(SourceLocation loc) {
@@ -401,7 +401,7 @@
 
   if (loc.isFileID())
     return true;
-  return PP.isAtEndOfMacroInstantiation(loc);
+  return PP.isAtEndOfMacroExpansion(loc);
 }
 
 bool TransformActionsImpl::canRemoveRange(SourceRange range) {

Modified: cfe/trunk/lib/ARCMigrate/Transforms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=135138&r1=135137&r2=135138&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.cpp Thu Jul 14 03:20:40 2011
@@ -94,7 +94,7 @@
                                             ASTContext &Ctx) {
   SourceManager &SM = Ctx.getSourceManager();
   if (loc.isMacroID()) {
-    if (!Lexer::isAtEndOfMacroInstantiation(loc, SM, Ctx.getLangOptions()))
+    if (!Lexer::isAtEndOfMacroExpansion(loc, SM, Ctx.getLangOptions()))
       return SourceLocation();
     loc = SM.getInstantiationRange(loc).second;
   }

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=135138&r1=135137&r2=135138&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Jul 14 03:20:40 2011
@@ -156,7 +156,7 @@
 ///
 /// On entrance to this routine, TokStartLoc is a macro location which has a
 /// spelling loc that indicates the bytes to be lexed for the token and an
-/// instantiation location that indicates where all lexed tokens should be
+/// expansion location that indicates where all lexed tokens should be
 /// "expanded from".
 ///
 /// FIXME: It would really be nice to make _Pragma just be a wrapper around a
@@ -166,8 +166,8 @@
 /// out of the critical path of the lexer!
 ///
 Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
-                                 SourceLocation InstantiationLocStart,
-                                 SourceLocation InstantiationLocEnd,
+                                 SourceLocation ExpansionLocStart,
+                                 SourceLocation ExpansionLocEnd,
                                  unsigned TokLen, Preprocessor &PP) {
   SourceManager &SM = PP.getSourceManager();
 
@@ -188,8 +188,8 @@
   // Set the SourceLocation with the remapping information.  This ensures that
   // GetMappedTokenLoc will remap the tokens as they are lexed.
   L->FileLoc = SM.createInstantiationLoc(SM.getLocForStartOfFile(SpellingFID),
-                                         InstantiationLocStart,
-                                         InstantiationLocEnd, TokLen);
+                                         ExpansionLocStart,
+                                         ExpansionLocEnd, TokLen);
 
   // Ensure that the lexer thinks it is inside a directive, so that end \n will
   // return an EOD token.
@@ -621,7 +621,7 @@
                                               unsigned CharNo,
                                               const SourceManager &SM,
                                               const LangOptions &Features) {
-  // Figure out how many physical characters away the specified instantiation
+  // Figure out how many physical characters away the specified expansion
   // character is.  This needs to take into consideration newlines and
   // trigraphs.
   bool Invalid = false;
@@ -683,10 +683,10 @@
     return SourceLocation();
 
   if (Loc.isMacroID()) {
-    if (Offset > 0 || !isAtEndOfMacroInstantiation(Loc, SM, Features))
-      return SourceLocation(); // Points inside the macro instantiation.
+    if (Offset > 0 || !isAtEndOfMacroExpansion(Loc, SM, Features))
+      return SourceLocation(); // Points inside the macro expansion.
 
-    // Continue and find the location just after the macro instantiation.
+    // Continue and find the location just after the macro expansion.
     Loc = SM.getInstantiationRange(Loc).second;
   }
 
@@ -700,8 +700,8 @@
 }
 
 /// \brief Returns true if the given MacroID location points at the first
-/// token of the macro instantiation.
-bool Lexer::isAtStartOfMacroInstantiation(SourceLocation loc,
+/// token of the macro expansion.
+bool Lexer::isAtStartOfMacroExpansion(SourceLocation loc,
                                           const SourceManager &SM,
                                           const LangOptions &LangOpts) {
   assert(loc.isValid() && loc.isMacroID() && "Expected a valid macro loc");
@@ -712,17 +712,18 @@
   if (infoLoc.second > 0)
     return false; // Does not point at the start of token.
 
-  SourceLocation instLoc = 
-      SM.getSLocEntry(infoLoc.first).getInstantiation().getInstantiationLocStart();
-  if (instLoc.isFileID())
-    return true; // No other macro instantiations, this is the first.
+  SourceLocation expansionLoc =
+    SM.getSLocEntry(infoLoc.first)
+      .getInstantiation().getInstantiationLocStart();
+  if (expansionLoc.isFileID())
+    return true; // No other macro expansions, this is the first.
 
-  return isAtStartOfMacroInstantiation(instLoc, SM, LangOpts);
+  return isAtStartOfMacroExpansion(expansionLoc, SM, LangOpts);
 }
 
 /// \brief Returns true if the given MacroID location points at the last
-/// token of the macro instantiation.
-bool Lexer::isAtEndOfMacroInstantiation(SourceLocation loc,
+/// token of the macro expansion.
+bool Lexer::isAtEndOfMacroExpansion(SourceLocation loc,
                                         const SourceManager &SM,
                                         const LangOptions &LangOpts) {
   assert(loc.isValid() && loc.isMacroID() && "Expected a valid macro loc");
@@ -742,12 +743,12 @@
   if (FID == SM.getFileID(afterLoc))
     return false; // Still in the same FileID, does not point to the last token.
   
-  SourceLocation instLoc = 
+  SourceLocation expansionLoc =
     SM.getSLocEntry(FID).getInstantiation().getInstantiationLocEnd();
-  if (instLoc.isFileID())
-    return true; // No other macro instantiations.
+  if (expansionLoc.isFileID())
+    return true; // No other macro expansions.
 
-  return isAtEndOfMacroInstantiation(instLoc, SM, LangOpts);
+  return isAtEndOfMacroExpansion(expansionLoc, SM, LangOpts);
 }
 
 //===----------------------------------------------------------------------===//
@@ -888,7 +889,7 @@
 //===----------------------------------------------------------------------===//
 
 /// GetMappedTokenLoc - If lexing out of a 'mapped buffer', where we pretend the
-/// lexer buffer was all instantiated at a single point, perform the mapping.
+/// lexer buffer was all expanded at a single point, perform the mapping.
 /// This is currently only used for _Pragma implementation, so it is the slow
 /// path of the hot getSourceLocation method.  Do not allow it to be inlined.
 static LLVM_ATTRIBUTE_NOINLINE SourceLocation GetMappedTokenLoc(
@@ -896,14 +897,14 @@
 static SourceLocation GetMappedTokenLoc(Preprocessor &PP,
                                         SourceLocation FileLoc,
                                         unsigned CharNo, unsigned TokLen) {
-  assert(FileLoc.isMacroID() && "Must be an instantiation");
+  assert(FileLoc.isMacroID() && "Must be a macro expansion");
 
   // Otherwise, we're lexing "mapped tokens".  This is used for things like
-  // _Pragma handling.  Combine the instantiation location of FileLoc with the
+  // _Pragma handling.  Combine the expansion location of FileLoc with the
   // spelling location.
   SourceManager &SM = PP.getSourceManager();
 
-  // Create a new SLoc which is expanded from Instantiation(FileLoc) but whose
+  // Create a new SLoc which is expanded from Expansion(FileLoc) but whose
   // characters come from spelling(FileLoc)+Offset.
   SourceLocation SpellingLoc = SM.getSpellingLoc(FileLoc);
   SpellingLoc = SpellingLoc.getFileLocWithOffset(CharNo);

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=135138&r1=135137&r2=135138&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Jul 14 03:20:40 2011
@@ -310,7 +310,7 @@
         SourceLocation FILoc = Tok.getLocation();
         const char *FIText = ": ";
         const SourceManager &SM = PP.getSourceManager();
-        if (FILoc.isFileID() || PP.isAtStartOfMacroInstantiation(FILoc)) {
+        if (FILoc.isFileID() || PP.isAtStartOfMacroExpansion(FILoc)) {
           FILoc = SM.getInstantiationLoc(FILoc);
           bool IsInvalid = false;
           const char *SourcePtr =





More information about the cfe-commits mailing list