[PATCH] D133177: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is not deleted before attempting to call DefineDefaultedFunction(...)

2022-09-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f6b3199d33c: [Clang] Fix lambda 
CheckForDefaultedFunction(...) so that it checks theā€¦ (authored by shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133177/new/

https://reviews.llvm.org/D133177

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function 
is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a 
non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base 
class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133177: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is not deleted before attempting to call DefineDefaultedFunction(...)

2022-09-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 457736.
shafik added a comment.

- Add Release note.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133177/new/

https://reviews.llvm.org/D133177

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function 
is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a 
non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base 
class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133177: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is not deleted before attempting to call DefineDefaultedFunction(...)

2022-09-01 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
shafik requested review of this revision.

I discovered this additional bug at the end of working on D132906 


In `Sema::CheckCompletedCXXClass(...) ` uses a lambda 
`CheckForDefaultedFunction` to verify each `CXXMethodDecl` holds to the 
expected invariants before passing them on to `CheckForDefaultedFunction`.

It is currently missing a check that it is not deleted, this adds that check 
and a test that crashed without this check.

This fixes: https://github.com/llvm/llvm-project/issues/57516


https://reviews.llvm.org/D133177

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function 
is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a 
non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base 
class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits