[PATCH] D90362: scan-build supprot relative 'file' in cdb.
Yu Shan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 18:56:38 PDT 2020
aabbaabb created this revision.
aabbaabb added reviewers: xazax.hun, phosek.
Herald added subscribers: cfe-commits, rnkovacs, whisperity.
Herald added a project: clang.
aabbaabb requested review of this revision.
Excluded folders in scan build is turned to absolute path before
comapre to 'file' in cdb. 'file' in cdb might be a path relative
to 'directory', so we need to turn it to absolute path before
comparison.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90362
Files:
clang/tools/scan-build-py/libscanbuild/analyze.py
Index: clang/tools/scan-build-py/libscanbuild/analyze.py
===================================================================
--- clang/tools/scan-build-py/libscanbuild/analyze.py
+++ clang/tools/scan-build-py/libscanbuild/analyze.py
@@ -207,10 +207,14 @@
def run_analyzer_parallel(args):
""" Runs the analyzer against the given compilation database. """
- def exclude(filename):
+ def exclude(filename, directory):
""" Return true when any excluded directory prefix the filename. """
- return any(re.match(r'^' + directory, filename)
- for directory in args.excludes)
+ if not os.path.isabs(filename):
+ # filename is either absolute or relative to directory. Need to turn
+ # it to absolute since 'args.excludes' are absolute paths.
+ filename = os.path.normpath(os.path.join(directory, filename))
+ return any(re.match(r'^' + exclude_directory, filename)
+ for exclude_directory in args.excludes)
consts = {
'clang': args.clang,
@@ -225,7 +229,8 @@
logging.debug('run analyzer against compilation database')
with open(args.cdb, 'r') as handle:
generator = (dict(cmd, **consts)
- for cmd in json.load(handle) if not exclude(cmd['file']))
+ for cmd in json.load(handle) if not exclude(
+ cmd['file'], cmd['directory']))
# when verbose output requested execute sequentially
pool = multiprocessing.Pool(1 if args.verbose > 2 else None)
for current in pool.imap_unordered(run, generator):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90362.301502.patch
Type: text/x-patch
Size: 1628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201029/39f21e05/attachment.bin>
More information about the cfe-commits
mailing list