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

Daniel Marjamäki via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 03:47:55 PDT 2017


danielmarjamaki added inline comments.


================
Comment at: tools/scan-build-py/libscanbuild/analyze.py:165
+            with open(filename, 'r') as in_file:
+                for line in in_file:
+                    yield line
----------------
I believe you can write:

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


================
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:
----------------
this 'with' seems redundant. I suggest an assignment and then less indentation will be needed below


================
Comment at: tools/scan-build-py/libscanbuild/analyze.py:223
+    ctu_config = get_ctu_config(args)
+    if ctu_config.collect:
+        shutil.rmtree(ctu_config.dir, ignore_errors=True)
----------------
not a big deal but I would use early exits in this function


================
Comment at: tools/scan-build-py/libscanbuild/clang.py:177
+    arch = ""
+    i = 0
+    while i < len(cmd) and cmd[i] != "-triple":
----------------
I am guessing that you can use cmd.find() instead of the loop


https://reviews.llvm.org/D30691





More information about the cfe-commits mailing list