diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp --- a/clang-tools-extra/clangd/Selection.cpp +++ b/clang-tools-extra/clangd/Selection.cpp @@ -369,7 +369,8 @@ // } // Selecting "++x" or "x" will do the right thing. auto Range = toHalfOpenFileRange(SM, LangOpts, S); - assert(Range && "We should be able to get the File Range"); + if(!Range) + return SelectionTree::Unselected; dlog("{1}claimRange: {0}", Range->printToString(SM), indent()); auto B = SM.getDecomposedLoc(Range->getBegin()); auto E = SM.getDecomposedLoc(Range->getEnd()); diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp --- a/clang-tools-extra/clangd/SourceCode.cpp +++ b/clang-tools-extra/clangd/SourceCode.cpp @@ -311,8 +311,11 @@ const LangOptions &LangOpts) { SourceRange FileRange = Loc; while (!FileRange.getBegin().isFileID()) { - assert(!FileRange.getEnd().isFileID() && - "Both Begin and End should be MacroIDs."); + // FIXME: Investigate when this assert fails. Added a hack until then. + // assert(!FileRange.getEnd().isFileID() && + // "Both Begin and End should be MacroIDs."); + if(FileRange.getEnd().isFileID()) + return SourceRange(); if (SM.isMacroArgExpansion(FileRange.getBegin())) { FileRange.setBegin(SM.getImmediateSpellingLoc(FileRange.getBegin())); FileRange.setEnd(SM.getImmediateSpellingLoc(FileRange.getEnd()));