[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 7 23:28:42 PST 2023


================
@@ -270,6 +274,35 @@ namespace clang {
   };
 }
 
+bool clang::MayDefAffectABI(const Decl *D) {
+  if (auto *FD = dyn_cast<FunctionDecl>(D)) {
+    if (FD->isInlined() || FD->isConstexpr())
+      return true;
+
+    // Non-user-provided functions get emitted as weak definitions with every
+    // use, no matter whether they've been explicitly instantiated etc.
+    if (!FD->isUserProvided())
+      return true;
+
+    if (FD->isDependentContext())
+      return true;
+
+    if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+      return true;
+  }
+
+  if (auto *VD = dyn_cast<VarDecl>(D)) {
----------------
tbaederr wrote:

```suggestion
  if (const auto *VD = dyn_cast<VarDecl>(D)) {
```

https://github.com/llvm/llvm-project/pull/71622


More information about the cfe-commits mailing list