diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /tools/scan-build | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/scan-build')
-rwxr-xr-x | tools/scan-build/bin/scan-build | 30 | ||||
-rwxr-xr-x | tools/scan-build/bin/set-xcode-analyzer | 2 | ||||
-rwxr-xr-x | tools/scan-build/libexec/ccc-analyzer | 7 | ||||
-rw-r--r-- | tools/scan-build/man/scan-build.1 | 5 |
4 files changed, 31 insertions, 13 deletions
diff --git a/tools/scan-build/bin/scan-build b/tools/scan-build/bin/scan-build index fd0dd66b2d..903e19a290 100755 --- a/tools/scan-build/bin/scan-build +++ b/tools/scan-build/bin/scan-build @@ -1,9 +1,8 @@ #!/usr/bin/env perl # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # @@ -1461,6 +1460,16 @@ sub ShellEscape { } ##----------------------------------------------------------------------------## +# FindXcrun - searches for the 'xcrun' executable. Returns "" if not found. +##----------------------------------------------------------------------------## + +sub FindXcrun { + my $xcrun = `which xcrun`; + chomp $xcrun; + return $xcrun; +} + +##----------------------------------------------------------------------------## # FindClang - searches for 'clang' executable. ##----------------------------------------------------------------------------## @@ -1469,6 +1478,16 @@ sub FindClang { $Clang = Cwd::realpath("$RealBin/bin/clang") if (-f "$RealBin/bin/clang"); if (!defined $Clang || ! -x $Clang) { $Clang = Cwd::realpath("$RealBin/clang") if (-f "$RealBin/clang"); + if (!defined $Clang || ! -x $Clang) { + # When an Xcode toolchain is present, look for a clang in the sibling bin + # of the parent of the bin directory. So if scan-build is at + # $TOOLCHAIN/usr/local/bin/scan-build look for clang at + # $TOOLCHAIN/usr/bin/clang. + my $has_xcode_toolchain = FindXcrun() ne ""; + if ($has_xcode_toolchain && -f "$RealBin/../../bin/clang") { + $Clang = Cwd::realpath("$RealBin/../../bin/clang"); + } + } } if (!defined $Clang || ! -x $Clang) { return "error: Cannot find an executable 'clang' relative to" . @@ -1478,8 +1497,7 @@ sub FindClang { } else { if ($Options{AnalyzerDiscoveryMethod} =~ /^[Xx]code$/) { - my $xcrun = `which xcrun`; - chomp $xcrun; + my $xcrun = FindXcrun(); if ($xcrun eq "") { return "Cannot find 'xcrun' to find 'clang' for analysis.\n"; } diff --git a/tools/scan-build/bin/set-xcode-analyzer b/tools/scan-build/bin/set-xcode-analyzer index 8e674823ba..c2a65c9085 100755 --- a/tools/scan-build/bin/set-xcode-analyzer +++ b/tools/scan-build/bin/set-xcode-analyzer @@ -42,7 +42,7 @@ def ModifySpec(path, isBuiltinAnalyzer, pathToChecker): if line.find("Static Analyzer") >= 0: foundAnalyzer = True else: - m = re.search('^(\s*ExecPath\s*=\s*")', line) + m = re.search(r'^(\s*ExecPath\s*=\s*")', line) if m: line = "".join([m.group(0), pathToChecker, '";\n']) # Do not modify further ExecPath's later in the xcspec. diff --git a/tools/scan-build/libexec/ccc-analyzer b/tools/scan-build/libexec/ccc-analyzer index 70afb5bcbb..9a4548f167 100755 --- a/tools/scan-build/libexec/ccc-analyzer +++ b/tools/scan-build/libexec/ccc-analyzer @@ -1,9 +1,8 @@ #!/usr/bin/env perl # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/tools/scan-build/man/scan-build.1 b/tools/scan-build/man/scan-build.1 index cf7e7b15c3..4f3cd8d103 100644 --- a/tools/scan-build/man/scan-build.1 +++ b/tools/scan-build/man/scan-build.1 @@ -1,5 +1,6 @@ -.\" This file is distributed under the University of Illinois Open Source -.\" License. See LICENSE.TXT for details. +.\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +.\" See https://llvm.org/LICENSE.txt for license information. +.\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception .\" $Id$ .Dd May 25, 2012 .Dt SCAN-BUILD 1 |