expose an iterator interface to getReplacementTokens instead of the datastructure itself.

llvm-svn: 39860
This commit is contained in:
Chris Lattner 2007-07-14 22:11:41 +00:00
parent a3834341c5
commit f40fe99118
3 changed files with 9 additions and 8 deletions

View 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.

View File

@ -1833,6 +1833,7 @@ void Preprocessor::HandleDefineDirective(LexerToken &DefineTok,
}
}
// Disable __VA_ARGS__ again.
Ident__VA_ARGS__->setIsPoisoned(true);

View File

@ -157,9 +157,9 @@ 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.