forked from OSchip/llvm-project
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:
parent
ecb0e1bc60
commit
89ec723468
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue