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

2024-11-25 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr created https://github.com/llvm/llvm-project/pull/117622 When a hidden object is built into multiple shared libraries, each instance of the library will get its own copy. If the object was supposed to be globally unique (e.g. a global variable or static data member),

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

2024-12-02 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From d944b2fde573a4fb352400ce3425121265b02685 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/2] Warn when unique objects might be duplicated in shared librar

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

2024-12-02 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From d944b2fde573a4fb352400ce3425121265b02685 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH] Warn when unique objects might be duplicated in shared libraries

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

2024-12-04 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From ba531f3dce1b992dad191e5a9f724ebdc6750d6c Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH] Warn when unique objects might be duplicated in shared libraries

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

2024-12-04 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Because this warning keeps firing in many different places, including in third-party libraries, I've disabled it by default until I can go through and fix all the instances. I think this provides a cleaner separation of concerns, so that this PR isn't clogged up with various hou

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

2024-12-09 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Ping https://github.com/llvm/llvm-project/pull/117622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-01-06 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Ping https://github.com/llvm/llvm-project/pull/117622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-02-03 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Thanks @zmodem for merging (and also reverting). Follow-up PR with the fix is #125526. https://github.com/llvm/llvm-project/pull/117622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

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

2025-02-03 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/125526 >From 486c3297f1a316a103c6583daf732af2d00d0b96 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/6] Warn when unique objects might be duplicated in shared librar

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

2025-02-03 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr created https://github.com/llvm/llvm-project/pull/125526 This is attempt 2 to merge this, the first one is #117622. This properly disables the tests when building for playstation, since the warning is disabled there. When a hidden object is built into multiple share

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

2025-02-11 Thread Devon Loehr via cfe-commits
@@ -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 DiagnoseDangerousUni

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

2025-02-11 Thread Devon Loehr via cfe-commits
@@ -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 DiagnoseDangerousUni

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

2025-02-11 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/125902 >From d95344cf393bcf0a8580e81f4848f5f72c67a652 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Tue, 4 Feb 2025 16:47:01 + Subject: [PATCH 1/5] Move into separate function, call in CheckCompleteVariableDecl

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

2025-02-11 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/125902 >From d95344cf393bcf0a8580e81f4848f5f72c67a652 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Tue, 4 Feb 2025 16:47:01 + Subject: [PATCH 1/4] Move into separate function, call in CheckCompleteVariableDecl

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

2025-02-11 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Thanks for the review! https://github.com/llvm/llvm-project/pull/125902 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-01-30 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 798b3f21593499194487c9877b8f4a3d9e44bb6e Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/5] Warn when unique objects might be duplicated in shared librar

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

2025-01-30 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Addressed feedback, responded where appropriate. I've also done some digging into how the warning should work on Windows: it seems like it'll be very straightforward (just replace "has hidden visibility" with "doesn't have a dll import/export attribute"), but I'll leave that for

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

2025-01-30 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 798b3f21593499194487c9877b8f4a3d9e44bb6e Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/4] Warn when unique objects might be duplicated in shared librar

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

2025-01-30 Thread Devon Loehr via cfe-commits
@@ -6153,6 +6153,15 @@ def warn_static_local_in_extern_inline : Warning< def note_convert_inline_to_static : Note< "use 'static' to give inline function %0 internal linkage">; +def warn_possible_object_duplication_mutable : Warning< + "%0 is mutable, has hidden visibility,

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

2025-01-30 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 798b3f21593499194487c9877b8f4a3d9e44bb6e Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/5] Warn when unique objects might be duplicated in shared librar

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

2025-01-30 Thread Devon Loehr via cfe-commits
@@ -13374,6 +13374,62 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc, .visit(QT, nullptr, false); } +bool Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated( +const VarDecl *Dcl) { + if (!Dcl || !getLangOpts().CPlusPlus)

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

2025-01-24 Thread Devon Loehr via cfe-commits
DKLoehr wrote: I've now added documentation for this warning explaining what it means and how to resolve it. I also added a release note mentioning its existence. https://github.com/llvm/llvm-project/pull/117622 ___ cfe-commits mailing list cfe-commit

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

2025-01-24 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 5ef8b8f3b84133ac7501331bf9b86b0b2f8b9ed9 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/3] Warn when unique objects might be duplicated in shared librar

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

2025-01-24 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 5ef8b8f3b84133ac7501331bf9b86b0b2f8b9ed9 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/2] Warn when unique objects might be duplicated in shared librar

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

2025-01-27 Thread Devon Loehr via cfe-commits
DKLoehr wrote: > Can you share a few of the examples where it triggers, to get a feel for what > this looks like on the LLVM code? There's a text file linked in the initial description ([here](https://github.com/user-attachments/files/18563888/clang-warnings.txt), for convenience) that summar

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

2025-01-29 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 798b3f21593499194487c9877b8f4a3d9e44bb6e Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/4] Warn when unique objects might be duplicated in shared librar

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

2025-01-29 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,187 @@ +/** + * When building shared libraries, hidden objects which are defined in header + * files will be duplicated, with one copy in each shared library. If the object + * was meant to be globally unique (one copy per program), this can cause very + * subtle bugs.

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

2025-01-29 Thread Devon Loehr via cfe-commits
@@ -13374,6 +13374,62 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc, .visit(QT, nullptr, false); } +bool Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated( +const VarDecl *Dcl) { + if (!Dcl || !getLangOpts().CPlusPlus)

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

2025-01-29 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,187 @@ +/** + * When building shared libraries, hidden objects which are defined in header + * files will be duplicated, with one copy in each shared library. If the object + * was meant to be globally unique (one copy per program), this can cause very + * subtle bugs.

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

2025-01-29 Thread Devon Loehr via cfe-commits
@@ -6153,6 +6153,15 @@ def warn_static_local_in_extern_inline : Warning< def note_convert_inline_to_static : Note< "use 'static' to give inline function %0 internal linkage">; +def warn_possible_object_duplication_mutable : Warning< + "%0 is mutable, has hidden visibility,

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

2025-01-29 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,187 @@ +/** + * When building shared libraries, hidden objects which are defined in header + * files will be duplicated, with one copy in each shared library. If the object + * was meant to be globally unique (one copy per program), this can cause very + * subtle bugs.

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

2025-01-29 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr edited https://github.com/llvm/llvm-project/pull/117622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-01-29 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,187 @@ +/** + * When building shared libraries, hidden objects which are defined in header + * files will be duplicated, with one copy in each shared library. If the object + * was meant to be globally unique (one copy per program), this can cause very + * subtle bugs.

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

2025-01-17 Thread Devon Loehr via cfe-commits
@@ -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)

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

2025-01-17 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 5ef8b8f3b84133ac7501331bf9b86b0b2f8b9ed9 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/6] Warn when unique objects might be duplicated in shared librar

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

2025-01-17 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/117622 >From 5ef8b8f3b84133ac7501331bf9b86b0b2f8b9ed9 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 21 Nov 2024 19:29:00 + Subject: [PATCH 1/2] Warn when unique objects might be duplicated in shared librar

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

2025-01-17 Thread Devon Loehr via cfe-commits
DKLoehr wrote: @zmodem Thanks for the review! I've addressed the code comments. To your questions: > What about code that's not going into a shared library? My impression is that you wouldn't mark things as having hidden visibility if they're not going to a shared library at least some of the

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

2025-01-17 Thread Devon Loehr via cfe-commits
DKLoehr wrote: If a review was requested from you and this code isn't related, apologies: For some reason attempting to rebase onto the current state of the repo ended up including a bunch of random extra commits that aren't related, and that resulted in a bunch of people automatically being a

[clang] Remove xbegin and _xend (PR #126952)

2025-02-12 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr created https://github.com/llvm/llvm-project/pull/126952 `intrin.h` contains declarations for both `xbegin` and `_xend`, but they should already be included transitively from `rtmintrin.h` via `immintrin.h` and/or `x86intrin.h`. Having them in both places causes prob

[clang] Remove xbegin and _xend (PR #126952)

2025-02-13 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/126952 >From 748451908cc46416dab8ec427e8df656e61d7d94 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Wed, 12 Feb 2025 18:17:05 + Subject: [PATCH 1/2] Remove xbegin and _xend --- clang/lib/Headers/intrin.h | 2 -

[clang] Remove xbegin and _xend (PR #126952)

2025-02-13 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Added a test based on the linked bug. I couldn't get it to reproduce in anything that seemed to fit in the existing file, so I made a new one. https://github.com/llvm/llvm-project/pull/126952 ___ cfe-commits mailing list cfe-commits@lis

[clang] Remove xbegin and _xend (PR #126952)

2025-02-13 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/126952 >From 01e40e4d8b3cc2068aa5a022c3acae246b6ac771 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Wed, 12 Feb 2025 18:17:05 + Subject: [PATCH 1/2] Remove xbegin and _xend --- clang/lib/Headers/intrin.h | 2 -

[clang] Check for mutability better (PR #127843)

2025-02-21 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/127843 >From 7a919e29b221f1070c420e263760b7071dc01da8 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 20 Feb 2025 15:19:13 + Subject: [PATCH 1/3] Implement mutable check in Sema --- clang/lib/Sema/SemaDecl.

[clang] Remove xbegin and _xend (PR #126952)

2025-02-21 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Just checking in, this was approved a few days ago but hasn't been merged yet. https://github.com/llvm/llvm-project/pull/126952 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] Check for mutability better (PR #127843)

2025-02-21 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Good call, changed. https://github.com/llvm/llvm-project/pull/127843 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Disable unique-object-duplication warning in templates (PR #129120)

2025-02-27 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr created https://github.com/llvm/llvm-project/pull/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 templa

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-13 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr created https://github.com/llvm/llvm-project/pull/131188 There's never any point to adding a `virtual` specifier to methods in a `final` class, since the class can't be subclassed. This adds a warning when we notice this happening, as suggested in #131108. We don't

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-13 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr edited https://github.com/llvm/llvm-project/pull/131188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = defau

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-15 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = default; // ex

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-15 Thread Devon Loehr via cfe-commits
@@ -2706,6 +2706,9 @@ def warn_final_dtor_non_final_class : Warning< InGroup; def note_final_dtor_non_final_class_silence : Note< "mark %0 as '%select{final|sealed}1' to silence this warning">; +def warn_unnecessary_virtual_specifier : Warning< + "virtual method %0 is insi

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/131188 >From fbd474fb5ae3adeaf1644a4d44e916e4d7c66395 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 13 Mar 2025 17:34:27 + Subject: [PATCH 1/4] Initial warning commit --- clang/include/clang/Basic/Diagnos

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = default; // ex

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = default; // ex

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-15 Thread Devon Loehr via cfe-commits
DKLoehr wrote: @zmodem Would you take a look? What do you think about implementing the suggestion about checking if virtual methods actually get overridden or not? https://github.com/llvm/llvm-project/pull/131188 ___ cfe-commits mailing list cfe-commi

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/131188 >From fbd474fb5ae3adeaf1644a4d44e916e4d7c66395 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 13 Mar 2025 17:34:27 + Subject: [PATCH 1/5] Initial warning commit --- clang/include/clang/Basic/Diagnos

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = default; // ex

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-14 Thread Devon Loehr via cfe-commits
@@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = defau

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-15 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Changed to not warn on `virtual...override`. I'm inclined to agree that it doesn't seem worth the effort to extend this to things that aren't actually overridden in practice. https://github.com/llvm/llvm-project/pull/131188 ___ cfe-com

[clang] Warn about virtual methods in `final` classes (PR #131188)

2025-03-15 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/131188 >From fbd474fb5ae3adeaf1644a4d44e916e4d7c66395 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 13 Mar 2025 17:34:27 + Subject: [PATCH 1/6] Initial warning commit --- clang/include/clang/Basic/Diagnos

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-28 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/133265 >From 792e1f3d062415134b8dfc4e8ed52f769f3e01f8 Mon Sep 17 00:00:00 2001 From: Devon Loehr Date: Thu, 27 Mar 2025 14:59:44 + Subject: [PATCH 1/4] Enable by default --- clang/include/clang/Basic/DiagnosticGr

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-28 Thread Devon Loehr via cfe-commits
@@ -689,7 +689,7 @@ if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" ) endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" ) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - append("-Werror=unguarded-availability-new" CMAKE_C_FL

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-27 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Ah, missed that, sorry. It seems there hasn't been a release since the warning was added, and the existing release note seems to still apply: https://github.com/llvm/llvm-project/blob/8bdcd0a96e65557c8c3bf506d186c49002db6463/clang/docs/ReleaseNotes.rst?plain=1#L291 https://githu

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-27 Thread Devon Loehr via cfe-commits
DKLoehr wrote: @zmodem Do you mind taking a look? https://github.com/llvm/llvm-project/pull/133265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-27 Thread Devon Loehr via cfe-commits
DKLoehr wrote: Ach, I was so focused on making the build work that I forgot to run tests... Fixed now, either by disabling the warning or adding it as expected, as seemed appropriate. https://github.com/llvm/llvm-project/pull/133265 ___ cfe-commits ma

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-27 Thread Devon Loehr via cfe-commits
https://github.com/DKLoehr created https://github.com/llvm/llvm-project/pull/133265 This turns on the unnecessary-virtual-specifier warning in genera, but disables it when building LLVM. It also tweaks the warning description to be slightly more accurate. Background: I've been working on clea

[clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-04-07 Thread Devon Loehr via cfe-commits
DKLoehr wrote: We're also seeing `class member cannot be redeclared` errors when trying to build chromium: ``` In file included from ../../components/system_cpu/cpu_probe.cc:16: In file included from ../../components/system_cpu/cpu_probe_linux.h:14: ../../base/threading/sequence_bound.h:281:8: e

[clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-04-07 Thread Devon Loehr via cfe-commits
DKLoehr wrote: I ended up with the following reproducer: ``` template struct S { template using Arg = T::template Arg; void f(Arg); void f(Arg); }; ``` Running this with `clang++ repro.cc -fsyntax-only -std=c++20` yields ``` repro.cc:5:8: error: class member cannot be redeclared