[ast-dump-tool] fix regression if --empty-implementation but --json-input-path is not
authorNico Weber <thakis@chromium.org>
Mon, 15 Mar 2021 12:44:05 +0000 (08:44 -0400)
committerNico Weber <thakis@chromium.org>
Mon, 15 Mar 2021 12:48:26 +0000 (08:48 -0400)
Looks like this broke in one of the relands of
https://reviews.llvm.org/D93164

clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py

index 054cae6..b4d31d3 100755 (executable)
@@ -156,14 +156,16 @@ def main():
 
     use_empty_implementation = options.empty_implementation
 
-    if not os.path.exists(options.json_input_path):
-      use_empty_implementation = True
+    if (not use_empty_implementation
+            and not os.path.exists(options.json_input_path)):
+        use_empty_implementation = True
 
-    with open(options.json_input_path) as f:
-        jsonData = json.load(f)
+    if not use_empty_implementation:
+        with open(options.json_input_path) as f:
+            jsonData = json.load(f)
 
-    if not 'classesInClade' in jsonData or not jsonData["classesInClade"]:
-      use_empty_implementation = True
+        if not 'classesInClade' in jsonData or not jsonData["classesInClade"]:
+            use_empty_implementation = True
 
     if use_empty_implementation:
         with open(os.path.join(os.getcwd(),