Eliminate the uglified keyword __import_module__ for importing
modules. This leaves us without an explicit syntax for importing
modules in C/C++, because such a syntax needs to be discussed
first. In Objective-C/Objective-C++, the @import syntax is used to
import modules.

Note that, under -fmodules, C/C++ programs can import modules via the
#include mechanism when a module map is in place for that header. This
allows us to work with modules in C/C++ without committing to a syntax.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147467 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
index 2a8282c..156c226 100644
--- a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
+++ b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
@@ -1,3 +1,3 @@
 
-__import_module__ MutuallyRecursive2;
+@import MutuallyRecursive2;
 
diff --git a/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h b/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
index 9800853..be3facd 100644
--- a/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
+++ b/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
@@ -1,6 +1,6 @@
 
 
-__import_module__ MutuallyRecursive1;
+@import MutuallyRecursive1;
 
 
 
diff --git a/test/Modules/Inputs/diamond.h b/test/Modules/Inputs/diamond.h
index 0ae3c4f..1990b45 100644
--- a/test/Modules/Inputs/diamond.h
+++ b/test/Modules/Inputs/diamond.h
@@ -1 +1 @@
-__import_module__ diamond_bottom;
+@import diamond_bottom;
diff --git a/test/Modules/Inputs/diamond_bottom.h b/test/Modules/Inputs/diamond_bottom.h
index e0b06d6..2a0a84e 100644
--- a/test/Modules/Inputs/diamond_bottom.h
+++ b/test/Modules/Inputs/diamond_bottom.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_left;
-__import_module__ diamond_right;
+@import diamond_left;
+@import diamond_right;
 
 char bottom(char *x);
diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h
index 88cbf60..fce2e48 100644
--- a/test/Modules/Inputs/diamond_left.h
+++ b/test/Modules/Inputs/diamond_left.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@import diamond_top;
 
 float left(float *);
 
diff --git a/test/Modules/Inputs/diamond_right.h b/test/Modules/Inputs/diamond_right.h
index 6f8bb82..fa408ea 100644
--- a/test/Modules/Inputs/diamond_right.h
+++ b/test/Modules/Inputs/diamond_right.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@import diamond_top;
 
 double right(double *);
 
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/C_one.h b/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
index cbdc2be..e3b7593 100644
--- a/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
+++ b/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
@@ -1,4 +1,4 @@
-__import_module__ A.One;
-__import_module__ B.One;
+@import A.One;
+@import B.One;
 
 long *C1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/C_two.h b/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
index 6a66ac7..b65dcf6 100644
--- a/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
+++ b/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
@@ -1,4 +1,4 @@
-__import_module__ A.Two;
-__import_module__ B.Two;
+@import A.Two;
+@import B.Two;
 
 unsigned long *C2;
diff --git a/test/Modules/cycles.c b/test/Modules/cycles.c
index 8e3e9c6..df2a0a7 100644
--- a/test/Modules/cycles.c
+++ b/test/Modules/cycles.c
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
-
-__import_module__ MutuallyRecursive1;
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
+@import MutuallyRecursive1;
 
 // FIXME: Lots of redundant diagnostics here, because the preprocessor
 // can't currently tell the parser not to try to load the module again.
 
-// CHECK: MutuallyRecursive2.h:3:19: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
-// CHECK: MutuallyRecursive1.h:2:19: fatal error: could not build module 'MutuallyRecursive2'
-// CHECK: cycles.c:4:19: fatal error: could not build module 'MutuallyRecursive1'
+// CHECK: MutuallyRecursive2.h:3:9: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
+// CHECK: MutuallyRecursive1.h:2:9: fatal error: could not build module 'MutuallyRecursive2'
+// CHECK: cycles.c:4:9: fatal error: could not build module 'MutuallyRecursive1'
 
diff --git a/test/Modules/diamond-pch.c b/test/Modules/diamond-pch.c
index d0f4590..4397c19 100644
--- a/test/Modules/diamond-pch.c
+++ b/test/Modules/diamond-pch.c
@@ -19,9 +19,10 @@
 }
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-pch -fmodule-cache-path %t -o %t.pch %S/Inputs/diamond.h
-// RUN: %clang_cc1 -fmodule-cache-path %t -include-pch %t.pch %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodule-cache-path %t -o %t.pch %S/Inputs/diamond.h
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -include-pch %t.pch %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c
index 59181c5..1d89021 100644
--- a/test/Modules/diamond.c
+++ b/test/Modules/diamond.c
@@ -3,7 +3,7 @@
 
 // in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
 
-__import_module__ diamond_bottom;
+@import diamond_bottom;
 
 void test_diamond(int i, float f, double d, char c) {
   top(&i);
@@ -21,8 +21,9 @@
 }
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c
index a3d5aa0..8f4c299 100644
--- a/test/Modules/irgen.c
+++ b/test/Modules/irgen.c
@@ -1,8 +1,9 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
 
-__import_module__ irgen;
+@import irgen;
 
 // CHECK: define void @triple_value
 void triple_value(int *px) {
diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c
index e278eb5..bc0b426 100644
--- a/test/Modules/load_failure.c
+++ b/test/Modules/load_failure.c
@@ -1,20 +1,21 @@
 #ifdef NONEXISTENT
-__import_module__ load_nonexistent;
+@import load_nonexistent;
 #endif
 
 #ifdef FAILURE
-__import_module__ load_failure;
+@import load_failure;
 #endif
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -x c++ -fmodule-cache-path %t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
-// CHECK-NONEXISTENT: load_failure.c:2:19: fatal error: module 'load_nonexistent' not found
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
+// CHECK-NONEXISTENT: load_failure.c:2:9: fatal error: module 'load_nonexistent' not found
 
-// RUN: not %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -DFAILURE 2> %t.out
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DFAILURE 2> %t.out
 // RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out
 
 // FIXME: Clean up diagnostic text below and give it a location
 // CHECK-FAILURE: error: C99 was disabled in PCH file but is currently enabled
+// FIXME: When we have a syntax for modules in C, use that.
 
 
diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp
index 2bb53da..5e84532 100644
--- a/test/Modules/lookup.cpp
+++ b/test/Modules/lookup.cpp
@@ -1,7 +1,8 @@
 
-#define import __import_module__
+#define import @import
 import lookup_left_cxx;
-#define IMPORT(X) __import_module__ X
+#undef import
+#define IMPORT(X) @import X
 IMPORT(lookup_right_cxx);
 
 void test(int i, float f) {
@@ -15,10 +16,11 @@
 }
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=lookup_left_cxx -x c++ %S/Inputs/module.map -verify
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=lookup_right_cxx -x c++ %S/Inputs/module.map -verify
-// RUN: %clang_cc1 -x c++ -fmodule-cache-path %t %s -verify
-// RUN: %clang_cc1 -ast-print -x c++ -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_left_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_right_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// FIXME: When we have a syntax for modules in C++, use that.
 
 // CHECK-PRINT: int *f0(int *);
 // CHECK-PRINT: float *f0(float *);
diff --git a/test/Modules/macros.c b/test/Modules/macros.c
index 460c482..3fddcc7 100644
--- a/test/Modules/macros.c
+++ b/test/Modules/macros.c
@@ -1,9 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -verify -fmodule-cache-path %t %s
-// RUN: %clang_cc1 -E -fmodules -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodule-cache-path %t %s
+// RUN: %clang_cc1 -E -fmodules -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// FIXME: When we have a syntax for modules in C, use that.
 
-__import_module__ macros;
+@import macros;
 
 #ifndef INTEGER
 #  error INTEGER macro should be visible
diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp
index bdfa268..e972ce2 100644
--- a/test/Modules/module-private.cpp
+++ b/test/Modules/module-private.cpp
@@ -1,10 +1,11 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -fmodule-name=module_private_left -x c++ -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -fmodule-name=module_private_right -x c++ -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
 
-__import_module__ module_private_left;
-__import_module__ module_private_right;
+@import module_private_left;
+@import module_private_right;
 
 void test() {
   int &ir = f0(1.0); // okay: f0() from 'right' is not visible
diff --git a/test/Modules/normal-module-map.cpp b/test/Modules/normal-module-map.cpp
index 4d2f59a..2858dab 100644
--- a/test/Modules/normal-module-map.cpp
+++ b/test/Modules/normal-module-map.cpp
@@ -8,7 +8,7 @@
   return umbrella + umbrella_sub; 
 }
 
-__import_module__ Umbrella2;
+@import Umbrella2;
 
 #include "a1.h"
 #include "b1.h"
@@ -18,7 +18,7 @@
   return a1 + b1 + nested2;
 }
 
-__import_module__ nested_umbrella.a;
+@import nested_umbrella.a;
 
 int testNestedUmbrellaA() {
   return nested_umbrella_a;
@@ -28,7 +28,7 @@
   return nested_umbrella_b; // expected-error{{use of undeclared identifier 'nested_umbrella_b'; did you mean 'nested_umbrella_a'?}}
 }
 
-__import_module__ nested_umbrella.b;
+@import nested_umbrella.b;
 
 int testNestedUmbrellaB() {
   return nested_umbrella_b;
diff --git a/test/Modules/submodules-preprocess.cpp b/test/Modules/submodules-preprocess.cpp
index b819d40..7d218b1 100644
--- a/test/Modules/submodules-preprocess.cpp
+++ b/test/Modules/submodules-preprocess.cpp
@@ -1,7 +1,8 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -Eonly -fmodule-cache-path %t -fmodules -I %S/Inputs/submodules %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -Eonly -fmodule-cache-path %t -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
 
-__import_module__ std.vector;
+@import std.vector;
 
 #ifndef HAVE_VECTOR
 #  error HAVE_VECTOR macro is not available (but should be)
@@ -15,7 +16,7 @@
 #  error HAVE_HASH_MAP macro is available (but shouldn't be)
 #endif
 
-__import_module__ std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+@import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
 
 #ifndef HAVE_VECTOR
 #  error HAVE_VECTOR macro is not available (but should be)
@@ -29,9 +30,9 @@
 #  error HAVE_HASH_MAP macro is available (but shouldn't be)
 #endif
 
-__import_module__ std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+@import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
 
-__import_module__ std; // import everything in 'std'
+@import std; // import everything in 'std'
 
 #ifndef HAVE_VECTOR
 #  error HAVE_VECTOR macro is not available (but should be)
@@ -45,7 +46,7 @@
 #  error HAVE_HASH_MAP macro is available (but shouldn't be)
 #endif
 
-__import_module__ std.hash_map;
+@import std.hash_map;
 
 #ifndef HAVE_VECTOR
 #  error HAVE_VECTOR macro is not available (but should be)
diff --git a/test/Modules/submodules.cpp b/test/Modules/submodules.cpp
index b62d487..1417446 100644
--- a/test/Modules/submodules.cpp
+++ b/test/Modules/submodules.cpp
@@ -1,7 +1,8 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs/submodules %s -verify
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
 
-__import_module__ std.vector;
+@import std.vector;
 
 vector<int> vi;
 
@@ -9,20 +10,20 @@
 remove_reference<int&>::type *int_ptr = 0; // expected-error{{unknown type name 'remove_reference'}} \
 // expected-error{{expected unqualified-id}}
 
-__import_module__ std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+@import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
 
 vector<float> vf;
 remove_reference<int&>::type *int_ptr2 = 0;
 
-__import_module__ std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+@import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
 
-__import_module__ std; // import everything in 'std'
+@import std; // import everything in 'std'
 
 // hash_map still isn't available.
 hash_map<int, float> ints_to_floats; // expected-error{{unknown type name 'hash_map'}} \
 // expected-error{{expected unqualified-id}}
 
-__import_module__ std.hash_map;
+@import std.hash_map;
 
 hash_map<int, float> ints_to_floats2;
 
diff --git a/test/Modules/wildcard-submodule-exports.cpp b/test/Modules/wildcard-submodule-exports.cpp
index a8da381..00d9571 100644
--- a/test/Modules/wildcard-submodule-exports.cpp
+++ b/test/Modules/wildcard-submodule-exports.cpp
@@ -1,7 +1,8 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs/wildcard-submodule-exports %s -verify
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/wildcard-submodule-exports %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
 
-__import_module__ C.One;
+@import C.One;
 
 void test_C_One() {
   int *A1_ptr = A1;
@@ -9,7 +10,7 @@
   (void)B1; // expected-error{{use of undeclared identifier 'B1'}}
 }
 
-__import_module__ C.Two;
+@import C.Two;
 
 void test_C_Two() {
   unsigned int *A2_ptr = A2;
@@ -17,7 +18,7 @@
   unsigned long *C2_ptr = C2;
 }
 
-__import_module__ B.One;
+@import B.One;
 
 void test_B_One() {
   short *B1_ptr = B1;