scan-build/ccc-analyzer: start analyzing C++ FTW.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91398 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer
index 9fca432..aca411f 100755
--- a/tools/scan-build/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer
@@ -14,14 +14,38 @@
 
 use strict;
 use warnings;
+use FindBin;
 use Cwd qw/ getcwd abs_path /;
 use File::Temp qw/ tempfile /;
 use File::Path qw / mkpath /;
 use File::Basename;
 use Text::ParseWords;
 
-my $CC = $ENV{'CCC_CC'};
-if (!defined $CC) { $CC = "gcc"; }
+##===----------------------------------------------------------------------===##
+# Compiler command setup.
+##===----------------------------------------------------------------------===##
+
+my $Compiler;
+my $Clang;
+
+if ($FindBin::Script =~ /c\+\+-analyzer/) {
+  $Compiler = $ENV{'CCC_CXX'};
+  if (!defined $Compiler) { $Compiler = "g++"; }
+  
+  $Clang = $ENV{'CLANG_CXX'};
+  if (!defined $Clang) { $Clang = 'clang++'; }
+}
+else {
+  $Compiler = $ENV{'CCC_CC'};
+  if (!defined $Compiler) { $Compiler = "gcc"; }
+
+  $Clang = $ENV{'CLANG'};
+  if (!defined $Clang) { $Clang = 'clang'; }
+}
+
+##===----------------------------------------------------------------------===##
+# Cleanup.
+##===----------------------------------------------------------------------===##
 
 my $ReportFailures = $ENV{'CCC_REPORT_FAILURES'};
 if (!defined $ReportFailures) { $ReportFailures = 1; }
@@ -79,7 +103,7 @@
   print OUT "@$Args\n";
   close OUT;
   `uname -a >> $PPFile.info.txt 2>&1`;
-  `$CC -v >> $PPFile.info.txt 2>&1`;
+  `$Compiler -v >> $PPFile.info.txt 2>&1`;
   system 'mv',$ofile,"$PPFile.stderr.txt";
   return (basename $PPFile);
 }
@@ -88,10 +112,6 @@
 #  Running the analyzer.
 ##----------------------------------------------------------------------------##
 
-# Determine what clang executable to use.
-my $Clang = $ENV{'CLANG'};
-if (!defined $Clang) { $Clang = 'clang'; }
-
 sub GetCCArgs {
   my $Args = shift;
   
@@ -134,9 +154,6 @@
   
   $Args = GetCCArgs($Args);
 
-  # Skip anything related to C++.
-  return if ($Lang =~ /c[+][+]/);
-
   my $RunAnalyzer = 0;
   my $Cmd;
   my @CmdArgs;
@@ -361,7 +378,9 @@
 
 my %LangsAccepted = (
   "objective-c" => 1,
-  "c" => 1
+  "c" => 1,
+  "c++" => 1,
+  "objective-c++" => 1
 );
 
 ##----------------------------------------------------------------------------##
@@ -377,7 +396,7 @@
 my %Uniqued;
 
 # Forward arguments to gcc.
-my $Status = system($CC,@ARGV);
+my $Status = system($Compiler,@ARGV);
 if ($Status) { exit($Status >> 8); }
 
 # Get the analysis options.