================
@@ -469,11 +470,31 @@ Interpreter::Parse(llvm::StringRef Code) {
// printing could cause it.
getCompilerInstance()->getDiagnostics().setSeverity(
clang::diag::warn_unused_expr, diag::Severity::Ignored,
SourceLocation());
+ // Suppress [[nodiscard]] warnings during parsing since we don't know yet
+ // if the expression has a missing semicolon (value printed) or not.
+ // If the value is printed, it's considered "used" so no warning is needed.
+ getCompilerInstance()->getDiagnostics().setSeverity(
+ clang::diag::warn_unused_result, diag::Severity::Ignored,
+ SourceLocation());
llvm::Expected<TranslationUnitDecl *> TuOrErr = IncrParser->Parse(Code);
if (!TuOrErr)
return TuOrErr.takeError();
+ // After parsing, re-enable [[nodiscard]] warnings and diagnose for
----------------
vgvassilev wrote:
Can we trace what happens in clang when a declaration is used? The node must be
marked somehow so that the diagnostics don’t report it. It’d be probably better
to do the same for these expressions rather than suppressing the diagnostics.
https://github.com/llvm/llvm-project/pull/178661
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits