================
@@ -400,7 +400,7 @@ class DefineInline : public Tweak {
if (!SelNode)
return false;
Source = getSelectedFunction(SelNode);
- if (!Source || !Source->hasBody())
+ if (!Source || !Source->doesThisDeclarationHaveABody())
----------------
Mrgoudan wrote:
I don't think a late-parsed `Source` is possible here.
The flag is only set by the parser under `LangOpts.DelayedTemplateParsing`
([Parser.cpp#L1252](https://github.com/llvm/llvm-project/blob/58b102609a9d08fbadb9c3fa1dd88bba2cf7f711/clang/lib/Parse/Parser.cpp#L1252),[ParseCXXInlineMethods.cpp#L144](https://github.com/llvm/llvm-project/blob/58b102609a9d08fbadb9c3fa1dd88bba2cf7f711/clang/lib/Parse/ParseCXXInlineMethods.cpp#L144)),
and clangd forces that option off for the main file
`CI->getLangOpts().DelayedTemplateParsing = false;
`([ParsedAST.cpp#L463](https://github.com/llvm/llvm-project/blob/58b102609a9d08fbadb9c3fa1dd88bba2cf7f711/clang-tools-extra/clangd/ParsedAST.cpp#L463))`
`Source` is the selected decl, so it is always in the main file; only the
preamble can still be late-parsed, and a preamble decl can only be `Target`,
whose body we never read.
Also, `hasBody()` wouldn't help with this: it is just
`doesThisDeclarationHaveABody()` over the redecl chain
([Decl.cpp#L3186](https://github.com/llvm/llvm-project/blob/58b102609a9d08fbadb9c3fa1dd88bba2cf7f711/clang/lib/AST/Decl.cpp#L3186)),
so the original code had the same exposure.
https://github.com/llvm/llvm-project/pull/227534
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits