Fix spell for clang < 7

This commit is contained in:
Fangrui Song 2018-07-16 09:49:32 -07:00
parent 134a09a255
commit d6ce5e6768

View File

@ -569,17 +569,20 @@ public:
const FileEntry *FE;
Range loc;
#if LLVM_VERSION_MAJOR < 7
CharSourceRange R;
if (SM.isMacroArgExpansion(Loc))
R = CharSourceRange::getTokenRange(Spell);
else {
auto P = SM.getExpansionRange(Loc);
loc = FromCharRange(SM, Ctx->getLangOpts(), SourceRange(P.first, P.second));
LocFID = SM.getFileID(P.first);
FE = SM.getFileEntryForID(LocFID);
R = CharSourceRange::getTokenRange(P.first, P.second);
}
#else
auto R = SM.isMacroArgExpansion(Loc) ? CharSourceRange::getTokenRange(Spell)
: SM.getExpansionRange(Loc);
#endif
loc = FromTokenRange(SM, Lang, R.getAsRange());
LocFID = SM.getFileID(R.getBegin());
FE = SM.getFileEntryForID(LocFID);
#endif
if (!FE)
return true;
IndexFile *db = param.ConsumeFile(*FE);