aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-14 22:11:41 +0000
committerChris Lattner <sabre@nondot.org>2007-07-14 22:11:41 +0000
commitc215bd659d8266a1d6b66ce231a63405a4c61daf (patch)
tree8691ff644071b1d3baf76493d963075719d8dab4
parentb5e240fa9e852b758032b28488a083c546cf6123 (diff)
expose an iterator interface to getReplacementTokens instead of the datastructure itself.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39860 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Lex/MacroExpander.cpp6
-rw-r--r--Lex/Preprocessor.cpp3
-rw-r--r--include/clang/Lex/MacroInfo.h8
3 files changed, 9 insertions, 8 deletions
diff --git a/Lex/MacroExpander.cpp b/Lex/MacroExpander.cpp
index a45efbd86e..45d4611233 100644
--- a/Lex/MacroExpander.cpp
+++ b/Lex/MacroExpander.cpp
@@ -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.
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp
index 795230120d..073fda2011 100644
--- a/Lex/Preprocessor.cpp
+++ b/Lex/Preprocessor.cpp
@@ -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);
diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h
index ea1a06d33e..b7495bf548 100644
--- a/include/clang/Lex/MacroInfo.h
+++ b/include/clang/Lex/MacroInfo.h
@@ -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) {