]> granicus.if.org Git - clang/commitdiff
Refactor MacroInfo so range for loops can be used to iterate its tokens.
authorDaniel Marjamaki <daniel.marjamaki@evidente.se>
Mon, 11 May 2015 08:25:54 +0000 (08:25 +0000)
committerDaniel Marjamaki <daniel.marjamaki@evidente.se>
Mon, 11 May 2015 08:25:54 +0000 (08:25 +0000)
Differential Revision: http://reviews.llvm.org/D9079

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236975 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/MacroInfo.h
lib/Frontend/PrintPreprocessedOutput.cpp

index fdd422f160ca7bbde4d0d07fe7d408b6df0f3fa1..81d075cb000c3e743bc36a1c521abd21102947ed 100644 (file)
@@ -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) {
index 8ca36489ee465e730db11a5c4a614c33661b4a67..037a6a525e2fce5611d237e01e6a518135932a45 100644 (file)
@@ -64,12 +64,11 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
     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);
   }
 }