From: Sam McCall Date: Mon, 11 Nov 2019 18:00:44 +0000 (+0100) Subject: [clangd] Fix crash in DefineInline::prepare() X-Git-Tag: llvmorg-11-init~4528 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9213dfec4d8ce42d90507c25545564f4a0bbfb8;p=platform%2Fupstream%2Fllvm.git [clangd] Fix crash in DefineInline::prepare() --- diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp index f6966f6..6d0599e 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -388,7 +388,7 @@ public: if (!SelNode) return false; Source = getSelectedFunction(SelNode); - if (!Source || !Source->isThisDeclarationADefinition()) + if (!Source || !Source->hasBody()) return false; // Only the last level of template parameter locations are not kept in AST, // so if we are inlining a method that is in a templated class, there is no diff --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp b/clang-tools-extra/clangd/unittests/TweakTests.cpp index 5a6df2e..ab28088 100644 --- a/clang-tools-extra/clangd/unittests/TweakTests.cpp +++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp @@ -920,6 +920,9 @@ TEST_F(DefineInlineTest, TriggersOnFunctionDecl) { [[(void)(5+3); return;]] }]] + + // Definition with no body. + class Bar { Bar() = def^ault; } )cpp"); }