[PATCH] D55823: [analyzer] Fix backward compatibility issue after D53280 'Emit an error for invalid -analyzer-config inputs'
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 18 06:38:56 PST 2018
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, whisperity.
Fix according to the discussion here: D53280 <https://reviews.llvm.org/D53280>
Repository:
rC Clang
https://reviews.llvm.org/D55823
Files:
lib/Driver/ToolChains/Clang.cpp
test/Analysis/invalid-analyzer-config-value.c
Index: test/Analysis/invalid-analyzer-config-value.c
===================================================================
--- test/Analysis/invalid-analyzer-config-value.c
+++ test/Analysis/invalid-analyzer-config-value.c
@@ -66,6 +66,12 @@
// CHECK-NO-COMPAT: error: unknown analyzer-config 'no-false-positives'
+
+// Test the driver properly using "analyzer-config-compatibility-mode=true",
+// even if -analyze isn't specified.
+// RUN: %clang --analyze -Xclang -analyzer-config -Xclang remember=TheVasa %s
+
+
// expected-no-diagnostics
int main() {}
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2360,9 +2360,6 @@
// Treat blocks as analysis entry points.
CmdArgs.push_back("-analyzer-opt-analyze-nested-blocks");
- // Enable compatilibily mode to avoid analyzer-config related errors.
- CmdArgs.push_back("-analyzer-config-compatibility-mode=true");
-
// Add default argument set.
if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) {
CmdArgs.push_back("-analyzer-checker=core");
@@ -3694,6 +3691,17 @@
if (isa<AnalyzeJobAction>(JA))
RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
+ {
+ auto AnalyzerConfigArg =
+ llvm::find_if(CmdArgs, [] (StringRef Arg) {
+ return Arg.contains("-analyzer-config");
+ });
+
+ // Enable compatilibily mode to avoid analyzer-config related errors.
+ if (AnalyzerConfigArg != CmdArgs.end())
+ CmdArgs.push_back("-analyzer-config-compatibility-mode=true");
+ }
+
CheckCodeGenerationOptions(D, Args);
unsigned FunctionAlignment = ParseFunctionAlignment(TC, Args);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55823.178661.patch
Type: text/x-patch
Size: 1783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181218/e06c5924/attachment.bin>
More information about the cfe-commits
mailing list