[cfe-commits] r135137 - in /cfe/trunk: include/clang/Lex/TokenLexer.h lib/Lex/TokenLexer.cpp

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


Author: chandlerc
Date: Thu Jul 14 03:20:34 2011
New Revision: 135137

URL: http://llvm.org/viewvc/llvm-project?rev=135137&view=rev
Log:
Switch the TokenLexer's terminology from various forms of 'instantiate'
to 'expand' for macros. Only comments and uses local to the TokenLexer
are updated.

No functionality changed.

Modified:
    cfe/trunk/include/clang/Lex/TokenLexer.h
    cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=135137&r1=135136&r2=135137&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
+++ cfe/trunk/include/clang/Lex/TokenLexer.h Thu Jul 14 03:20:34 2011
@@ -59,15 +59,15 @@
   ///
   unsigned CurToken;
 
-  /// InstantiateLocStart/End - The source location range where this macro was
-  /// instantiated.
-  SourceLocation InstantiateLocStart, InstantiateLocEnd;
+  /// ExpandLocStart/End - The source location range where this macro was
+  /// expanded.
+  SourceLocation ExpandLocStart, ExpandLocEnd;
 
   /// \brief Source location pointing at the source location entry chunk that
-  /// was reserved for the current macro instantiation.
+  /// was reserved for the current macro expansion.
   SourceLocation MacroExpansionStart;
   
-  /// \brief The offset of the macro instantiation in the
+  /// \brief The offset of the macro expansion in the
   /// "source location address space".
   unsigned MacroStartSLocOffset;
 
@@ -162,7 +162,7 @@
   /// HandleMicrosoftCommentPaste - In microsoft compatibility mode, /##/ pastes
   /// together to form a comment that comments out everything in the current
   /// macro, other active macros, and anything left on the current physical
-  /// source line of the instantiated buffer.  Handle this by returning the
+  /// source line of the expanded buffer.  Handle this by returning the
   /// first token on the next line.
   void HandleMicrosoftCommentPaste(Token &Tok);
 

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=135137&r1=135136&r2=135137&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Thu Jul 14 03:20:34 2011
@@ -23,7 +23,7 @@
 
 /// Create a TokenLexer for the specified macro with the specified actual
 /// arguments.  Note that this ctor takes ownership of the ActualArgs pointer.
-void TokenLexer::Init(Token &Tok, SourceLocation ILEnd, MacroArgs *Actuals) {
+void TokenLexer::Init(Token &Tok, SourceLocation ELEnd, MacroArgs *Actuals) {
   // If the client is reusing a TokenLexer, make sure to free any memory
   // associated with it.
   destroy();
@@ -32,8 +32,8 @@
   ActualArgs = Actuals;
   CurToken = 0;
 
-  InstantiateLocStart = Tok.getLocation();
-  InstantiateLocEnd = ILEnd;
+  ExpandLocStart = Tok.getLocation();
+  ExpandLocEnd = ELEnd;
   AtStartOfLine = Tok.isAtStartOfLine();
   HasLeadingSpace = Tok.hasLeadingSpace();
   Tokens = &*Macro->tokens_begin();
@@ -49,7 +49,7 @@
     assert(Tokens[0].getLocation().isValid());
     assert((Tokens[0].getLocation().isFileID() || Tokens[0].is(tok::comment)) &&
            "Macro defined in macro?");
-    assert(InstantiateLocStart.isValid());
+    assert(ExpandLocStart.isValid());
 
     // Reserve a source location entry chunk for the length of the macro
     // definition. Tokens that get lexed directly from the definition will
@@ -58,8 +58,8 @@
     SourceLocation macroStart = SM.getInstantiationLoc(Tokens[0].getLocation());
     MacroDefStartInfo = SM.getDecomposedLoc(macroStart);
     MacroExpansionStart = SM.createInstantiationLoc(macroStart,
-                                              InstantiateLocStart,
-                                              InstantiateLocEnd,
+                                              ExpandLocStart,
+                                              ExpandLocEnd,
                                               Macro->getDefinitionLength(SM));
   }
 
@@ -91,7 +91,7 @@
   DisableMacroExpansion = disableMacroExpansion;
   NumTokens = NumToks;
   CurToken = 0;
-  InstantiateLocStart = InstantiateLocEnd = SourceLocation();
+  ExpandLocStart = ExpandLocEnd = SourceLocation();
   AtStartOfLine = false;
   HasLeadingSpace = false;
   MacroExpansionStart = SourceLocation();
@@ -145,7 +145,7 @@
       assert(ArgNo != -1 && "Token following # is not an argument?");
 
       SourceLocation hashInstLoc;
-      if(InstantiateLocStart.isValid()) {
+      if(ExpandLocStart.isValid()) {
         hashInstLoc = getMacroExpansionLocation(CurTok.getLocation());
         assert(hashInstLoc.isValid() && "Expected '#' to come from definition");
       }
@@ -224,7 +224,7 @@
             Tok.setKind(tok::unknown);
         }
 
-        if(InstantiateLocStart.isValid()) {
+        if(ExpandLocStart.isValid()) {
           SourceLocation curInst =
               getMacroExpansionLocation(CurTok.getLocation());
           assert(curInst.isValid() &&
@@ -281,7 +281,7 @@
           Tok.setKind(tok::unknown);
       }
 
-      if (InstantiateLocStart.isValid()) {
+      if (ExpandLocStart.isValid()) {
         SourceLocation curInst =
             getMacroExpansionLocation(CurTok.getLocation());
         assert(curInst.isValid() &&
@@ -413,17 +413,17 @@
   // The token's current location indicate where the token was lexed from.  We
   // need this information to compute the spelling of the token, but any
   // diagnostics for the expanded token should appear as if they came from
-  // InstantiationLoc.  Pull this information together into a new SourceLocation
+  // ExpansionLoc.  Pull this information together into a new SourceLocation
   // that captures all of this.
-  if (InstantiateLocStart.isValid() &&   // Don't do this for token streams.
+  if (ExpandLocStart.isValid() &&   // Don't do this for token streams.
       // Check that the token's location was not already set properly.
       SM.isBeforeInSourceLocationOffset(Tok.getLocation(),
                                         MacroStartSLocOffset)) {
     SourceLocation instLoc;
     if (Tok.is(tok::comment)) {
       instLoc = SM.createInstantiationLoc(Tok.getLocation(),
-                                          InstantiateLocStart,
-                                          InstantiateLocEnd,
+                                          ExpandLocStart,
+                                          ExpandLocEnd,
                                           Tok.getLength());
     } else {
       instLoc = getMacroExpansionLocation(Tok.getLocation());
@@ -570,12 +570,12 @@
 
         // Do not emit the error when preprocessing assembler code.
         if (!PP.getLangOptions().AsmPreprocessor) {
-          // Explicitly convert the token location to have proper instantiation
+          // Explicitly convert the token location to have proper expansion
           // information so that the user knows where it came from.
           SourceManager &SM = PP.getSourceManager();
           SourceLocation Loc =
-            SM.createInstantiationLoc(PasteOpLoc, InstantiateLocStart,
-                                      InstantiateLocEnd, 2);
+            SM.createInstantiationLoc(PasteOpLoc, ExpandLocStart,
+                                      ExpandLocEnd, 2);
           // If we're in microsoft extensions mode, downgrade this from a hard
           // error to a warning that defaults to an error.  This allows
           // disabling it.
@@ -607,9 +607,9 @@
   // The token's current location indicate where the token was lexed from.  We
   // need this information to compute the spelling of the token, but any
   // diagnostics for the expanded token should appear as if the token was
-  // instantiated from the (##) operator. Pull this information together into
+  // expanded from the (##) operator. Pull this information together into
   // a new SourceLocation that captures all of this.
-  if (InstantiateLocStart.isValid()) {
+  if (ExpandLocStart.isValid()) {
     SourceManager &SM = PP.getSourceManager();
     SourceLocation pasteLocInst =
         getMacroExpansionLocation(PasteOpLoc);
@@ -652,7 +652,7 @@
 /// HandleMicrosoftCommentPaste - In microsoft compatibility mode, /##/ pastes
 /// together to form a comment that comments out everything in the current
 /// macro, other active macros, and anything left on the current physical
-/// source line of the instantiated buffer.  Handle this by returning the
+/// source line of the expanded buffer.  Handle this by returning the
 /// first token on the next line.
 void TokenLexer::HandleMicrosoftCommentPaste(Token &Tok) {
   // We 'comment out' the rest of this macro by just ignoring the rest of the
@@ -670,7 +670,7 @@
 /// definition, returns the appropriate source location pointing at the
 /// macro expansion source location entry.
 SourceLocation TokenLexer::getMacroExpansionLocation(SourceLocation loc) const {
-  assert(InstantiateLocStart.isValid() && MacroExpansionStart.isValid() &&
+  assert(ExpandLocStart.isValid() && MacroExpansionStart.isValid() &&
          "Not appropriate for token streams");
   assert(loc.isValid());
   





More information about the cfe-commits mailing list