[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 04:19:38 PDT 2017

whisperity added a comment.

The Python code here still uses `mangled name` in their wording. Does this mean this patch is yet to be updated with the USR management in the parent patch?

Comment at: tools/scan-build-py/libscanbuild/analyze.py:165
+            with open(filename, 'r') as in_file:
+                for line in in_file:
+                    yield line
danielmarjamaki wrote:
> I believe you can write:
>     for line in open(filename, 'r'):
Do we want to rely on the interpreter implementation on when the file is closed.


  for line in open(filename, 'r'):

is used, the file handle will be closed based on garbage collection rules. Having this handle disposed after the iteration is true for the stock CPython implementation, but it is still nontheless an implementation specific approach.

Whereas using `with` will explicitly close the file handle on the spot, no matter what.

Comment at: tools/scan-build-py/libscanbuild/analyze.py:172
+        extern_fns_map_file = os.path.join(ctudir, CTU_FUNCTION_MAP_FILENAME)
+        with open(extern_fns_map_file, 'w') as out_file:
+            for mangled_name, ast_file in mangled_ast_pairs:
danielmarjamaki wrote:
> this 'with' seems redundant. I suggest an assignment and then less indentation will be needed below
I don't seem to understand what do you want to assign to what.


More information about the cfe-commits mailing list