[clang] Enable -Wunique-object-duplication inside templated code (PR #125902)

Devon Loehr via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 11 07:23:28 PST 2025


================
@@ -3669,6 +3669,7 @@ class Sema final : public SemaBase {
   /// cause problems if the variable is mutable, its initialization is
   /// effectful, or its address is taken.
   bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl);
+  void DiagnoseDangerousUniqueObjectDuplication(const VarDecl *Dcl);
----------------
DKLoehr wrote:

I think it's meaningful because it's possible for objects to be duplicated "harmlessly", in which case we don't warn because the only problem is a little extra memory usage. This is the case for constants whose initializers don't have side effects.

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


More information about the cfe-commits mailing list