Refactor MacroInfo so range for loops can be used to iterate its tokens.

Differential Revision: http://reviews.llvm.org/D9079

llvm-svn: 236976
This commit is contained in:
Daniel Marjamaki 2015-05-11 08:26:25 +00:00
parent ecb0e1bc60
commit 89ec723468
1 changed files with 3 additions and 4 deletions

View File

@ -405,14 +405,13 @@ static std::string getMacroExpandedString(clang::Preprocessor &PP,
const clang::MacroArgs *Args) { const clang::MacroArgs *Args) {
std::string Expanded; std::string Expanded;
// Walk over the macro Tokens. // Walk over the macro Tokens.
typedef clang::MacroInfo::tokens_iterator Iter; for (const auto &T : MI->tokens()) {
for (Iter I = MI->tokens_begin(), E = MI->tokens_end(); I != E; ++I) { clang::IdentifierInfo *II = T.getIdentifierInfo();
clang::IdentifierInfo *II = I->getIdentifierInfo();
int ArgNo = (II && Args ? MI->getArgumentNum(II) : -1); int ArgNo = (II && Args ? MI->getArgumentNum(II) : -1);
if (ArgNo == -1) { if (ArgNo == -1) {
// This isn't an argument, just add it. // This isn't an argument, just add it.
if (II == nullptr) if (II == nullptr)
Expanded += PP.getSpelling((*I)); // Not an identifier. Expanded += PP.getSpelling(T); // Not an identifier.
else { else {
// Token is for an identifier. // Token is for an identifier.
std::string Name = II->getName().str(); std::string Name = II->getName().str();