summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/test/AST/gen_ast_dump_json_test.py12
-rw-r--r--clang/test/CMakeLists.txt4
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/test/AST/gen_ast_dump_json_test.py b/clang/test/AST/gen_ast_dump_json_test.py
index f32b69afb03..699aaf04a5b 100644
--- a/clang/test/AST/gen_ast_dump_json_test.py
+++ b/clang/test/AST/gen_ast_dump_json_test.py
@@ -55,11 +55,19 @@ def filter_json(dict_var, filters, out):
for e in v:
if isinstance(e, OrderedDict):
filter_json(e, filters, out)
-
+
+
+def default_clang_path():
+ guessed_clang = os.path.join(os.path.dirname(__file__), "clang")
+ if os.path.isfile(guessed_clang):
+ return guessed_clang
+ return None
+
+
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--clang", help="The clang binary (could be a relative or absolute path)",
- action="store", required=True)
+ action="store", default=default_clang_path())
parser.add_argument("--source", help="the source file. Command used to generate the json will be of the format <clang> -cc1 -ast-dump=json <opts> <source>",
action="store", required=True)
parser.add_argument("--filters", help="comma separated list of AST filters. Ex: --filters=TypedefDecl,BuiltinType",
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5bdbcd9415a..1e545ef0ea9 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -136,6 +136,10 @@ if (CLANG_ENABLE_STATIC_ANALYZER)
endif()
endif()
+# Copy gen_ast_dump_json_test.py to the clang build dir. This allows invoking
+# it without having to pass the --clang= argument
+configure_file(AST/gen_ast_dump_json_test.py ${LLVM_TOOLS_BINARY_DIR}/gen_ast_dump_json_test.py COPYONLY)
+
add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
OpenPOWER on IntegriCloud