summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-05-14 20:10:33 +0000
committerTed Kremenek <kremenek@apple.com>2008-05-14 20:10:33 +0000
commite3fc13a3e0a5abb340c4184c30075ef9a72bb165 (patch)
tree7029500408bac569444eb90998def92ca0aef6c2
parent763ec13862bfa1c6b37fa6a1f27fc1c21a1a95a5 (diff)
downloadbcm5719-llvm-e3fc13a3e0a5abb340c4184c30075ef9a72bb165.tar.gz
bcm5719-llvm-e3fc13a3e0a5abb340c4184c30075ef9a72bb165.zip
Added "-a" option to scan-build to select the analysis (ASTConsumer) used by clang. The default is -checker-cfref.
llvm-svn: 51116
-rwxr-xr-xclang/utils/ccc-analyzer21
-rwxr-xr-xclang/utils/scan-build26
2 files changed, 39 insertions, 8 deletions
diff --git a/clang/utils/ccc-analyzer b/clang/utils/ccc-analyzer
index 6530303b73d..a1308daa8ee 100755
--- a/clang/utils/ccc-analyzer
+++ b/clang/utils/ccc-analyzer
@@ -50,7 +50,7 @@ def remove_pch_extension(path):
return path
return path[:i]
-def analyze(clang, args,language,output,files,verbose,htmldir,file):
+def analyze(clang, args,language,output,files,verbose,htmldir,file,analysis_type):
if language.find("c++") > 0:
return
@@ -73,14 +73,12 @@ def analyze(clang, args,language,output,files,verbose,htmldir,file):
command = 'cp'.split()
args = command + files + target.split()
else:
- command = clang.split() + '-checker-cfref'.split()
+ command = clang.split() + analysis_type.split()
args = command + args;
RunAnalyzer = 1
if verbose == 2:
print >> sys.stderr, '#SHELL (cd ' + os.getcwd() + ' && ' + ' '.join(command + print_args) + ')\n'
- print >> sys.stderr, '#LINE (cd ' + os.getcwd() + ' && wc -l ' + file + ')\n'
-
if RunAnalyzer and htmldir is not None:
args.append('-o')
@@ -142,18 +140,29 @@ def main(args):
# Forward to GCC.
compile(args)
-
+
+ # Set the analyzer flag.
+ analysis_type = os.environ.get('CCC_ANALYZER_ANALYSIS')
+
+ if analysis_type is not None:
+ analysis_type = "-" + analysis_type
+ else:
+ analysis_type = "-checker-cfref"
+
+ # Determine the level of verbosity.
if os.environ.get('CCC_ANALYZER_VERBOSE') is not None:
verbose = 1
if os.environ.get('CCC_ANALYZER_LOG') is not None:
verbose = 2
+ # Determine what clang executable to use.
clang_env = os.environ.get('CLANG')
if clang_env is not None:
clang = clang_env
+ # Get the HTML output directory.
htmldir = os.environ.get('CCC_ANALYZER_HTML')
i = 0
@@ -268,7 +277,7 @@ def main(args):
if language != 'unknown':
analyze_args = [ '-x', language ] + analyze_args
analyze_args = analyze_args + compile_opts
- analyze(clang, analyze_args, language, output, files, verbose, htmldir, file)
+ analyze(clang, analyze_args, language, output, files, verbose, htmldir, file, analysis_type)
# compile(args)
diff --git a/clang/utils/scan-build b/clang/utils/scan-build
index 890f0145a5d..c6647cd1b90 100755
--- a/clang/utils/scan-build
+++ b/clang/utils/scan-build
@@ -523,14 +523,17 @@ USAGE: $Prog [options] <build command> [build options]
OPTIONS:
+ -a - The analysis to run. The default is 'checker-cfref'.
+ Valid options are: 'checker-cfref', 'fsyntax-only'
+
-o - Target directory for HTML report files. Subdirectories
will be created as needed to represent separate "runs" of
the analyzer. If this option is not specified, a directory
is created in /tmp to store the reports.
-
+
-h - Display this message.
--help
-
+
-k - Add a "keep on going" option to the specified build command.
--keep-going This option currently supports make and xcodebuild.
This is a convenience option; one can specify this
@@ -565,6 +568,7 @@ ENDTEXT
my $HtmlDir; # Parent directory to store HTML files.
my $IgnoreErrors = 0; # Ignore build errors.
my $ViewResults = 0; # View results when the build terminates.
+my $Analysis = "checker-cfref";
if (!@ARGV) {
DisplayHelp();
@@ -582,6 +586,22 @@ while (@ARGV) {
exit 0;
}
+ if ($arg eq "-a") {
+ shift @ARGV;
+
+ if (!@ARGV) {
+ die "$Prog: '-a' option requires an analysis type.\n";
+ }
+
+ $Analysis = shift @ARGV;
+
+ if (!($Analysis eq "checker-cfref" or $Analysis eq "fsyntax-only")) {
+ die "$Prog: Invalid argument '$Analysis' to -a.\n";
+ }
+
+ next;
+ }
+
if ($arg eq "-o") {
shift @ARGV;
@@ -667,6 +687,8 @@ if ($Verbose >= 3) {
$ENV{'CCC_ANALYZER_LOG'} = 1;
}
+$ENV{'CCC_ANALYZER_ANALYSIS'} = $Analysis;
+
# Run the build.
RunBuildCommand(\@ARGV, $IgnoreErrors);
OpenPOWER on IntegriCloud