[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-11-11 Thread Haowei Wu via Phabricator via cfe-commits
haowei closed this revision.
haowei added a comment.

Landed in 
https://github.com/llvm/llvm-project/commit/d93287cac89fd50a105ac4a59c079884b8e53e49


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-11-02 Thread Yu Shan via Phabricator via cfe-commits
aabbaabb added a comment.

I think there are also some patches that only exist here not on that repo so 
there is no strict upstream/downstream, just two forked versions.
Since in our use case, we would likely use this version instead of the python 
version (easier to update/maintain), I suggest just adding the fix we need here.
For this specific bug, the python version is already fixed in a different way 
by reading the code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D90362#2369394 , @phosek wrote:

> What's the plan regarding updating scan-build-py to match the upstream? It 
> seems like this issue has already been address in the upstream version.

As far as I understand, the author is no longer motivated to contribute to 
LLVM, so I think there are two ways forward:

- Just remove this from the LLVM repo and redirect users to use the GitHub/Pypi 
version, or
- Import the upstream fixes we need ourselves.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-11-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

What's the plan regarding updating scan-build-py to match the upstream? It 
seems like this issue has already been address in the upstream version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-11-02 Thread Yu Shan via Phabricator via cfe-commits
aabbaabb added a comment.

kindly ping for help to submit this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-10-29 Thread Yu Shan via Phabricator via cfe-commits
aabbaabb added a comment.

Gabor or Petr, 
Can any one of you help me commit this change? Not sure if I could commit 
myself.

In D90362#2361400 , @xazax.hun wrote:

> I know that the current situation is a mess, but there is an alternative 
> version of scan-build-py on Github, which is also distributed on pypi. Could 
> you check if that version is also susceptible to this problem and open a pull 
> request for the author in case it is?
>
> The repository is here: https://github.com/rizsotto/scan-build
>
> This would be the best way to ensure the bug is fixed for all the users.

Do you mean pull this change into that repo after this got submitted in trunk? 
Will do!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-10-29 Thread Yu Shan via Phabricator via cfe-commits
aabbaabb added a comment.

Differential Revision: https://reviews.llvm.org/D90362


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-10-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I know that the current situation is a mess, but there is an alternative 
version of scan-build-py on Github, which is also distributed on pypi. Could 
you check if that version is also susceptible to this problem and open a pull 
request for the author in case it is?

The repository is here: https://github.com/rizsotto/scan-build

This would be the best way to ensure the bug is fixed for all the users.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-10-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90362/new/

https://reviews.llvm.org/D90362

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90362: scan-build supprot relative 'file' in cdb.

2020-10-28 Thread Yu Shan via Phabricator via cfe-commits
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):


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):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits