summaryrefslogtreecommitdiffstats
path: root/tools/scan-build/ccc-analyzer
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-05-02 19:39:53 +0000
committerdim <dim@FreeBSD.org>2011-05-02 19:39:53 +0000
commit110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (patch)
tree64a10f4c4154739d4a8191d7e1b52ce497f4ebd6 /tools/scan-build/ccc-analyzer
parenta0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (diff)
downloadFreeBSD-src-110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab.zip
FreeBSD-src-110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab.tar.gz
Vendor import of clang trunk r130700:
http://llvm.org/svn/llvm-project/cfe/trunk@130700
Diffstat (limited to 'tools/scan-build/ccc-analyzer')
-rwxr-xr-xtools/scan-build/ccc-analyzer66
1 files changed, 30 insertions, 36 deletions
diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer
index 5601387..7793a8d 100755
--- a/tools/scan-build/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer
@@ -147,9 +147,10 @@ sub GetCCArgs {
}
sub Analyze {
- my ($Clang, $Args, $AnalyzeArgs, $Lang, $Output, $Verbose, $HtmlDir,
+ my ($Clang, $OriginalArgs, $AnalyzeArgs, $Lang, $Output, $Verbose, $HtmlDir,
$file) = @_;
+ my @Args = @$OriginalArgs;
my $Cmd;
my @CmdArgs;
my @CmdArgsSansAnalyses;
@@ -166,41 +167,37 @@ sub Analyze {
else {
$Cmd = $Clang;
if ($Lang eq "objective-c" || $Lang eq "objective-c++") {
- push @$Args,'-DIBOutlet=__attribute__((iboutlet))';
- push @$Args,'-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection)))';
- push @$Args,'-DIBAction=void)__attribute__((ibaction)';
+ push @Args,'-DIBOutlet=__attribute__((iboutlet))';
+ push @Args,'-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection)))';
+ push @Args,'-DIBAction=void)__attribute__((ibaction)';
}
# Create arguments for doing regular parsing.
- my $SyntaxArgs = GetCCArgs("-fsyntax-only", $Args);
- @CmdArgsSansAnalyses = @CmdArgs;
- push @CmdArgsSansAnalyses, @$SyntaxArgs;
-
+ my $SyntaxArgs = GetCCArgs("-fsyntax-only", \@Args);
+ @CmdArgsSansAnalyses = @$SyntaxArgs;
+
# Create arguments for doing static analysis.
if (defined $ResultFile) {
- push @$Args,'-o';
- push @$Args, $ResultFile;
+ push @Args, '-o', $ResultFile;
}
elsif (defined $HtmlDir) {
- push @$Args,'-o';
- push @$Args, $HtmlDir;
+ push @Args, '-o', $HtmlDir;
+ }
+ if ($Verbose) {
+ push @Args, "-Xclang", "-analyzer-display-progress";
}
- push @$Args,"-Xclang";
- push @$Args,"-analyzer-display-progress";
foreach my $arg (@$AnalyzeArgs) {
- push @$Args, "-Xclang";
- push @$Args, $arg;
+ push @Args, "-Xclang", $arg;
}
-
+
# Display Ubiviz graph?
if (defined $ENV{'CCC_UBI'}) {
- push @$Args, "-Xclang";
- push @$Args,"-analyzer-viz-egraph-ubigraph";
+ push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
}
- my $AnalysisArgs = GetCCArgs("--analyze", $Args);
- push @CmdArgs, @$AnalysisArgs;
+ my $AnalysisArgs = GetCCArgs("--analyze", \@Args);
+ @CmdArgs = @$AnalysisArgs;
}
my @PrintArgs;
@@ -217,7 +214,7 @@ sub Analyze {
if ($Verbose == 1) {
# We MUST print to stderr. Some clients use the stdout output of
# gcc for various purposes.
- print STDERR join(' ',@PrintArgs);
+ print STDERR join(' ', @PrintArgs);
print STDERR "\n";
}
elsif ($Verbose == 2) {
@@ -368,9 +365,11 @@ my %LangMap = (
'cp' => 'c++',
'cpp' => 'c++',
'cc' => 'c++',
+ 'ii' => 'c++',
'i' => 'c-cpp-output',
'm' => 'objective-c',
- 'mi' => 'objective-c-cpp-output'
+ 'mi' => 'objective-c-cpp-output',
+ 'mm' => 'objective-c++'
);
my %UniqueOptions = (
@@ -383,14 +382,11 @@ my %UniqueOptions = (
my %LangsAccepted = (
"objective-c" => 1,
- "c" => 1
+ "c" => 1,
+ "c++" => 1,
+ "objective-c++" => 1
);
-if (defined $ENV{'CCC_ANALYZER_CPLUSPLUS'}) {
- $LangsAccepted{"c++"} = 1;
- $LangsAccepted{"objective-c++"} = 1;
-}
-
##----------------------------------------------------------------------------##
# Main Logic.
##----------------------------------------------------------------------------##
@@ -613,8 +609,7 @@ if ($Action eq 'compile' or $Action eq 'link') {
my @AnalyzeArgs;
if ($FileLang ne 'unknown') {
- push @CmdArgs,'-x';
- push @CmdArgs,$FileLang;
+ push @CmdArgs, '-x', $FileLang;
}
if (defined $StoreModel) {
@@ -625,9 +620,9 @@ if ($Action eq 'compile' or $Action eq 'link') {
push @AnalyzeArgs, "-analyzer-constraints=$ConstraintsModel";
}
-# if (defined $Analyses) {
-# push @AnalyzeArgs, split '\s+', $Analyses;
-# }
+ if (defined $Analyses) {
+ push @AnalyzeArgs, split '\s+', $Analyses;
+ }
if (defined $OutputFormat) {
push @AnalyzeArgs, "-analyzer-output=" . $OutputFormat;
@@ -646,8 +641,7 @@ if ($Action eq 'compile' or $Action eq 'link') {
if (scalar @Archs) {
foreach my $arch (@Archs) {
my @NewArgs;
- push @NewArgs, '-arch';
- push @NewArgs, $arch;
+ push @NewArgs, '-arch', $arch;
push @NewArgs, @CmdArgs;
Analyze($Clang, \@NewArgs, \@AnalyzeArgs, $FileLang, $Output,
$Verbose, $HtmlDir, $file);
OpenPOWER on IntegriCloud