[clang] [clang-repl] Suppress [[nodiscard]] warnings for REPL printed express (PR #178661)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 17 05:27:47 PDT 2026
AaronBallman wrote:
Is this a more general problem than just suppressing nodiscard? How do we handle things like suppressing "expression result unused" in the absence of `[[nodiscard]]` (https://godbolt.org/z/66sfa18PE)
Instead of disabling the diagnostic or trying to muck with the "used" flag on the AST node, perhaps a different approach is for clang-repl to model print expressions as-if the user passed the value to a print function, so the value really is used? e.g., the user writes:
```
int x;
x
```
and clang-repl models that as if the user wrote:
```
int x;
type_safe_smart_and_awesome_repl_print(stdout, x);
```
(I am unfamiliar enough with the internals of clang-repl that this might also be a terrible idea.) That seems like it would solve a whole class of these kinds of issues.
https://github.com/llvm/llvm-project/pull/178661
More information about the cfe-commits
mailing list