[clang-tools-extra] b9213df - [clangd] Fix crash in DefineInline::prepare()

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 11 10:01:19 PST 2019


Author: Sam McCall
Date: 2019-11-11T19:01:06+01:00
New Revision: b9213dfec4d8ce42d90507c25545564f4a0bbfb8

URL: https://github.com/llvm/llvm-project/commit/b9213dfec4d8ce42d90507c25545564f4a0bbfb8
DIFF: https://github.com/llvm/llvm-project/commit/b9213dfec4d8ce42d90507c25545564f4a0bbfb8.diff

LOG: [clangd] Fix crash in DefineInline::prepare()

Added: 
    

Modified: 
    clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
    clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
index f6966f619ade..6d0599e8821c 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -388,7 +388,7 @@ class DefineInline : public Tweak {
     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 5a6df2e03e67..ab2808835832 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");
 }
 


        


More information about the cfe-commits mailing list