================
@@ -21537,6 +21537,14 @@ Sema::FunctionEmissionStatus
Sema::getEmissionStatus(const FunctionDecl *FD,
if (IsEmittedForExternalSymbol())
return FunctionEmissionStatus::Emitted;
+
+ // CodeGen also emits a function regardless of its uses if it is forced to,
+ // so its deferred diagnostics must not wait for a use.
+ const FunctionDecl *Def = FD->getDefinition();
+ if (Def && !Def->hasSkippedBody() &&
+ (LangOpts.EmitAllDecls || Def->hasAttr<UsedAttr>() ||
+ Def->hasAttr<ConstructorAttr>() || Def->hasAttr<DestructorAttr>()))
----------------
steffenlarsen wrote:
Ah, good point. I did another pass over all these paths and found a handful
other cases that will not emit:
1. Function that become immediate by calling `consteval` (C++20)
2. Lambdas
3. Implicit host/device template functions
4. Implicit functions and functions defaulted on their first declaration
5. `available_externally` definitions
I also found the helper function `DeclMustBeEmitted` to simplify the original
check a little.
https://github.com/llvm/llvm-project/pull/229008
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits