summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2018-06-21 21:45:24 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2018-06-21 21:45:24 +0000
commitdc3f88ad981061a7b4b2872927fceca9ac336453 (patch)
treeba6540985208d20f00de45f0ca3dd64be09b8150 /clang/test
parent30648ab2333f24e720e9eb5f05f64a8648cd8c16 (diff)
downloadbcm5719-llvm-dc3f88ad981061a7b4b2872927fceca9ac336453.tar.gz
bcm5719-llvm-dc3f88ad981061a7b4b2872927fceca9ac336453.zip
Re-apply: Add python tool to dump and construct header maps
Header maps are binary files used by Xcode, which are used to map header names or paths to other locations. Clang has support for those since its inception, but there's not a lot of header map testing around. Since it's a binary format, testing becomes pretty much brittle and its hard to even know what's inside if you don't have the appropriate tools. Add a python based tool that allows creating and dumping header maps based on a json description of those. While here, rewrite tests to use the tool and remove the binary files from the tree. This tool was initially written by Daniel Dunbar. Thanks to Stella Stamenova for helping make this work on Windows. Differential Revision: https://reviews.llvm.org/D46485 rdar://problem/39994722 llvm-svn: 335295
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CMakeLists.txt1
-rw-r--r--clang/test/Modules/crash-vfs-headermaps.m10
-rw-r--r--clang/test/Preprocessor/Inputs/headermap-rel/foo.hmapbin804 -> 0 bytes
-rw-r--r--clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json6
-rw-r--r--clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmapbin108 -> 0 bytes
-rw-r--r--clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json6
-rw-r--r--clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmapbin102 -> 0 bytes
-rw-r--r--clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json6
-rw-r--r--clang/test/Preprocessor/headermap-rel.c8
-rw-r--r--clang/test/Preprocessor/headermap-rel2.c9
-rw-r--r--clang/test/Preprocessor/nonportable-include-with-hmap.c4
-rw-r--r--clang/test/lit.cfg.py2
12 files changed, 32 insertions, 20 deletions
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 8efe3600c54..8d6db5348e0 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -54,6 +54,7 @@ list(APPEND CLANG_TEST_DEPS
clang-rename
clang-refactor
clang-diff
+ hmaptool
)
if(CLANG_ENABLE_STATIC_ANALYZER)
diff --git a/clang/test/Modules/crash-vfs-headermaps.m b/clang/test/Modules/crash-vfs-headermaps.m
index 4f88f3ba119..c340d268ea9 100644
--- a/clang/test/Modules/crash-vfs-headermaps.m
+++ b/clang/test/Modules/crash-vfs-headermaps.m
@@ -1,15 +1,9 @@
// REQUIRES: crash-recovery, shell, system-darwin
-// This uses a headermap with this entry:
-// Foo.h -> Foo/Foo.h
-
-// Copy out the headermap from test/Preprocessor/Inputs/headermap-rel and avoid
-// adding another binary format to the repository.
-
// RUN: rm -rf %t
-// RUN: mkdir -p %t/m
-// RUN: cp -a %S/../Preprocessor/Inputs/headermap-rel %t/i
+// RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
// RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
+// RUN: '%python' hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap
// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
// RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \
diff --git a/clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap b/clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap
deleted file mode 100644
index 783c64e67bb..00000000000
--- a/clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap
+++ /dev/null
Binary files differ
diff --git a/clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json b/clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
new file mode 100644
index 00000000000..ccfd911f0f7
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
@@ -0,0 +1,6 @@
+{
+ "mappings" :
+ {
+ "Foo.h" : "Foo/Foo.h"
+ }
+}
diff --git a/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap b/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
deleted file mode 100644
index a0770fb2512..00000000000
--- a/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
+++ /dev/null
Binary files differ
diff --git a/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json b/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
new file mode 100644
index 00000000000..e03703b1bb0
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
@@ -0,0 +1,6 @@
+{
+ "mappings" :
+ {
+ "someheader.h" : "Product/someheader.h"
+ }
+}
diff --git a/clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap b/clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
deleted file mode 100644
index 9036f208711..00000000000
--- a/clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
+++ /dev/null
Binary files differ
diff --git a/clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json b/clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
new file mode 100644
index 00000000000..c69f1df7725
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
@@ -0,0 +1,6 @@
+{
+ "mappings" :
+ {
+ "Foo/Foo.h" : "headers/foo/Foo.h"
+ }
+}
diff --git a/clang/test/Preprocessor/headermap-rel.c b/clang/test/Preprocessor/headermap-rel.c
index 38500a70f69..4c67186830f 100644
--- a/clang/test/Preprocessor/headermap-rel.c
+++ b/clang/test/Preprocessor/headermap-rel.c
@@ -1,8 +1,6 @@
-
-// This uses a headermap with this entry:
-// Foo.h -> Foo/Foo.h
-
-// RUN: %clang_cc1 -E %s -o %t.i -I %S/Inputs/headermap-rel/foo.hmap -F %S/Inputs/headermap-rel
+// RUN: rm -f %t.hmap
+// RUN: '%python' hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap
+// RUN: %clang_cc1 -E %s -o %t.i -I %t.hmap -F %S/Inputs/headermap-rel
// RUN: FileCheck %s -input-file %t.i
// CHECK: Foo.h is parsed
diff --git a/clang/test/Preprocessor/headermap-rel2.c b/clang/test/Preprocessor/headermap-rel2.c
index d61f3385b22..af12bf3949b 100644
--- a/clang/test/Preprocessor/headermap-rel2.c
+++ b/clang/test/Preprocessor/headermap-rel2.c
@@ -1,8 +1,7 @@
-// This uses a headermap with this entry:
-// someheader.h -> Product/someheader.h
-
-// RUN: %clang_cc1 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H
-// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> %t.out
+// RUN: rm -f %t.hmap
+// RUN: '%python' hmaptool write %S/Inputs/headermap-rel2/project-headers.hmap.json %t.hmap
+// RUN: %clang_cc1 -v -fsyntax-only %s -iquote %t.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H
+// RUN: %clang_cc1 -fsyntax-only %s -iquote %t.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> %t.out
// RUN: FileCheck %s -input-file %t.out
// CHECK: Product/someheader.h
diff --git a/clang/test/Preprocessor/nonportable-include-with-hmap.c b/clang/test/Preprocessor/nonportable-include-with-hmap.c
index fc958e7e5e3..f2c279f36ce 100644
--- a/clang/test/Preprocessor/nonportable-include-with-hmap.c
+++ b/clang/test/Preprocessor/nonportable-include-with-hmap.c
@@ -1,5 +1,7 @@
+// RUN: rm -f %t.hmap
+// RUN: '%python' hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json %t.hmap
// RUN: %clang_cc1 -Eonly \
-// RUN: -I%S/Inputs/nonportable-hmaps/foo.hmap \
+// RUN: -I%t.hmap \
// RUN: -I%S/Inputs/nonportable-hmaps \
// RUN: %s -verify
//
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index f5cc72bdf51..6fa7ef66fc9 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -58,7 +58,7 @@ tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
tools = [
'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'clang-tblgen',
- 'opt',
+ 'opt', 'hmaptool',
ToolSubst('%clang_func_map', command=FindTool(
'clang-func-mapping'), unresolved='ignore'),
]
OpenPOWER on IntegriCloud