Author: Timm Baeder Date: 2026-08-12T08:01:37+02:00 New Revision: b196601866cd5fdc1a0c975aada756784723de66
URL: https://github.com/llvm/llvm-project/commit/b196601866cd5fdc1a0c975aada756784723de66 DIFF: https://github.com/llvm/llvm-project/commit/b196601866cd5fdc1a0c975aada756784723de66.diff LOG: [clang][bytecode][NFC] Use hasBody() instead of getBody() (#215718) We either don't use the body at all, or only use it to convert it to an integer. Use `hasBody()` instead. Added: Modified: clang/lib/AST/ByteCode/Interp.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 5f2884d09b35e..1f1db99973f2b 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1118,8 +1118,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); @@ -1142,7 +1142,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()) { @@ -1792,9 +1792,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; @@ -1849,7 +1849,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
