Skip to content

Commit 9108fd0

Browse files
committed
anonymous namespace -> static
1 parent 3fe511a commit 9108fd0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clang/lib/Sema/SemaStmt.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@ static bool DiagnoseNoDiscard(Sema &S, const WarnUnusedResultAttr *A,
222222
return S.Diag(Loc, diag::warn_unused_result_msg) << A << Msg << R1 << R2;
223223
}
224224

225-
namespace {
226-
void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
225+
static void DiagnoseUnused(Sema &S, const Expr *E,
226+
std::optional<unsigned> DiagID) {
227+
// When called from Sema::DiagnoseUnusedExprResult, DiagID is a diagnostic for
228+
// where this expression is not used. When called from
229+
// Sema::DiagnoseDiscardedNodiscard, DiagID is std::nullopt and this function
230+
// will only diagnose [[nodiscard]], [[gnu::warn_unused_result]] and similar
227231
bool NoDiscardOnly = !DiagID.has_value();
228232

229233
// If we are in an unevaluated expression context, then there can be no unused
@@ -395,7 +399,6 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
395399
S.DiagIfReachable(Loc, llvm::ArrayRef<const Stmt *>(E),
396400
S.PDiag(*DiagID) << R1 << R2);
397401
}
398-
} // namespace
399402

400403
void Sema::DiagnoseDiscardedNodiscard(const Expr *E) {
401404
DiagnoseUnused(*this, E, std::nullopt);

0 commit comments

Comments
 (0)