summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2016-11-07 20:42:25 +0000
committerSean Callanan <scallanan@apple.com>2016-11-07 20:42:25 +0000
commit24c5fe6b343eaf2d1261786f573fd3d866b15ef9 (patch)
treeaf16e9795b1e8de3dbaf7b00209313a015b52941 /clang/test
parent5caae908b71c9a4f94a96e336b674f07598fe525 (diff)
downloadbcm5719-llvm-24c5fe6b343eaf2d1261786f573fd3d866b15ef9.tar.gz
bcm5719-llvm-24c5fe6b343eaf2d1261786f573fd3d866b15ef9.zip
When the ASTImporter imports a source location, it avoids importing macro
expansions by calling getSpellingLoc(). That's great in most cases, but for macros defined in the '<built-in>' source file, the source file is invalid and does not import correctly, causing an assertion failure (the assertion is Invalid SLocOffset or bad function choice). A more reliable way to avoid this is to use getFileLoc(), which does not return built-in locations. This avoids the crash but still preserves valid source locations. I've added a testcase that covers the previously crashing scenario. https://reviews.llvm.org/D26054 llvm-svn: 286144
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/ASTMerge/Inputs/macro.modulemap4
-rw-r--r--clang/test/ASTMerge/Inputs/macro1.h5
-rw-r--r--clang/test/ASTMerge/Inputs/macro1.m5
-rw-r--r--clang/test/ASTMerge/Inputs/macro2.m5
-rw-r--r--clang/test/ASTMerge/macro.m6
5 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/ASTMerge/Inputs/macro.modulemap b/clang/test/ASTMerge/Inputs/macro.modulemap
new file mode 100644
index 00000000000..dba1f2207f1
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/macro.modulemap
@@ -0,0 +1,4 @@
+module macro1 [extern_c] {
+ header "macro1.h"
+ export *
+}
diff --git a/clang/test/ASTMerge/Inputs/macro1.h b/clang/test/ASTMerge/Inputs/macro1.h
new file mode 100644
index 00000000000..f089e612543
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/macro1.h
@@ -0,0 +1,5 @@
+typedef void *VoidRef;
+
+void maybeNull(
+ int i,
+ __nullable VoidRef *__nullable);
diff --git a/clang/test/ASTMerge/Inputs/macro1.m b/clang/test/ASTMerge/Inputs/macro1.m
new file mode 100644
index 00000000000..2612613bd0b
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/macro1.m
@@ -0,0 +1,5 @@
+@import macro1;
+
+void foo() {
+ maybeNull(0, 0);
+}
diff --git a/clang/test/ASTMerge/Inputs/macro2.m b/clang/test/ASTMerge/Inputs/macro2.m
new file mode 100644
index 00000000000..b5b155a95b5
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/macro2.m
@@ -0,0 +1,5 @@
+void foo();
+
+void bar() {
+ foo();
+}
diff --git a/clang/test/ASTMerge/macro.m b/clang/test/ASTMerge/macro.m
new file mode 100644
index 00000000000..77e596d3bae
--- /dev/null
+++ b/clang/test/ASTMerge/macro.m
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/cache
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fmodule-map-file=%S/Inputs/macro.modulemap -I%S/Inputs -emit-pch -o %t.1.ast %S/Inputs/macro1.m
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fmodule-map-file=%S/Inputs/macro.modulemap -I%S/Inputs -emit-pch -o %t.2.ast %S/Inputs/macro2.m
+// RUN: %clang_cc1 -fmodules -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
OpenPOWER on IntegriCloud