[clang] Warn when unique objects might be duplicated in shared libraries (PR #117622)

Devon Loehr via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 17 07:12:24 PST 2025


================
@@ -13386,6 +13386,62 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc,
         .visit(QT, nullptr, false);
 }
 
+bool Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
+    const VarDecl *dcl) {
+  if (!dcl || !getLangOpts().CPlusPlus)
----------------
DKLoehr wrote:

C has different rules about this kind of thing, and we already have a [very similar check](https://github.com/llvm/llvm-project/blob/edf3a55bcecc8b0441a7a5fe6bda2023f86667a3/clang/include/clang/Basic/DiagnosticSemaKinds.td#L6133) for enforcing them.

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


More information about the cfe-commits mailing list