From 89ec7234680d8aa7e5a2e2f405fb339c933a2a1d Mon Sep 17 00:00:00 2001 From: Daniel Marjamaki Date: Mon, 11 May 2015 08:26:25 +0000 Subject: [PATCH] Refactor MacroInfo so range for loops can be used to iterate its tokens. Differential Revision: http://reviews.llvm.org/D9079 llvm-svn: 236976 --- clang-tools-extra/modularize/PreprocessorTracker.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp index b5b21fb510cb..551bb3cea5bb 100644 --- a/clang-tools-extra/modularize/PreprocessorTracker.cpp +++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp @@ -405,14 +405,13 @@ static std::string getMacroExpandedString(clang::Preprocessor &PP, 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 auto &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();