[PATCH][scan-build]Add -target option when clang is invoked to check syntax

Kazuhiro Yabe via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 22 03:57:43 PST 2017


Dear all,

This patch adds the '-target' option to the clang option to invoke to
check the syntax when scan-build is called with the --analyzer-target
option.


I'm using scan-build in cross compile project. (target: armv7-a)
Even when cross compiling, scan-build invokes clang with -triple (HOST
ARCH) to check syntax.
Therefore, if my code has some errors, clang reports error in syntax
checking:

error: unknown target CPU 'armv7-a'

This patch fixes that issue.

Thanks.


Index: tools/scan-build/libexec/ccc-analyzer
===================================================================
--- tools/scan-build/libexec/ccc-analyzer (revision 295806)
+++ tools/scan-build/libexec/ccc-analyzer (working copy)
@@ -224,6 +224,10 @@
   else {
     $Cmd = $Clang;

+    if (defined $AnalyzerTarget) {
+      push @Args, "-target", $AnalyzerTarget;
+    }
+
     # Create arguments for doing regular parsing.
     my $SyntaxArgs = GetCCArgs($HtmlDir, "-fsyntax-only", \@Args);
     @CmdArgsSansAnalyses = @$SyntaxArgs;
@@ -248,10 +252,6 @@
       push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
     }

-    if (defined $AnalyzerTarget) {
-      push @Args, "-target", $AnalyzerTarget;
-    }
-
     my $AnalysisArgs = GetCCArgs($HtmlDir, "--analyze", \@Args);
     @CmdArgs = @$AnalysisArgs;
   }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170222/0266b978/attachment-0001.html>


More information about the cfe-commits mailing list