@@ -1392,49 +1392,37 @@ class TranslateASTVisitor final
13921392
13931393 // Check that we are only expanding a single macro call.
13941394 if (!Begin.isMacroID () || !End.isMacroID () ||
1395- Mgr.getImmediateMacroCallerLoc (Begin) != Mgr.getImmediateMacroCallerLoc (End))
1395+ Mgr.getImmediateMacroCallerLoc (Begin) != Mgr.getImmediateMacroCallerLoc (End)) {
13961396 return true ;
1397-
1398- if (Begin.isMacroID ()) {
1399- #if CLANG_VERSION_MAJOR < 7
1400- // getImmediateExpansionRange in LLVM<7 returns a
1401- // std::pair<SourceLocation, SourceLocation>, which we need to
1402- // translate to a CharSourceRange for Lexer::getSourceText
1403- auto LocPair = Mgr.getImmediateExpansionRange (Begin);
1404- auto ExpansionRange = CharSourceRange::getCharRange (LocPair.first , LocPair.second );
1405- #else // CLANG_VERSION_MAJOR >= 7
1406- auto ExpansionRange = Mgr.getImmediateExpansionRange (Begin);
1407- #endif
1408- curMacroExpansionSource =
1409- Lexer::getSourceText (ExpansionRange, Mgr, Context->getLangOpts ());
14101397 }
14111398
1399+ auto ExpansionRange = Mgr.getImmediateExpansionRange (Begin);
1400+ curMacroExpansionSource =
1401+ Lexer::getSourceText (ExpansionRange, Mgr, Context->getLangOpts ());
1402+
14121403 // The macro stack unwound by getImmediateMacroCallerLoc and friends
14131404 // starts with literal replacement and works it's way to the macro call
14141405 // that was replaced.
14151406 while (Begin.isMacroID ()) {
1416- #if CLANG_VERSION_MAJOR < 7
1417- auto ExpansionRange = Mgr.getImmediateExpansionRange (Begin);
1418- auto ExpansionBegin = ExpansionRange.first ;
1419- auto ExpansionEnd = ExpansionRange.second ;
1420- #else // CLANG_VERSION_MAJOR >= 7
14211407 auto ExpansionRange = Mgr.getImmediateExpansionRange (Begin).getAsRange ();
14221408 auto ExpansionBegin = ExpansionRange.getBegin ();
14231409 auto ExpansionEnd = ExpansionRange.getEnd ();
1424- #endif
14251410 StringRef name;
14261411 MacroInfo *mac = getMacroInfo (ExpansionBegin, name);
14271412
1428- if (!mac || mac->getNumTokens () == 0 )
1413+ if (!mac || mac->getNumTokens () == 0 ) {
14291414 return true ;
1415+ }
1416+
14301417 auto ReplacementBegin = mac->getReplacementToken (0 ).getLocation ();
14311418 auto ReplacementEnd = mac->getDefinitionEndLoc ();
14321419 // Verify that this expansion covers the entire macro replacement
14331420 // definition, i.e. E is not a subexpression of the macro
14341421 // replacement.
14351422 if (Mgr.getSpellingLoc (Begin) != ReplacementBegin ||
1436- Mgr.getSpellingLoc (End) != ReplacementEnd)
1423+ Mgr.getSpellingLoc (End) != ReplacementEnd) {
14371424 return true ;
1425+ }
14381426
14391427 Begin = ExpansionBegin;
14401428 End = ExpansionEnd;
@@ -1443,10 +1431,10 @@ class TranslateASTVisitor final
14431431 curMacroExpansionStack.push_back (mac);
14441432 }
14451433 }
1434+
14461435 return true ;
14471436 }
14481437
1449-
14501438 bool VisitVAArgExpr (VAArgExpr *E) {
14511439 std::vector<void *> childIds{E->getSubExpr ()};
14521440 encode_entry (E, TagVAArgExpr, childIds);
0 commit comments