]> granicus.if.org Git - clang/commitdiff
expose an iterator interface to getReplacementTokens instead of the datastructure...
authorChris Lattner <sabre@nondot.org>
Sat, 14 Jul 2007 22:11:41 +0000 (22:11 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 14 Jul 2007 22:11:41 +0000 (22:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39860 91177308-0d34-0410-b5e6-96231b3b80d8

Lex/MacroExpander.cpp
Lex/Preprocessor.cpp
include/clang/Lex/MacroInfo.h

index a45efbd86e997f73b42834634f6adc48f0f95ef8..45d4611233d461973afccbc506a9f2a8e48ca486 100644 (file)
@@ -240,8 +240,8 @@ MacroExpander::MacroExpander(LexerToken &Tok, MacroArgs *Actuals,
     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(const LexerToken *TokArray, unsigned NumToks,
 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.
index 795230120d9e515431449308a7ae48eda1ece65f..073fda2011fe2a243fcb8e538ab796d7c865d646 100644 (file)
@@ -1729,7 +1729,7 @@ void Preprocessor::HandleDefineDirective(LexerToken &DefineTok,
   // 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 @@ void Preprocessor::HandleDefineDirective(LexerToken &DefineTok,
     }
   }
   
+  
   // Disable __VA_ARGS__ again.
   Ident__VA_ARGS__->setIsPoisoned(true);
 
index ea1a06d33e32ace8a3dbdf5ab47f1021d617f597..b7495bf548f2e3c1fe30a9c954dcaf01c2093e97 100644 (file)
@@ -157,10 +157,10 @@ public:
     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) {