[clang] [clang-tools-extra] [Clang] Implement CWG2813: Class member access with prvalues (PR #120223)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 17 04:33:09 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 0693b9e9ccdec5f09a3080b1bec73f5004a8dfa3 fb9570cbaa8ee6565b23f0183002b848d0e6f35d --extensions cpp,h -- clang-tools-extra/clangd/unittests/DumpASTTests.cpp clang/include/clang/Sema/Sema.h clang/lib/AST/Expr.cpp clang/lib/Sema/SemaExprMember.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaStmt.cpp clang/test/AST/ast-dump-for-range-lifetime.cpp clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp clang/test/CXX/drs/cwg28xx.cpp clang/test/CodeGenCXX/cxx2b-deducing-this.cpp clang/test/SemaCXX/cxx2b-deducing-this.cpp clang/test/SemaCXX/ms-property.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index cd09d748f0..6c32e17bf0 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10659,9 +10659,9 @@ public:
SourceLocation EndLoc);
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
- /// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is semantically
- /// a discarded-value expression, diagnose if any [[nodiscard]] value
- /// has been discarded
+ /// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is
+ /// semantically a discarded-value expression, diagnose if any [[nodiscard]]
+ /// value has been discarded
void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E);
/// DiagnoseUnusedExprResult - If the statement passed in is an expression
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 5c35f44e38..8f45a10ecc 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -230,8 +230,8 @@ namespace {
// Diagnoses unused expressions that call functions marked [[nodiscard]],
// [[gnu::warn_unused_result]] and similar.
-// Additionally, a DiagID can be provided to emit a warning in additional contexts
-// (such as for an unused LHS of a comma expression)
+// Additionally, a DiagID can be provided to emit a warning in additional
+// contexts (such as for an unused LHS of a comma expression)
void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
bool NoDiscardOnly = !DiagID.has_value();
@@ -332,8 +332,8 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
} else if (const auto *ILE = dyn_cast<InitListExpr>(E)) {
if (const TagDecl *TD = ILE->getType()->getAsTagDecl()) {
- if (DiagnoseNoDiscard(S, TD, TD->getAttr<WarnUnusedResultAttr>(), Loc,
- R1, R2, /*isCtor=*/false))
+ if (DiagnoseNoDiscard(S, TD, TD->getAttr<WarnUnusedResultAttr>(), Loc, R1,
+ R2, /*isCtor=*/false))
return;
}
} else if (ShouldSuppress)
@@ -347,7 +347,8 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
}
const ObjCMethodDecl *MD = ME->getMethodDecl();
if (MD) {
- if (DiagnoseNoDiscard(S, nullptr, MD->getAttr<WarnUnusedResultAttr>(), Loc, R1, R2,
+ if (DiagnoseNoDiscard(S, nullptr, MD->getAttr<WarnUnusedResultAttr>(),
+ Loc, R1, R2,
/*isCtor=*/false))
return;
}
@@ -403,7 +404,7 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
// Don't diagnose discarded left of dot in static class member access
// because its type is "used" to determine the class to access
- //if (DiagID == diag::warn_discarded_class_member_access)
+ // if (DiagID == diag::warn_discarded_class_member_access)
// return;
// Do not diagnose use of a comma operator in a SFINAE context because the
``````````
</details>
https://github.com/llvm/llvm-project/pull/120223
More information about the cfe-commits
mailing list