This is an archive of the discontinued LLVM Phabricator instance.

[clang][Driver] Don't overwrite `DiagnosticsEngine::IgnoreAllWarnings`, rely on `DiagnosticOptions::IgnoreWarnings` value.
ClosedPublic

Authored by vsapsai on Nov 29 2022, 6:08 PM.

Details

Summary

Driver overwrites DiagnosticsEngine::IgnoreAllWarnings based on -w flag
without taking into account DiagnosticOptions::IgnoreWarnings that is
propagated to DiagnosticsEngine in ProcessWarningOptions (called from
CompilerInstance::createDiagnostics). It makes it hard to manipulate
DiagnosticOptions directly and pushes towards string-based API.

Most of in-tree tools use DiagnosticOptions already, so migrate
clang_parseTranslationUnit_Impl to use it too. Don't parse -w
directly but rely on

def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, Flags<[CC1Option]>,
  MarshallingInfoFlag<DiagnosticOpts<"IgnoreWarnings">>;

Allows to reland D138252.

Diff Detail

Event Timeline

vsapsai created this revision.Nov 29 2022, 6:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 6:08 PM
vsapsai requested review of this revision.Nov 29 2022, 6:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 6:08 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

To help folks digging up the history, the code in driver was introduced in https://reviews.llvm.org/D11322 and the test case added in "test/Index/warning-flags.c" requires the change in "clang/tools/libclang/CIndex.cpp", that's why I don't have any extra test changes.

MaskRay accepted this revision.Nov 30 2022, 8:03 PM
This revision is now accepted and ready to land.Nov 30 2022, 8:03 PM

Thanks for the review!