summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorCorentin Jabot <corentinjabot@gmail.com>2023-07-10 08:54:15 +0200
committerCorentin Jabot <corentinjabot@gmail.com>2023-07-24 18:15:38 +0200
commit8698262a4365bf22b5b0c96e77bfecd3dcf084a7 (patch)
tree78c01a94f51a758084d3d17c7709cad968a4d3c0 /clang/lib/CodeGen/CodeGenModule.cpp
parent331a54d670722f5ee6b64a25d1547df3679d6c51 (diff)
[Clang] Fix consteval propagation for aggregates and defaulted constructors
This patch does a few things: * Fix aggregate initialization. When an aggregate has an initializer that is immediate-escalating, the context in which it is used automatically becomes an immediate function. The wording does that by rpretending an aggregate initialization is itself an invocation which is not really how clang works, so my previous attempt was... wrong. * Fix initialization of defaulted constructors with immediate escalating default member initializers. The wording was silent about that case and I did not handled it fully https://cplusplus.github.io/CWG/issues/2760.html * Fix diagnostics In some cases clang would produce additional and unhelpful diagnostics by listing the invalid references to consteval function that appear in immediate escalating functions Fixes https://github.com/llvm/llvm-project/issues/63742 Reviewed By: aaron.ballman, #clang-language-wg, Fznamznon Differential Revision: https://reviews.llvm.org/D155175
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index e2beb77d196f..07a9dec12f6f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4438,13 +4438,10 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
/// GetAddrOfFunction - Return the address of the given function. If Ty is
/// non-null, then this function will use the specified type if it has to
/// create it (this occurs when we see a definition of the function).
-llvm::Constant *CodeGenModule::GetAddrOfFunction(GlobalDecl GD,
- llvm::Type *Ty,
- bool ForVTable,
- bool DontDefer,
- ForDefinition_t IsForDefinition) {
- assert(!cast<FunctionDecl>(GD.getDecl())->isImmediateFunction() &&
- "an immediate function should never be emitted");
+llvm::Constant *
+CodeGenModule::GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty, bool ForVTable,
+ bool DontDefer,
+ ForDefinition_t IsForDefinition) {
// If there was no specific requested type, just convert it now.
if (!Ty) {
const auto *FD = cast<FunctionDecl>(GD.getDecl());