https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/215718

We either don't use the body at all, or only use it to convert it to an 
integer. Use `hasBody()` instead.

>From e07ded2d417fb478b51cc473df8c6b8b4a7975f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Wed, 12 Aug 2026 06:47:00 +0200
Subject: [PATCH] [clang][bytecode][NFC] Use hasBody() instead of getBody()

We either don't use the body at all, or only use it to convert it to an
integer. Use `hasBody()` instead.
---
 clang/lib/AST/ByteCode/Interp.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

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;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to