forked from OSchip/llvm-project
[clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.
Differential Revision: https://reviews.llvm.org/D92579
This commit is contained in:
parent
a18d5e3e9f
commit
c282b7de5a
|
@ -274,6 +274,8 @@ bool AddUsing::prepare(const Selection &Inputs) {
|
||||||
} else if (auto *T = Node->ASTNode.get<TypeLoc>()) {
|
} else if (auto *T = Node->ASTNode.get<TypeLoc>()) {
|
||||||
if (auto E = T->getAs<ElaboratedTypeLoc>()) {
|
if (auto E = T->getAs<ElaboratedTypeLoc>()) {
|
||||||
QualifierToRemove = E.getQualifierLoc();
|
QualifierToRemove = E.getQualifierLoc();
|
||||||
|
if (!QualifierToRemove)
|
||||||
|
return false;
|
||||||
|
|
||||||
auto SpelledTokens =
|
auto SpelledTokens =
|
||||||
TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
|
TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
|
||||||
|
|
|
@ -2523,6 +2523,9 @@ public:
|
||||||
// Do not offer code action on typo-corrections.
|
// Do not offer code action on typo-corrections.
|
||||||
EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
|
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.
|
// Check that we do not trigger in header files.
|
||||||
FileName = "test.h";
|
FileName = "test.h";
|
||||||
ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
|
ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
|
||||||
|
|
Loading…
Reference in New Issue