diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-03-01 14:54:16 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-03-01 14:54:16 +0000 |
commit | 8b9b3bd07c5046ae3010516d84d3217934ad10d5 (patch) | |
tree | b352ac923482fa800709b5291976798ace5613b5 /clang/tools/scan-build-py/libscanbuild/clang.py | |
parent | 1bab70109b9fa259f928fe30a8ad153db8f4ecbe (diff) | |
download | bcm5719-llvm-8b9b3bd07c5046ae3010516d84d3217934ad10d5.tar.gz bcm5719-llvm-8b9b3bd07c5046ae3010516d84d3217934ad10d5.zip |
Resubmit [analyzer] Support for naive cross translation unit analysis
Originally submitted as r326323 and r326324.
Reverted in r326432.
Reverting the commit was a mistake.
The breakage was due to invalid build files in our internal buildsystem,
CMakeLists did not have any cyclic dependencies.
llvm-svn: 326439
Diffstat (limited to 'clang/tools/scan-build-py/libscanbuild/clang.py')
-rw-r--r-- | clang/tools/scan-build-py/libscanbuild/clang.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/clang/tools/scan-build-py/libscanbuild/clang.py b/clang/tools/scan-build-py/libscanbuild/clang.py index 192e708782c..ab422066cab 100644 --- a/clang/tools/scan-build-py/libscanbuild/clang.py +++ b/clang/tools/scan-build-py/libscanbuild/clang.py @@ -8,11 +8,13 @@ Since Clang command line interface is so rich, but this project is using only a subset of that, it makes sense to create a function specific wrapper. """ +import subprocess import re from libscanbuild import run_command from libscanbuild.shell import decode -__all__ = ['get_version', 'get_arguments', 'get_checkers'] +__all__ = ['get_version', 'get_arguments', 'get_checkers', 'is_ctu_capable', + 'get_triple_arch'] # regex for activated checker ACTIVE_CHECKER_PATTERN = re.compile(r'^-analyzer-checker=(.*)$') @@ -152,3 +154,26 @@ def get_checkers(clang, plugins): raise Exception('Could not query Clang for available checkers.') return checkers + + +def is_ctu_capable(func_map_cmd): + """ Detects if the current (or given) clang and function mapping + executables are CTU compatible. """ + + try: + run_command([func_map_cmd, '-version']) + except (OSError, subprocess.CalledProcessError): + return False + return True + + +def get_triple_arch(command, cwd): + """Returns the architecture part of the target triple for the given + compilation command. """ + + cmd = get_arguments(command, cwd) + try: + separator = cmd.index("-triple") + return cmd[separator + 1] + except (IndexError, ValueError): + return "" |