[clang-tools-extra] [clangd] DefineInline: only trigger on the declaration that has the body (PR #227534)

Aleksandr Platonov via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 01:57:04 PDT 2026


================
@@ -400,7 +400,7 @@ class DefineInline : public Tweak {
     if (!SelNode)
       return false;
     Source = getSelectedFunction(SelNode);
-    if (!Source || !Source->hasBody())
+    if (!Source || !Source->doesThisDeclarationHaveABody())
----------------
ArcsinX wrote:

I think in this assertion we need a clear message what we expect and why. I.e. we use `doesThisDeclarationHaveABody()` check and based on the result expect non-null function body. Possible cause guessing maybe not very suitable here, because in a future `doesThisDeclarationHaveABody()` there can be more cases when it can returns `true`.
So, maybe "Expected non-null body for declaration satisfying doesThisDeclarationHaveABody()" or "Function declaration with a body must have a body Stmt".

https://github.com/llvm/llvm-project/pull/227534


More information about the cfe-commits mailing list