diff --git a/clang/tools/scan-build/ccc-analyzer b/clang/tools/scan-build/ccc-analyzer index 969c1bbb0880..ae114dffbbf5 100755 --- a/clang/tools/scan-build/ccc-analyzer +++ b/clang/tools/scan-build/ccc-analyzer @@ -444,6 +444,9 @@ my $InternalStats = $ENV{'CCC_ANALYZER_INTERNAL_STATS'}; my $OutputFormat = $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'}; if (!defined $OutputFormat) { $OutputFormat = "html"; } +# Get the config options. +my $ConfigOptions = $ENV{'CCC_ANALYZER_CONFIG'}; + # Determine the level of verbosity. my $Verbose = 0; if (defined $ENV{'CCC_ANALYZER_VERBOSE'}) { $Verbose = 1; } @@ -683,6 +686,9 @@ if ($Action eq 'compile' or $Action eq 'link') { } } } + if (defined $ConfigOptions) { + push @AnalyzeArgs, split '\s+', $ConfigOptions; + } push @CmdArgs, @CompileOpts; push @CmdArgs, $file; diff --git a/clang/tools/scan-build/scan-build b/clang/tools/scan-build/scan-build index 0f119f604986..e48a9b107e97 100755 --- a/clang/tools/scan-build/scan-build +++ b/clang/tools/scan-build/scan-build @@ -885,7 +885,8 @@ sub AddIfNotPresent { sub SetEnv { my $Options = shift @_; foreach my $opt ('CC', 'CXX', 'CLANG', 'CLANG_CXX', - 'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS') { + 'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS', + 'CCC_ANALYZER_CONFIG') { die "$opt is undefined\n" if (!defined $opt); $ENV{$opt} = $Options->{$opt}; } @@ -1164,6 +1165,10 @@ ADVANCED OPTIONS: --override-compiler Always resort to the ccc-analyzer even when better interposition methods are available. + + -analyzer-config + + Provide options to pass through to the analyzer's -analyzer-config flag. CONTROLLING CHECKERS: @@ -1336,6 +1341,7 @@ my @AnalysesToRun; my $StoreModel; my $ConstraintsModel; my $InternalStats; +my @ConfigOptions; my $OutputFormat = "html"; my $AnalyzerStats = 0; my $MaxLoop = 0; @@ -1483,7 +1489,13 @@ while (@ARGV) { $OutputFormat = "plist-html"; next; } - + + if ($arg eq "-analyzer-config") { + shift @ARGV; + push @ConfigOptions, "-analyzer-config", shift @ARGV; + next; + } + if ($arg eq "-no-failure-reports") { $ENV{"CCC_REPORT_FAILURES"} = 0; next; @@ -1636,6 +1648,7 @@ if ($MaxLoop > 0) { push @AnalysesToRun, "-analyzer-max-loop $MaxLoop"; } # interposition. my $CCC_ANALYZER_ANALYSIS = join ' ',@AnalysesToRun; my $CCC_ANALYZER_PLUGINS = join ' ',@PluginsToLoad; +my $CCC_ANALYZER_CONFIG = join ' ',@ConfigOptions; my %Options = ( 'CC' => $Cmd, 'CXX' => $CmdCXX, @@ -1644,6 +1657,7 @@ my %Options = ( 'VERBOSE' => $Verbose, 'CCC_ANALYZER_ANALYSIS' => $CCC_ANALYZER_ANALYSIS, 'CCC_ANALYZER_PLUGINS' => $CCC_ANALYZER_PLUGINS, + 'CCC_ANALYZER_CONFIG' => $CCC_ANALYZER_CONFIG, 'OUTPUT_DIR' => $HtmlDir );