[PATCH] D138970: [clang][Driver] Don't overwrite `DiagnosticsEngine::IgnoreAllWarnings`, rely on `DiagnosticOptions::IgnoreWarnings` value.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 29 18:08:43 PST 2022
vsapsai created this revision.
vsapsai added reviewers: bnbarham, dyung, MaskRay.
Herald added subscribers: StephenFan, ributzka, arphaman.
Herald added a project: All.
vsapsai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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 <https://reviews.llvm.org/D138252>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138970
Files:
clang/lib/Driver/Driver.cpp
clang/tools/libclang/CIndex.cpp
Index: clang/tools/libclang/CIndex.cpp
===================================================================
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3797,8 +3797,10 @@
}
// Configure the diagnostics.
+ std::unique_ptr<DiagnosticOptions> DiagOpts = CreateAndPopulateDiagOpts(
+ llvm::makeArrayRef(command_line_args, num_command_line_args));
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- CompilerInstance::createDiagnostics(new DiagnosticOptions));
+ CompilerInstance::createDiagnostics(DiagOpts.release()));
if (options & CXTranslationUnit_KeepGoing)
Diags->setFatalsAsError(true);
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1211,9 +1211,6 @@
// FIXME: This stuff needs to go into the Compilation, not the driver.
bool CCCPrintPhases;
- // Silence driver warnings if requested
- Diags.setIgnoreAllWarnings(Args.hasArg(options::OPT_w));
-
// -canonical-prefixes, -no-canonical-prefixes are used very early in main.
Args.ClaimAllArgs(options::OPT_canonical_prefixes);
Args.ClaimAllArgs(options::OPT_no_canonical_prefixes);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138970.478774.patch
Type: text/x-patch
Size: 1239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221130/f0200ae6/attachment.bin>
More information about the cfe-commits
mailing list