llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Implicit functions may still have a body. The !hasBody() check is enough. --- Full diff: https://github.com/llvm/llvm-project/pull/107992.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpFrame.cpp (+5-5) - (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+7) ``````````diff diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp index 6830a7b37f1da5..6c1e446458dc57 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.cpp +++ b/clang/lib/AST/ByteCode/InterpFrame.cpp @@ -210,28 +210,28 @@ Pointer InterpFrame::getParamPointer(unsigned Off) { SourceInfo InterpFrame::getSource(CodePtr PC) const { // Implicitly created functions don't have any code we could point at, // so return the call site. - if (Func && (!Func->hasBody() || Func->getDecl()->isImplicit()) && Caller) + if (Func && !Func->hasBody() && Caller) return Caller->getSource(RetPC); return S.getSource(Func, PC); } const Expr *InterpFrame::getExpr(CodePtr PC) const { - if (Func && (!Func->hasBody() || Func->getDecl()->isImplicit()) && Caller) - return Caller->getExpr(RetPC); + if (Func && !Func->hasBody() && Caller) + return Caller->getExpr(PC); return S.getExpr(Func, PC); } SourceLocation InterpFrame::getLocation(CodePtr PC) const { - if (Func && (!Func->hasBody() || Func->getDecl()->isImplicit()) && Caller) + if (Func && !Func->hasBody() && Caller) return Caller->getLocation(RetPC); return S.getLocation(Func, PC); } SourceRange InterpFrame::getRange(CodePtr PC) const { - if (Func && (!Func->hasBody() || Func->getDecl()->isImplicit()) && Caller) + if (Func && !Func->hasBody() && Caller) return Caller->getRange(RetPC); return S.getRange(Func, PC); diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 9c9ca23e0a6a69..9fd5eae67a21f6 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -968,3 +968,10 @@ namespace FunctionStart { static_assert(__builtin_function_start(a) == a, ""); // both-error {{not an integral constant expression}} \ // both-note {{comparison of addresses of literals has unspecified value}} } + +namespace BuiltinInImplicitCtor { + constexpr struct { + int a = __builtin_isnan(1.0); + } Foo; + static_assert(Foo.a == 0, ""); +} `````````` </details> https://github.com/llvm/llvm-project/pull/107992 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits