From d6ce5e67682d6bba45ea74807897de7fde950a14 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 16 Jul 2018 09:49:32 -0700 Subject: [PATCH] Fix spell for clang < 7 --- src/indexer.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 126da193..14bf3123 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -569,17 +569,20 @@ public: const FileEntry *FE; Range loc; #if LLVM_VERSION_MAJOR < 7 - auto P = SM.getExpansionRange(Loc); - loc = FromCharRange(SM, Ctx->getLangOpts(), SourceRange(P.first, P.second)); - LocFID = SM.getFileID(P.first); - FE = SM.getFileEntryForID(LocFID); + CharSourceRange R; + if (SM.isMacroArgExpansion(Loc)) + R = CharSourceRange::getTokenRange(Spell); + else { + auto P = SM.getExpansionRange(Loc); + 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);