Update prebuilt Clang to r416183b from Android.

https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef

clang 12.0.5 (based on r416183b) from build 7284624.

Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/bin/scan-build b/linux-x64/clang/bin/scan-build
index 903e19a..645f550 100755
--- a/linux-x64/clang/bin/scan-build
+++ b/linux-x64/clang/bin/scan-build
@@ -57,6 +57,7 @@
   KeepEmpty => 0,            # Don't remove output directory even with 0 results.
   EnableCheckers => {},
   DisableCheckers => {},
+  SilenceCheckers => {},
   Excludes => [],
   UseCC => undef,            # C compiler to use for compilation.
   UseCXX => undef,           # C++ compiler to use for compilation.
@@ -71,8 +72,9 @@
   MaxLoop => 0,
   PluginsToLoad => [],
   AnalyzerDiscoveryMethod => undef,
-  OverrideCompiler => 0,      # The flag corresponding to the --override-compiler command line option.
-  ForceAnalyzeDebugCode => 0
+  OverrideCompiler => 0,     # The flag corresponding to the --override-compiler command line option.
+  ForceAnalyzeDebugCode => 0,
+  GenerateIndex => 0         # Skip the analysis, only generate index.html.
 );
 lock_keys(%Options);
 
@@ -595,9 +597,11 @@
     return 0;
   }
 
-  # Scan each report file and build an index.
+  # Scan each report file, in alphabetical order, and build an index.
   my @Index;
   my @Stats;
+
+  @filesFound = sort @filesFound;
   foreach my $file (@filesFound) { ScanFile(\@Index, $Dir, $file, \@Stats); }
 
   # Scan the failures directory and use the information in the .info files
@@ -945,6 +949,42 @@
   return $Num;
 }
 
+sub Finalize {
+  my $BaseDir = shift;
+  my $ExitStatus = shift;
+
+  Diag "Analysis run complete.\n";
+  if (defined $Options{OutputFormat}) {
+    if ($Options{OutputFormat} =~ /plist/ ||
+        $Options{OutputFormat} =~ /sarif/) {
+      Diag "Analysis results (" .
+        ($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") .
+        " files) deposited in '$Options{OutputDir}'\n";
+    }
+    if ($Options{OutputFormat} =~ /html/) {
+      # Postprocess the HTML directory.
+      my $NumBugs = Postprocess($Options{OutputDir}, $BaseDir,
+                                $Options{AnalyzerStats}, $Options{KeepEmpty});
+
+      if ($Options{ViewResults} and -r "$Options{OutputDir}/index.html") {
+        Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n";
+        my $ScanView = Cwd::realpath("$RealBin/scan-view");
+        if (! -x $ScanView) { $ScanView = "scan-view"; }
+        if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); }
+        if (! -x $ScanView) { $ScanView = `which scan-view`; chomp $ScanView; }
+        exec $ScanView, "$Options{OutputDir}";
+      }
+
+      if ($Options{ExitStatusFoundBugs}) {
+        exit 1 if ($NumBugs > 0);
+        exit $ExitStatus;
+      }
+    }
+  }
+
+  exit $ExitStatus;
+}
+
 ##----------------------------------------------------------------------------##
 # RunBuildCommand - Run the build command.
 ##----------------------------------------------------------------------------##
@@ -1258,6 +1298,12 @@
 
    View analysis results in a web browser when the build completes.
 
+ --generate-index-only <output location>
+
+   Do not perform the analysis, but only regenerate the index.html file
+   from existing report.html files. Useful for making a custom Static Analyzer
+   integration into a build system that isn't otherwise supported by scan-build.
+
 ADVANCED OPTIONS:
 
  -no-failure-reports
@@ -1549,6 +1595,10 @@
     }
 
     if ($arg eq "-o") {
+      if (defined($Options{OutputDir})) {
+        DieDiag("Only one of '-o' or '--generate-index-only' can be specified.\n");
+      }
+
       shift @$Args;
 
       if (!@$Args) {
@@ -1564,6 +1614,27 @@
       next;
     }
 
+    if ($arg eq "--generate-index-only") {
+      if (defined($Options{OutputDir})) {
+        DieDiag("Only one of '-o' or '--generate-index-only' can be specified.\n");
+      }
+
+      shift @$Args;
+
+      if (!@$Args) {
+        DieDiag("'--generate-index-only' option requires a target directory name.\n");
+      }
+
+      # Construct an absolute path.  Uses the current working directory
+      # as a base if the original path was not absolute.
+      my $OutDir = shift @$Args;
+      mkpath($OutDir) unless (-e $OutDir);  # abs_path wants existing dir
+      $Options{OutputDir} = abs_path($OutDir);
+      $Options{GenerateIndex} = 1;
+
+      next;
+    }
+
     if ($arg =~ /^--html-title(=(.+))?$/) {
       shift @$Args;
 
@@ -1742,9 +1813,15 @@
     if ($arg eq "-disable-checker") {
       shift @$Args;
       my $Checker = shift @$Args;
-      # Store $NumArgs to preserve the order the checkers were disabled.
-      $Options{DisableCheckers}{$Checker} = $NumArgs;
-      delete $Options{EnableCheckers}{$Checker};
+      # Store $NumArgs to preserve the order the checkers are disabled/silenced.
+      # See whether it is a core checker to disable. That means we do not want
+      # to emit a report from that checker so we have to silence it.
+      if (index($Checker, "core") == 0) {
+        $Options{SilenceCheckers}{$Checker} = $NumArgs;
+      } else {
+        $Options{DisableCheckers}{$Checker} = $NumArgs;
+        delete $Options{EnableCheckers}{$Checker};
+      }
       next;
     }
 
@@ -1808,11 +1885,6 @@
 ProcessArgs(\@ARGV);
 # All arguments are now shifted from @ARGV. The rest is a build command, if any.
 
-if (!@ARGV and !$RequestDisplayHelp) {
-  ErrorDiag("No build command specified.\n\n");
-  $ForceDisplayHelp = 1;
-}
-
 my $ClangNotFoundErrMsg = FindClang();
 
 if ($ForceDisplayHelp || $RequestDisplayHelp) {
@@ -1820,6 +1892,25 @@
   exit $ForceDisplayHelp;
 }
 
+$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV)));
+
+if ($Options{GenerateIndex}) {
+  $ClangVersion = "unknown";
+  Finalize($Options{OutputDir}, 0);
+}
+
+# Make sure to use "" to handle paths with spaces.
+$ClangVersion = HtmlEscape(`"$Clang" --version`);
+
+if (!@ARGV and !$RequestDisplayHelp) {
+  ErrorDiag("No build command specified.\n\n");
+  $ForceDisplayHelp = 1;
+}
+
+# Determine the output directory for the HTML reports.
+my $BaseDir = $Options{OutputDir};
+$Options{OutputDir} = GetHTMLRunDir($Options{OutputDir});
+
 DieDiag($ClangNotFoundErrMsg) if (defined $ClangNotFoundErrMsg);
 
 $ClangCXX = $Clang;
@@ -1834,21 +1925,11 @@
     $ClangCXX =~ s/.exe$/++.exe/;
   }
   else {
-    $ClangCXX =~ s/\-\d+\.\d+$//;
+    $ClangCXX =~ s/\-\d+(\.\d+)?$//;
     $ClangCXX .= "++";
   }
 }
 
-# Make sure to use "" to handle paths with spaces.
-$ClangVersion = HtmlEscape(`"$Clang" --version`);
-
-# Determine where results go.
-$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV)));
-
-# Determine the output directory for the HTML reports.
-my $BaseDir = $Options{OutputDir};
-$Options{OutputDir} = GetHTMLRunDir($Options{OutputDir});
-
 # Determine the location of ccc-analyzer.
 my $AbsRealBin = Cwd::realpath($RealBin);
 my $Cmd = "$AbsRealBin/../libexec/ccc-analyzer";
@@ -1891,6 +1972,16 @@
 my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun;
 my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } @{$Options{PluginsToLoad}};
 my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } @{$Options{ConfigOptions}};
+
+if (%{$Options{SilenceCheckers}}) {
+  $CCC_ANALYZER_CONFIG =
+      $CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers="
+                          .join(';', sort {
+                                            $Options{SilenceCheckers}{$a} <=>
+                                            $Options{SilenceCheckers}{$b}
+                                          } keys %{$Options{SilenceCheckers}});
+}
+
 my %EnvVars = (
   'CC' => $Cmd,
   'CXX' => $CmdCXX,
@@ -1916,33 +2007,4 @@
 my $ExitStatus = RunBuildCommand(\@ARGV, $Options{IgnoreErrors}, $Options{KeepCC},
 	                        $Cmd, $CmdCXX, \%EnvVars);
 
-if (defined $Options{OutputFormat}) {
-  if ($Options{OutputFormat} =~ /plist/ ||
-      $Options{OutputFormat} =~ /sarif/) {
-    Diag "Analysis run complete.\n";
-    Diag "Analysis results (" .
-      ($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") .
-      " files) deposited in '$Options{OutputDir}'\n";
-  }
-  if ($Options{OutputFormat} =~ /html/) {
-    # Postprocess the HTML directory.
-    my $NumBugs = Postprocess($Options{OutputDir}, $BaseDir,
-                              $Options{AnalyzerStats}, $Options{KeepEmpty});
-
-    if ($Options{ViewResults} and -r "$Options{OutputDir}/index.html") {
-      Diag "Analysis run complete.\n";
-      Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n";
-      my $ScanView = Cwd::realpath("$RealBin/scan-view");
-      if (! -x $ScanView) { $ScanView = "scan-view"; }
-      if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); }
-      exec $ScanView, "$Options{OutputDir}";
-    }
-
-    if ($Options{ExitStatusFoundBugs}) {
-      exit 1 if ($NumBugs > 0);
-      exit $ExitStatus;
-    }
-  }
-}
-
-exit $ExitStatus;
+Finalize($BaseDir, $ExitStatus);