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);


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);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to