[clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.

Differential Revision: https://reviews.llvm.org/D92579
This commit is contained in:
Adam Czachorowski 2020-12-03 18:09:36 +01:00
parent a18d5e3e9f
commit c282b7de5a
2 changed files with 5 additions and 0 deletions

View File

@ -274,6 +274,8 @@ bool AddUsing::prepare(const Selection &Inputs) {
} else if (auto *T = Node->ASTNode.get<TypeLoc>()) {
if (auto E = T->getAs<ElaboratedTypeLoc>()) {
QualifierToRemove = E.getQualifierLoc();
if (!QualifierToRemove)
return false;
auto SpelledTokens =
TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));

View File

@ -2523,6 +2523,9 @@ public:
// Do not offer code action on typo-corrections.
EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
// NestedNameSpecifier, but no namespace.
EXPECT_UNAVAILABLE(Header + "class Foo {}; class F^oo foo;");
// Check that we do not trigger in header files.
FileName = "test.h";
ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.