diff options
Diffstat (limited to 'clang/tools/scan-build')
-rwxr-xr-x | clang/tools/scan-build/bin/scan-build | 20 | ||||
-rwxr-xr-x | clang/tools/scan-build/libexec/ccc-analyzer | 8 |
2 files changed, 25 insertions, 3 deletions
diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build index 6a14484970a..3182a29767b 100755 --- a/clang/tools/scan-build/bin/scan-build +++ b/clang/tools/scan-build/bin/scan-build @@ -69,7 +69,8 @@ my %Options = ( MaxLoop => 0, PluginsToLoad => [], AnalyzerDiscoveryMethod => undef, - OverrideCompiler => 0 # The flag corresponding to the --override-compiler command line option. + OverrideCompiler => 0, # The flag corresponding to the --override-compiler command line option. + ForceAnalyzeDebugCode => 0 ); lock_keys(%Options); @@ -951,7 +952,8 @@ sub SetEnv { 'CCC_CC', 'CCC_CXX', 'CCC_REPORT_FAILURES', - 'CLANG_ANALYZER_TARGET') { + 'CLANG_ANALYZER_TARGET', + 'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE') { my $x = $EnvVars->{$var}; if (defined $x) { $ENV{$var} = $x } } @@ -1118,6 +1120,11 @@ OPTIONS: Also analyze functions in #included files. By default, such functions are skipped unless they are called by functions within the main source file. + --force-analyze-debug-code + + Tells analyzer to enable assertions in code even if they were disabled + during compilation to enable more precise results. + -o <output location> Specifies the output directory for analyzer reports. Subdirectories will be @@ -1681,6 +1688,12 @@ sub ProcessArgs { next; } + if ($arg eq "--force-analyze-debug-code") { + shift @$Args; + $Options{ForceAnalyzeDebugCode} = 1; + next; + } + DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/); $NumArgs--; @@ -1796,7 +1809,8 @@ my %EnvVars = ( 'CCC_ANALYZER_CONSTRAINTS_MODEL' => $Options{ConstraintsModel}, 'CCC_ANALYZER_INTERNAL_STATS' => $Options{InternalStats}, 'CCC_ANALYZER_OUTPUT_FORMAT' => $Options{OutputFormat}, - 'CLANG_ANALYZER_TARGET' => $Options{AnalyzerTarget} + 'CLANG_ANALYZER_TARGET' => $Options{AnalyzerTarget}, + 'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE' => $Options{ForceAnalyzeDebugCode} ); # Run the build. diff --git a/clang/tools/scan-build/libexec/ccc-analyzer b/clang/tools/scan-build/libexec/ccc-analyzer index 831dd42e9c9..bfda1d326f9 100755 --- a/clang/tools/scan-build/libexec/ccc-analyzer +++ b/clang/tools/scan-build/libexec/ccc-analyzer @@ -492,6 +492,9 @@ if (defined $ENV{'CCC_ANALYZER_LOG'}) { $Verbose = 2; } # Get the HTML output directory. my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'}; +# Get force-analyze-debug-code option. +my $ForceAnalyzeDebugCode = $ENV{'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE'}; + my %DisabledArchs = ('ppc' => 1, 'ppc64' => 1); my %ArchsSeen; my $HadArch = 0; @@ -682,6 +685,11 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) { } } +# Forcedly enable debugging if requested by user. +if ($ForceAnalyzeDebugCode) { + push @CompileOpts, '-UNDEBUG'; +} + # If we are on OSX and have an installation where the # default SDK is inferred by xcrun use xcrun to infer # the SDK. |