diff --git a/clang/test/Modules/Inputs/macros.h b/clang/test/Modules/Inputs/macros.h new file mode 100644 index 000000000000..4be71aaaa0f4 --- /dev/null +++ b/clang/test/Modules/Inputs/macros.h @@ -0,0 +1,10 @@ +#define MODULE +#define INTEGER(X) int +#define FLOAT float +#define DOUBLE double + +#__export_macro__ INTEGER +#__private_macro__ FLOAT +#__private_macro__ MODULE + +int (INTEGER); diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index 67a90ccaade1..13546b08fe61 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -7,3 +7,6 @@ module lookup_left_objc { umbrella "lookup_left.h" } module lookup_right_objc { umbrella "lookup_right.h" } module lookup_left_cxx { umbrella "lookup_left.hpp" } module lookup_right_cxx { umbrella "lookup_right.hpp" } +module module_private_left { umbrella "module_private_left.h" } +module module_private_right { umbrella "module_private_right.h" } +module macros { umbrella "macros.h" } diff --git a/clang/test/Modules/Inputs/module_private_left.h b/clang/test/Modules/Inputs/module_private_left.h new file mode 100644 index 000000000000..617a7abf3d98 --- /dev/null +++ b/clang/test/Modules/Inputs/module_private_left.h @@ -0,0 +1,26 @@ +__module_private__ struct HiddenStruct; + +struct HiddenStruct { +}; + + +int &f0(int); + +template +__module_private__ void f1(T*); + +template +void f1(T*); + +template +__module_private__ class vector; + +template +class vector { +}; + +vector vec_float; + +typedef __module_private__ int Integer; +typedef int Integer; + diff --git a/clang/test/Modules/Inputs/module_private_right.h b/clang/test/Modules/Inputs/module_private_right.h new file mode 100644 index 000000000000..e7c1bb822164 --- /dev/null +++ b/clang/test/Modules/Inputs/module_private_right.h @@ -0,0 +1,13 @@ +__module_private__ double &f0(double); +double &f0(double); + +__module_private__ int hidden_var; + +inline void test_f0_in_right() { + double &dr = f0(hidden_var); +} + +struct VisibleStruct { + __module_private__ int field; + __module_private__ virtual void setField(int f); +}; diff --git a/clang/test/Modules/macros.c b/clang/test/Modules/macros.c index e371237bb011..3eb0dbb3be49 100644 --- a/clang/test/Modules/macros.c +++ b/clang/test/Modules/macros.c @@ -1,19 +1,7 @@ -// RUN: %clang_cc1 -emit-module -o %t/macros.pcm -DMODULE %s -// RUN: %clang_cc1 -verify -fmodule-cache-path %t -fdisable-module-hash %s -// RUN: %clang_cc1 -E -fmodule-cache-path %t -fdisable-module-hash %s | FileCheck -check-prefix CHECK-PREPROCESSED %s - -#if defined(MODULE) -#define INTEGER(X) int -#define FLOAT float -#define DOUBLE double - -#__export_macro__ INTEGER -#__private_macro__ FLOAT -#__private_macro__ MODULE - -int (INTEGER); - -#else +// RUN: rm -rf %t +// RUN: %clang_cc1 -emit-module-from-map -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map +// RUN: %clang_cc1 -verify -fmodule-cache-path %t %s +// RUN: %clang_cc1 -E -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s __import_module__ macros; @@ -39,4 +27,3 @@ void f() { // CHECK-PREPROCESSED: int i = INTEGER; int i = INTEGER; // the value was exported, the macro was not. } -#endif diff --git a/clang/test/Modules/module-private.cpp b/clang/test/Modules/module-private.cpp index 7bd2a205c055..500c58701017 100644 --- a/clang/test/Modules/module-private.cpp +++ b/clang/test/Modules/module-private.cpp @@ -1,54 +1,10 @@ -// RUN: mkdir -p %t -// RUN: %clang_cc1 -x c++ -emit-module -o %t/left.pcm %s -D MODULE_LEFT -// RUN: %clang_cc1 -x c++ -emit-module -o %t/right.pcm %s -D MODULE_RIGHT -// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -verify +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodule-cache-path %t -fmodule-name=module_private_left -x c++ -emit-module-from-map %S/Inputs/module.map +// RUN: %clang_cc1 -fmodule-cache-path %t -fmodule-name=module_private_right -x c++ -emit-module-from-map %S/Inputs/module.map +// RUN: %clang_cc1 -fmodule-cache-path %t %s -verify -#if defined(MODULE_LEFT) - -__module_private__ struct HiddenStruct; - -struct HiddenStruct { -}; - - -int &f0(int); - -template -__module_private__ void f1(T*); - -template -void f1(T*); - -template -__module_private__ class vector; - -template -class vector { -}; - -vector vec_float; - -typedef __module_private__ int Integer; -typedef int Integer; - -#elif defined(MODULE_RIGHT) -__module_private__ double &f0(double); -double &f0(double); - -__module_private__ int hidden_var; - -inline void test_f0_in_right() { - double &dr = f0(hidden_var); -} - -struct VisibleStruct { - __module_private__ int field; - __module_private__ virtual void setField(int f); -}; - -#else -__import_module__ left; -__import_module__ right; +__import_module__ module_private_left; +__import_module__ module_private_right; void test() { int &ir = f0(1.0); // okay: f0() from 'right' is not visible @@ -137,4 +93,3 @@ struct LikeVisibleStruct { }; int check_struct_size[sizeof(VisibleStruct) == sizeof(LikeVisibleStruct)? 1 : -1]; -#endif