r236975 - Refactor MacroInfo so range for loops can be used to iterate its tokens.
Daniel Marjamaki
daniel.marjamaki at evidente.se
Mon May 11 01:25:54 PDT 2015
Author: danielmarjamaki
Date: Mon May 11 03:25:54 2015
New Revision: 236975
URL: http://llvm.org/viewvc/llvm-project?rev=236975&view=rev
Log:
Refactor MacroInfo so range for loops can be used to iterate its tokens.
Differential Revision: http://reviews.llvm.org/D9079
Modified:
cfe/trunk/include/clang/Lex/MacroInfo.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=236975&r1=236974&r2=236975&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Mon May 11 03:25:54 2015
@@ -245,6 +245,7 @@ public:
tokens_iterator tokens_begin() const { return ReplacementTokens.begin(); }
tokens_iterator tokens_end() const { return ReplacementTokens.end(); }
bool tokens_empty() const { return ReplacementTokens.empty(); }
+ ArrayRef<Token> tokens() const { return ReplacementTokens; }
/// \brief Add the specified token to the replacement text for the macro.
void AddTokenToBody(const Token &Tok) {
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=236975&r1=236974&r2=236975&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Mon May 11 03:25:54 2015
@@ -64,12 +64,11 @@ static void PrintMacroDefinition(const I
OS << ' ';
SmallString<128> SpellingBuffer;
- for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end();
- I != E; ++I) {
- if (I->hasLeadingSpace())
+ for (const auto &T : MI.tokens()) {
+ if (T.hasLeadingSpace())
OS << ' ';
- OS << PP.getSpelling(*I, SpellingBuffer);
+ OS << PP.getSpelling(T, SpellingBuffer);
}
}
More information about the cfe-commits
mailing list