[PATCH] D92579: [clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.
Adam Czachorowski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 3 09:10:50 PST 2020
adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92579
Files:
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2523,6 +2523,9 @@
// 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.
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -274,6 +274,8 @@
} 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()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92579.309277.patch
Type: text/x-patch
Size: 1206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201203/425267af/attachment.bin>
More information about the cfe-commits
mailing list