[cfe-commits] r39860 - in /cfe/trunk: Lex/MacroExpander.cpp Lex/Preprocessor.cpp include/clang/Lex/MacroInfo.h

Chris Lattner sabre at nondot.org
Sat Jul 14 15:11:41 PDT 2007


Author: lattner
Date: Sat Jul 14 17:11:41 2007
New Revision: 39860

URL: http://llvm.org/viewvc/llvm-project?rev=39860&view=rev
Log:
expose an iterator interface to getReplacementTokens instead of the datastructure itself.


Modified:
    cfe/trunk/Lex/MacroExpander.cpp
    cfe/trunk/Lex/Preprocessor.cpp
    cfe/trunk/include/clang/Lex/MacroInfo.h

Modified: cfe/trunk/Lex/MacroExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/MacroExpander.cpp?rev=39860&r1=39859&r2=39860&view=diff

==============================================================================
--- cfe/trunk/Lex/MacroExpander.cpp (original)
+++ cfe/trunk/Lex/MacroExpander.cpp Sat Jul 14 17:11:41 2007
@@ -240,8 +240,8 @@
     InstantiateLoc(Tok.getLocation()),
     AtStartOfLine(Tok.isAtStartOfLine()),
     HasLeadingSpace(Tok.hasLeadingSpace()) {
-  MacroTokens = &Macro->getReplacementTokens()[0];
-  NumMacroTokens = Macro->getReplacementTokens().size();
+  MacroTokens = &*Macro->tokens_begin();
+  NumMacroTokens = Macro->tokens_end()-Macro->tokens_begin();
 
   // If this is a function-like macro, expand the arguments and change
   // MacroTokens to point to the expanded tokens.
@@ -275,7 +275,7 @@
 MacroExpander::~MacroExpander() {
   // If this was a function-like macro that actually uses its arguments, delete
   // the expanded tokens.
-  if (Macro && MacroTokens != &Macro->getReplacementTokens()[0])
+  if (Macro && MacroTokens != &*Macro->tokens_begin())
     delete [] MacroTokens;
   
   // MacroExpander owns its formal arguments.

Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=39860&r1=39859&r2=39860&view=diff

==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Sat Jul 14 17:11:41 2007
@@ -1729,7 +1729,7 @@
   // Error reading macro name?  If so, diagnostic already issued.
   if (MacroNameTok.getKind() == tok::eom)
     return;
-  
+
   // If we are supposed to keep comments in #defines, reenable comment saving
   // mode.
   CurLexer->KeepCommentMode = KeepMacroComments;
@@ -1833,6 +1833,7 @@
     }
   }
   
+  
   // Disable __VA_ARGS__ again.
   Ident__VA_ARGS__->setIsPoisoned(true);
 

Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=39860&r1=39859&r2=39860&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Sat Jul 14 17:11:41 2007
@@ -157,10 +157,10 @@
     return ReplacementTokens[Tok];
   }
   
-  const std::vector<LexerToken> &getReplacementTokens() const {
-    return ReplacementTokens;
-  }
-
+  typedef std::vector<LexerToken>::const_iterator tokens_iterator;
+  tokens_iterator tokens_begin() const { return ReplacementTokens.begin(); }
+  tokens_iterator tokens_end() const { return ReplacementTokens.end(); }
+  
   /// AddTokenToBody - Add the specified token to the replacement text for the
   /// macro.
   void AddTokenToBody(const LexerToken &Tok) {





More information about the cfe-commits mailing list