[all-commits] [llvm/llvm-project] 751f2f: Disable unique-object-duplication warning in templ...

Devon Loehr via All-commits all-commits at lists.llvm.org
Fri Feb 28 01:26:16 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 751f2fc8d5f465be5634b39adb8256a02f419984
      https://github.com/llvm/llvm-project/commit/751f2fc8d5f465be5634b39adb8256a02f419984
  Author: Devon Loehr <DKLoehr at users.noreply.github.com>
  Date:   2025-02-28 (Fri, 28 Feb 2025)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/SemaCXX/unique_object_duplication.h

  Log Message:
  -----------
  Disable unique-object-duplication warning in templates (#129120)

I've been trying to resolve instances of the unique-object-duplication
warning in chromium code. Unfortunately, I've found that practically
speaking, it's near-impossible to actually fix the problem when
templates are involved.

My understanding is that the warning is correct -- the variables it's
flagging are indeed duplicated and potentially causing bugs as a result.
The problem is that hiddenness is contagious: if a templated class or
variable depends on something hidden, then it itself must also be
hidden, even if the user explicitly marked it visible. In order to make
it actually visible, the user must manually figure out everything that
it depends on, mark them as visible, and do so recursively until all of
its ancestors are visible.

This process is extremely difficult and unergonomic, negating much of
the benefits of templates since now each new use requires additional
work. Furthermore, the process doesn't work if the user can't edit some
of the files, e.g. if they're in a third-party library.

Since a warning that can't practically be fixed isn't useful, this PR
disables the warning for _all_ templated code by inverting the check.
The warning remains active (and, in my experience, easily fixable) in
non-templated code.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list