[PING][PATCH] Refactoring, update MacroInfo interface so a for range can be used to iterate through the tokens
Daniel Marjamäki
Daniel.Marjamaki at evidente.se
Mon Apr 27 06:38:27 PDT 2015
Please review this refactoring.
http://reviews.llvm.org/D9079
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Mobile: +46 (0)709 12 42 62
E-mail: Daniel.Marjamaki at evidente.se
www.evidente.se
________________________________________
Från: Daniel Marjamäki [daniel.marjamaki at evidente.se]
Skickat: den 20 april 2015 13:06
Till: Daniel Marjamäki; alexfh at google.com
Cc: cfe-commits at cs.uiuc.edu
Ämne: Re: [PATCH] Refactoring, update MacroInfo interface so a for range can be used to iterate through the tokens
good comments. I have taken care of those.
http://reviews.llvm.org/D9079
Files:
include/clang/Lex/MacroInfo.h
lib/Frontend/PrintPreprocessedOutput.cpp
tools/extra/modularize/PreprocessorTracker.cpp
Index: include/clang/Lex/MacroInfo.h
===================================================================
--- include/clang/Lex/MacroInfo.h
+++ include/clang/Lex/MacroInfo.h
@@ -241,6 +241,7 @@
tokens_iterator tokens_begin() const { return ReplacementTokens.begin(); }
tokens_iterator tokens_end() const { return ReplacementTokens.end(); }
bool tokens_empty() const { return ReplacementTokens.empty(); }
+ const SmallVectorImpl<Token> &tokens() const { return ReplacementTokens; }
/// \brief Add the specified token to the replacement text for the macro.
void AddTokenToBody(const Token &Tok) {
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===================================================================
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -64,12 +64,11 @@
OS << ' ';
SmallString<128> SpellingBuffer;
- for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end();
- I != E; ++I) {
- if (I->hasLeadingSpace())
+ for (const Token &T : MI.tokens()) {
+ if (T.hasLeadingSpace())
OS << ' ';
- OS << PP.getSpelling(*I, SpellingBuffer);
+ OS << PP.getSpelling(T, SpellingBuffer);
}
}
Index: tools/extra/modularize/PreprocessorTracker.cpp
===================================================================
--- tools/extra/modularize/PreprocessorTracker.cpp
+++ tools/extra/modularize/PreprocessorTracker.cpp
@@ -405,14 +405,13 @@
const clang::MacroArgs *Args) {
std::string Expanded;
// Walk over the macro Tokens.
- typedef clang::MacroInfo::tokens_iterator Iter;
- for (Iter I = MI->tokens_begin(), E = MI->tokens_end(); I != E; ++I) {
- clang::IdentifierInfo *II = I->getIdentifierInfo();
+ for (const clang::Token &T : MI->tokens()) {
+ clang::IdentifierInfo *II = T.getIdentifierInfo();
int ArgNo = (II && Args ? MI->getArgumentNum(II) : -1);
if (ArgNo == -1) {
// This isn't an argument, just add it.
if (II == nullptr)
- Expanded += PP.getSpelling((*I)); // Not an identifier.
+ Expanded += PP.getSpelling(T); // Not an identifier.
else {
// Token is for an identifier.
std::string Name = II->getName().str();
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list