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