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) {
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();