[clang] [clang][bytecode][NFC] Use hasBody() instead of getBody() (PR #215718)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 21:49:09 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We either don't use the body at all, or only use it to convert it to an integer. Use `hasBody()` instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/215718.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+6-6)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index ece2e71408731..58ea91df742ea 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1122,8 +1122,8 @@ static bool diagnoseCallableDecl(InterpState &S, CodePtr OpPC,
<< DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
const FunctionDecl *Definition;
- const Stmt *Body = DiagDecl->getBody(Definition);
- if (Body && Definition)
+ bool HasBody = DiagDecl->hasBody(Definition);
+ if (HasBody && Definition)
S.Note(Definition->getLocation(), diag::note_declared_at);
else
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
@@ -1146,7 +1146,7 @@ static bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
const FunctionDecl *DiagDecl = F->getDecl();
const FunctionDecl *Definition = nullptr;
- DiagDecl->getBody(Definition);
+ DiagDecl->hasBody(Definition);
if (!Definition && S.checkingPotentialConstantExpression() &&
DiagDecl->isConstexpr()) {
@@ -1796,9 +1796,9 @@ bool CheckFunctionDecl(InterpState &S, CodePtr OpPC, const FunctionDecl *FD) {
return false;
const FunctionDecl *Definition = nullptr;
- const Stmt *Body = FD->getBody(Definition);
+ bool HasBody = FD->hasBody(Definition);
- if (Definition && Body &&
+ if (Definition && HasBody &&
(Definition->isConstexpr() || (S.Current->MSVCConstexprAllowed &&
Definition->hasAttr<MSConstexprAttr>())))
return true;
@@ -1853,7 +1853,7 @@ bool CheckBitCast(InterpState &S, CodePtr OpPC, const Type *TargetType,
static void compileFunction(InterpState &S, const Function *Func) {
const FunctionDecl *Definition;
- if (!Func->getDecl()->getBody(Definition))
+ if (!Func->getDecl()->hasBody(Definition))
return;
if (!Definition)
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/215718
More information about the cfe-commits
mailing list