diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2018-02-28 13:23:10 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2018-02-28 13:23:10 +0000 |
commit | eb0584bee413c5b0f3275e47d6153433c8a3130f (patch) | |
tree | e9f412f0f0fe6c8a291bd02ecadaec4ccbd79b52 /clang/tools/scan-build-py/libscanbuild/clang.py | |
parent | 4529aac2de3ffccbf015503681bb5c9712e295b7 (diff) | |
download | bcm5719-llvm-eb0584bee413c5b0f3275e47d6153433c8a3130f.tar.gz bcm5719-llvm-eb0584bee413c5b0f3275e47d6153433c8a3130f.zip |
[analyzer] Support for naive cross translation unit analysis
The aim of this patch is to be minimal to enable incremental development of
the feature on the top of the tree. This patch should be an NFC when the
feature is turned off. It is turned off by default and still considered as
experimental.
Technical details are available in the EuroLLVM Talk:
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7
Note that the initial prototype was done by A. Sidorin et al.: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html
Contributions to the measurements and the new version of the code: Peter Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem.
Differential Revision: https://reviews.llvm.org/D30691
llvm-svn: 326323
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 "" |