[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
Wed Dec 19 11:32:58 PST 2018


Szelethus updated this revision to Diff 178927.
Szelethus added a comment.

I'm still looking for a sensible solution, but I'll at least share a patch that actually works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55823/new/

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,10 @@
 
 // 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 -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
@@ -3694,6 +3694,16 @@
   if (isa<AnalyzeJobAction>(JA))
     RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 
+  // Enable compatilibily mode to avoid analyzer-config related errors.
+  // Since we can't access frontend flags through hasArg, let's manually iterate
+  // through them.
+  for (size_t Index = 0; Index < Args.size(); ++Index) {
+    if (StringRef(Args.getArgString(Index)).contains("-analyzer-config")) {
+      CmdArgs.push_back("-analyzer-config-compatibility-mode=true");
+      break;
+    }
+  }
+
   CheckCodeGenerationOptions(D, Args);
 
   unsigned FunctionAlignment = ParseFunctionAlignment(TC, Args);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55823.178927.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181219/25133c33/attachment.bin>


More information about the cfe-commits mailing list