[PATCH] D64914: Implement P1771
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 14:15:33 PDT 2019
aaron.ballman added inline comments.
================
Comment at: clang/lib/Sema/SemaStmt.cpp:296-301
+ if (A) {
+ StringRef Msg = A->getMessage();
+ if (!Msg.empty())
+ Diag(Loc, diag::warn_unused_constructor_msg) << A << Msg << R1 << R2;
+ else
+ Diag(Loc, diag::warn_unused_constructor) << A << R1 << R2;
----------------
We use this pattern in a handful of places. I wonder if we want to add a private function to `Sema` to handle this: `void DiagnoseNodiscard(const WarnUnusedResultAttr *A, SourceLocation Loc, bool IsConstructor);` (maybe it could return a partial diagnostic so we can optionally apply the source ranges to it as well?)
================
Comment at: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:91
+ operator ConvertTo();
+ [[nodiscard]] operator int();
+};
----------------
Can you add a test that adds a message to the `nodiscard` attribute written directly on a conversion operator?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64914/new/
https://reviews.llvm.org/D64914
More information about the cfe-commits
mailing list