Skip to content

Commit fb9570c

Browse files
committed
Apply my own review feedback
1 parent 6b34aa8 commit fb9570c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10659,10 +10659,10 @@ class Sema final : public SemaBase {
1065910659
SourceLocation EndLoc);
1066010660
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
1066110661

10662-
/// DiagnoseDiscardedNodiscard - Given an expression that is semantically
10662+
/// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is semantically
1066310663
/// a discarded-value expression, diagnose if any [[nodiscard]] value
1066410664
/// has been discarded
10665-
void DiagnoseDiscardedNodiscard(const Expr *E);
10665+
void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E);
1066610666

1066710667
/// DiagnoseUnusedExprResult - If the statement passed in is an expression
1066810668
/// whose result is unused, warn.

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
11331133
if (Converted.isInvalid())
11341134
return true;
11351135
BaseExpr = Converted.get();
1136-
DiagnoseDiscardedNodiscard(BaseExpr);
1136+
DiagnoseDiscardedExprMarkedNodiscard(BaseExpr);
11371137
return false;
11381138
};
11391139
auto MakeGLValue = [&] {

clang/lib/Sema/SemaStmt.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ static bool DiagnoseNoDiscard(Sema &S, const NamedDecl *OffendingDecl,
227227
}
228228

229229
namespace {
230+
231+
// Diagnoses unused expressions that call functions marked [[nodiscard]],
232+
// [[gnu::warn_unused_result]] and similar.
233+
// Additionally, a DiagID can be provided to emit a warning in additional contexts
234+
// (such as for an unused LHS of a comma expression)
230235
void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
231236
bool NoDiscardOnly = !DiagID.has_value();
232237

@@ -412,7 +417,7 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
412417
}
413418
} // namespace
414419

415-
void Sema::DiagnoseDiscardedNodiscard(const Expr *E) {
420+
void Sema::DiagnoseDiscardedExprMarkedNodiscard(const Expr *E) {
416421
DiagnoseUnused(*this, E, std::nullopt);
417422
}
418423

0 commit comments

Comments
 (0)