[clangd] Fix crash in DefineInline::prepare()
authorSam McCall <sam.mccall@gmail.com>
Mon, 11 Nov 2019 18:00:44 +0000 (19:00 +0100)
committerSam McCall <sam.mccall@gmail.com>
Mon, 11 Nov 2019 18:01:06 +0000 (19:01 +0100)
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

index f6966f6..6d0599e 100644 (file)
@@ -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
index 5a6df2e..ab28088 100644 (file)
@@ -920,6 +920,9 @@ TEST_F(DefineInlineTest, TriggersOnFunctionDecl) {
     [[(void)(5+3);
     return;]]
   }]]
+
+  // Definition with no body.
+  class Bar { Bar() = def^ault; }
   )cpp");
 }