================
@@ -21504,6 +21504,40 @@ void Sema::ActOnPragmaWeakAlias(IdentifierInfo* Name,
   }
 }
 
+/// Whether the definition \p FD is only handed to the ASTConsumer, and thus to
+/// CodeGen, once it is used, so that it is never emitted unless it is used.
+static bool isEmittedOnlyIfUsed(const FunctionDecl *FD) {
+  // Lambda call operators are defined by their lambda expressions, which are
+  // not top-level declarations. Implicit functions and functions defaulted on
+  // their first declaration are defined when they are used.
+  return isLambdaMethod(FD) || FD->isImplicit() ||
+         FD->getCanonicalDecl()->isDefaulted();
+}
+
+/// Whether CodeGen emits \p FD regardless of whether it is used.
+static bool isEmittedRegardlessOfUses(const Sema &S, const FunctionDecl *FD,
+                                      bool Final) {
+  const FunctionDecl *Def = FD->getDefinition();
+  if (!Def || Def->hasSkippedBody())
+    return false;
+  // Immediate functions are never emitted. Whether an immediate-escalating
+  // function is immediate is only known once its body is complete, so leave
+  // that to the check at the end of the translation unit.
+  const LangOptions &LangOpts = S.getLangOpts();
+  if (Def->isImmediateFunction() ||
+      (!Final && LangOpts.CPlusPlus20 && Def->isImmediateEscalating()))
----------------
steffenlarsen wrote:

We do. Even though immediate-escalating functions only really matter for C++20, 
`isImmediateEscalating` is C++-version agnostic and will report `true` for 
cases in pre-C++20 code, potentially causing this to not consider it as emitted.

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

Reply via email to