[clang] b4b5469 - [clang][Driver] Don't overwrite `DiagnosticsEngine::IgnoreAllWarnings`, rely on `DiagnosticOptions::IgnoreWarnings` value.
Volodymyr Sapsai via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 2 11:59:36 PST 2022
Author: Volodymyr Sapsai
Date: 2022-12-02T11:59:22-08:00
New Revision: b4b54697b7aacda1fabef36d4e74d5ee45641618
URL: https://github.com/llvm/llvm-project/commit/b4b54697b7aacda1fabef36d4e74d5ee45641618
DIFF: https://github.com/llvm/llvm-project/commit/b4b54697b7aacda1fabef36d4e74d5ee45641618.diff
LOG: [clang][Driver] Don't overwrite `DiagnosticsEngine::IgnoreAllWarnings`, rely on `DiagnosticOptions::IgnoreWarnings` value.
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.
Differential Revision: https://reviews.llvm.org/D138970
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/tools/libclang/CIndex.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5423fdc9855eb..6bd2d38f65744 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1211,9 +1211,6 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// 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);
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index dec7efd7bfb14..4210f162569ed 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3797,8 +3797,10 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
}
// 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);
More information about the cfe-commits
mailing list