summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2016-05-31 18:19:32 +0000
committerManman Ren <manman.ren@gmail.com>2016-05-31 18:19:32 +0000
commit33d80295891fca25ceca3397a70d423cd03b1337 (patch)
tree38dbc85a63caf13da54df3458e2ada7c57cbbd19 /clang/test/Modules
parent3b3f490f9c5706bb4d216068283f78694826100b (diff)
downloadbcm5719-llvm-33d80295891fca25ceca3397a70d423cd03b1337.tar.gz
bcm5719-llvm-33d80295891fca25ceca3397a70d423cd03b1337.zip
PCH + module: make sure we write out macros associated with builtin identifiers.
When we import a module that defines a builtin identifier from prefix header and precompile the prefix header, the macro information related to the identifier is lost. If we don't precompile the prefix header, the source file can still see the macro information. The reason is that we write out the identifier in the pch but not the macro information since the macro is not defined locally. This is related to r251565. In that commit, if we read a builtin identifier from a module that wasn't "interesting" to that module, we will still write it out to a PCH that imports that module. The fix is to write exported module macros for PCH as well. rdar://24666630 Differential Revision: http://reviews.llvm.org/D20383 llvm-svn: 271310
Diffstat (limited to 'clang/test/Modules')
-rw-r--r--clang/test/Modules/Inputs/MacroFabs1.h6
-rw-r--r--clang/test/Modules/Inputs/module.map4
-rw-r--r--clang/test/Modules/Inputs/pch-import-module-with-macro.pch3
-rw-r--r--clang/test/Modules/pch-module-macro.m9
4 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/MacroFabs1.h b/clang/test/Modules/Inputs/MacroFabs1.h
new file mode 100644
index 00000000000..a78c5539f4a
--- /dev/null
+++ b/clang/test/Modules/Inputs/MacroFabs1.h
@@ -0,0 +1,6 @@
+
+#undef fabs
+#define fabs(x) (x)
+
+#undef my_fabs
+#define my_fabs(x) (x)
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
index 4db1cca925c..6846690c849 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -414,3 +414,7 @@ module MethodPoolString2 {
}
module Empty {}
+
+module MacroFabs1 {
+ header "MacroFabs1.h"
+}
diff --git a/clang/test/Modules/Inputs/pch-import-module-with-macro.pch b/clang/test/Modules/Inputs/pch-import-module-with-macro.pch
new file mode 100644
index 00000000000..c06d7728b62
--- /dev/null
+++ b/clang/test/Modules/Inputs/pch-import-module-with-macro.pch
@@ -0,0 +1,3 @@
+
+@import MacroFabs1;
+
diff --git a/clang/test/Modules/pch-module-macro.m b/clang/test/Modules/pch-module-macro.m
new file mode 100644
index 00000000000..cc9f6873745
--- /dev/null
+++ b/clang/test/Modules/pch-module-macro.m
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-with-macro.pch
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify
+// expected-no-diagnostics
+
+int test(int x) {
+ return my_fabs(x) + fabs(x);
+}
+
OpenPOWER on IntegriCloud