]> granicus.if.org Git - clang/commitdiff
Eliminate the uglified keyword __import_module__ for importing
authorDouglas Gregor <dgregor@apple.com>
Tue, 3 Jan 2012 19:32:59 +0000 (19:32 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 3 Jan 2012 19:32:59 +0000 (19:32 +0000)
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

28 files changed:
include/clang/Basic/IdentifierTable.h
include/clang/Basic/TokenKinds.def
include/clang/Lex/Preprocessor.h
include/clang/Sema/Sema.h
lib/Basic/IdentifierTable.cpp
lib/Lex/PPDirectives.cpp
lib/Lex/Preprocessor.cpp
lib/Parse/Parser.cpp
test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
test/Modules/Inputs/diamond.h
test/Modules/Inputs/diamond_bottom.h
test/Modules/Inputs/diamond_left.h
test/Modules/Inputs/diamond_right.h
test/Modules/Inputs/wildcard-submodule-exports/C_one.h
test/Modules/Inputs/wildcard-submodule-exports/C_two.h
test/Modules/cycles.c
test/Modules/diamond-pch.c
test/Modules/diamond.c
test/Modules/irgen.c
test/Modules/load_failure.c
test/Modules/lookup.cpp
test/Modules/macros.c
test/Modules/module-private.cpp
test/Modules/normal-module-map.cpp
test/Modules/submodules-preprocess.cpp
test/Modules/submodules.cpp
test/Modules/wildcard-submodule-exports.cpp

index a5eea3281f179d463c5b581b31d1b28d0e4e734b..c41e6da1a044e95ffd83cf968568d04b7ffcebee 100644 (file)
@@ -69,7 +69,9 @@ class IdentifierInfo {
   bool OutOfDate              : 1; // True if there may be additional
                                    // information about this identifier
                                    // stored externally.
-  // 2 bits left in 32-bit word.
+  bool IsImport               : 1; // True if this is the 'import' contextual
+                                   // keyword.
+  // 1 bit left in 32-bit word.
   
   void *FETokenInfo;               // Managed by the language front-end.
   llvm::StringMapEntry<IdentifierInfo*> *Entry;
@@ -283,6 +285,18 @@ public:
       RecomputeNeedsHandleIdentifier();
   }
   
+  /// \brief Determine whether this is the contextual keyword 'import'.
+  bool isImport() const { return IsImport; }
+  
+  /// \brief Set whether this identifier is the contextual keyword 'import'.
+  void setImport(bool I) {
+    IsImport = I;
+    if (I)
+      NeedsHandleIdentifier = true;
+    else
+      RecomputeNeedsHandleIdentifier();
+  }
+  
 private:
   /// RecomputeNeedsHandleIdentifier - The Preprocessor::HandleIdentifier does
   /// several special (but rare) things to identifiers of various sorts.  For
@@ -295,8 +309,7 @@ private:
     NeedsHandleIdentifier =
       (isPoisoned() | hasMacroDefinition() | isCPlusPlusOperatorKeyword() |
        isExtensionToken() | isCXX11CompatKeyword() || isOutOfDate() ||
-       (getTokenID() == tok::kw___import_module__) ||
-       (getObjCKeywordID() == tok::objc_import));
+       isImport());
   }
 };
 
@@ -447,6 +460,10 @@ public:
     // contents.
     II->Entry = &Entry;
 
+    // If this is the 'import' contextual keyword, mark it as such.
+    if (Name.equals("import"))
+      II->setImport(true);
+
     return *II;
   }
 
@@ -478,6 +495,10 @@ public:
       // Make sure getName() knows how to find the IdentifierInfo
       // contents.
       II->Entry = &Entry;
+      
+      // If this is the 'import' contextual keyword, mark it as such.
+      if (Name.equals("import"))
+        II->setImport(true);
     }
 
     return *II;
index 277ed84ed69a81a8cd07c455680a60332bb22c92..7841c201b87591046cf26dea9c3ec12651d72778 100644 (file)
@@ -405,7 +405,6 @@ KEYWORD(__array_extent              , KEYCXX)
 
 // Apple Extension.
 KEYWORD(__private_extern__          , KEYALL)
-KEYWORD(__import_module__           , KEYALL)
 KEYWORD(__module_private__          , KEYALL)
 
 // Microsoft Extension.
index 53d5f400b358deb60ec97c83075b356bd9956dd2..8c7b0bce3fe2e3170a2b5500b3c110f59fb701e4 100644 (file)
@@ -162,8 +162,8 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
   /// for preprocessing.
   SourceLocation CodeCompletionFileLoc;
 
-  /// \brief The source location of the __import_module__ or 'import' keyword we 
-  /// just lexed, if any.
+  /// \brief The source location of the 'import' contextual keyword we just 
+  /// lexed, if any.
   SourceLocation ModuleImportLoc;
 
   /// \brief The module import path that we're currently processing.
index 2b7c6a78e7fae3a0104458fc6087d792860b14f9..086bf23dab0a77057cd41d04d53cf0315600b00e 100644 (file)
@@ -1120,10 +1120,9 @@ public:
 
   /// \brief The parser has processed a module import declaration.
   ///
-  /// \param AtLoc The location of the '@' symbol, if present.
+  /// \param AtLoc The location of the '@' symbol, if any.
   ///
-  /// \param ImportLoc The location of the '__import_module__' or 'import' 
-  /// keyword.
+  /// \param ImportLoc The location of the 'import' keyword.
   ///
   /// \param Path The module access path.
   DeclResult ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, 
index 4368ff712c4ce6c267d0efef5193d7b509e104b0..3da15bde0e9ecf31048a72ac8cef5ab00dac3308 100644 (file)
@@ -40,6 +40,7 @@ IdentifierInfo::IdentifierInfo() {
   ChangedAfterLoad = false;
   RevertedTokenID = false;
   OutOfDate = false;
+  IsImport = false;
   FETokenInfo = 0;
   Entry = 0;
 }
index 04d92b8a29111efc66c574705301fd1c7977acd7..138e7d98791ac6dbe0f7b3dd08f35f1bb51280c2 100644 (file)
@@ -1378,15 +1378,16 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
     bool BuildingImportedModule
       = Path[0].first->getName() == getLangOptions().CurrentModule;
     
-    if (!BuildingImportedModule) {
+    if (!BuildingImportedModule && getLangOptions().ObjC2) {
       // If we're not building the imported module, warn that we're going
       // to automatically turn this inclusion directive into a module import.
+      // We only do this in Objective-C, where we have a module-import syntax.
       CharSourceRange ReplaceRange(SourceRange(HashLoc, CharEnd), 
                                    /*IsTokenRange=*/false);
       Diag(HashLoc, diag::warn_auto_module_import)
         << IncludeKind << PathString 
         << FixItHint::CreateReplacement(ReplaceRange,
-             "__import_module__ " + PathString.str().str() + ";");
+             "@import " + PathString.str().str() + ";");
     }
     
     // Load the module.
index 8722be93d35b2a7aaafb278ef1277286946f28fa..046b0dfb01ab818e4017bc889dc4c09e4e6d0bb6 100644 (file)
@@ -548,11 +548,9 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
   if (II.isExtensionToken() && !DisableMacroExpansion)
     Diag(Identifier, diag::ext_token_used);
   
-  // If this is the '__import_module__' or 'import' keyword, note that the next 
-  // token indicates a module name.
-  if ((II.getTokenID() == tok::kw___import_module__ ||
-       II.getObjCKeywordID() == tok::objc_import) &&
-      !InMacroArgs && !DisableMacroExpansion) {
+  // If this is the 'import' contextual keyword, note that the next token 
+  // indicates a module name.
+  if (II.isImport() && !InMacroArgs && !DisableMacroExpansion) {
     ModuleImportLoc = Identifier.getLocation();
     ModuleImportPath.clear();
     ModuleImportExpectsIdentifier = true;
@@ -560,7 +558,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
   }
 }
 
-/// \brief Lex a token following the __import_module__ or 'import' keyword.
+/// \brief Lex a token following the 'import' contextual keyword.
 ///
 void Preprocessor::LexAfterModuleImport(Token &Result) {
   // Figure out what kind of lexer we actually have.
@@ -578,14 +576,10 @@ void Preprocessor::LexAfterModuleImport(Token &Result) {
 
   // The token sequence 
   //
-  //   __import_module__ identifier (. identifier)*
-  //
-  // or
-  //
   //   import identifier (. identifier)*
   //
-  // indicates a module import directive. We already saw the __import_module__
-  // or 'import' keyword, so now we're looking for the identifiers.
+  // indicates a module import directive. We already saw the 'import' 
+  // contextual keyword, so now we're looking for the identifiers.
   if (ModuleImportExpectsIdentifier && Result.getKind() == tok::identifier) {
     // We expected to see an identifier here, and we did; continue handling
     // identifiers.
index b96ff388dbccec28243c82e2b7c3b4a840acf173..d14b9adce2cc1991015bd8227520f6b8a4489ac9 100644 (file)
@@ -666,9 +666,6 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
   case tok::kw___if_not_exists:
     ParseMicrosoftIfExistsExternalDeclaration();
     return DeclGroupPtrTy();
-
-  case tok::kw___import_module__:
-    return ParseModuleImport(SourceLocation());
       
   default:
   dont_know:
@@ -1570,8 +1567,7 @@ void Parser::ParseMicrosoftIfExistsExternalDeclaration() {
 }
 
 Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
-  assert((Tok.is(tok::kw___import_module__) || 
-          Tok.isObjCAtKeyword(tok::objc_import)) && 
+  assert(Tok.isObjCAtKeyword(tok::objc_import) && 
          "Improper start to module import");
   SourceLocation ImportLoc = ConsumeToken();
   
index 2a8282cc0119abe9fd071cbee9159d0382d59bc8..156c22604f5ac8b2766742c41f5d8234be8c8c05 100644 (file)
@@ -1,3 +1,3 @@
 
-__import_module__ MutuallyRecursive2;
+@import MutuallyRecursive2;
 
index 98008533f3072345e5f2d4b709cc0747923ad3a2..be3facd70eccb62bdb76f7ad96e83330d617e255 100644 (file)
@@ -1,6 +1,6 @@
 
 
-__import_module__ MutuallyRecursive1;
+@import MutuallyRecursive1;
 
 
 
index 0ae3c4fbcb5dd0faba09e3d421a9845336a74ff4..1990b45b5f856bd06176574638e8aaae9b36f5f3 100644 (file)
@@ -1 +1 @@
-__import_module__ diamond_bottom;
+@import diamond_bottom;
index e0b06d6cd972c232cc0219f8ccbe3ffa97e7d2d1..2a0a84e3d7b3ec44de04b61ae4adcc1f536d917a 100644 (file)
@@ -1,4 +1,4 @@
-__import_module__ diamond_left;
-__import_module__ diamond_right;
+@import diamond_left;
+@import diamond_right;
 
 char bottom(char *x);
index 88cbf60977b3a04cab364c366fdee4e94d2e415c..fce2e48882f8f0acb691ca35262684779d302196 100644 (file)
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@import diamond_top;
 
 float left(float *);
 
index 6f8bb82f8d240a1e10873e45c5caabac588e3470..fa408ea5ba7f1359e2ce7f22765c33a05d0e971a 100644 (file)
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@import diamond_top;
 
 double right(double *);
 
index cbdc2beecc44585982ef873f1a06b1aacd314bf3..e3b7593b80c8c1e9453783b2673e553665fa058c 100644 (file)
@@ -1,4 +1,4 @@
-__import_module__ A.One;
-__import_module__ B.One;
+@import A.One;
+@import B.One;
 
 long *C1;
index 6a66ac78310ff2c12ac8770496fe790a94b3e79d..b65dcf612ebc7b366f1684998fc7856e0c7ca604 100644 (file)
@@ -1,4 +1,4 @@
-__import_module__ A.Two;
-__import_module__ B.Two;
+@import A.Two;
+@import B.Two;
 
 unsigned long *C2;
index 8e3e9c6316175d888feea6951895cff6aebb7e05..df2a0a785df5edca3d82707d850c70e2b602fa33 100644 (file)
@@ -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'
 
index d0f45908cfa51aa0ec1407a752ee5c9559841d21..4397c194c0ec546bbe991f76d6812d6481e97d0d 100644 (file)
@@ -19,9 +19,10 @@ void test_diamond(int i, float f, double d, char c) {
 }
 
 // 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.
index 59181c533d48f7c4431af6f7a81f17af4d8a5180..1d8902101ee4b615bf39a9db7f519cae7c23032b 100644 (file)
@@ -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 @@ void test_diamond(int i, float f, double d, char c) {
 }
 
 // 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.
index a3d5aa0534c5648864056c3758d5c439fe33bda8..8f4c299a7efbc02b185bd5855589a33ce28d3939 100644 (file)
@@ -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) {
index e278eb5aff8fd45969c6599774ab7cfb9d31cd5a..bc0b42631598d976bf0e06e922b3a0e1eb919774 100644 (file)
@@ -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 -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.
 
 
index 2bb53da66f14edf7d7ab6d3750ff4b0c52d0c91a..5e84532e60ff5652d264a7759ca954c80fda1518 100644 (file)
@@ -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 @@ void test(int i, float f) {
 }
 
 // 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 *);
index 460c482ef9cfdd1947bb12ed301e0e61caca6e5a..3fddcc7ff5d671601e625ee9b63f68c271b31b5d 100644 (file)
@@ -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
index bdfa2682ce1e02381c01dbc1a5e97caef6decc23..e972ce2891c0c64c116eae39af9e4589285a6fdd 100644 (file)
@@ -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
index 4d2f59a7ca829eeb201bde0bcf33924e8032478a..2858dabae15572dc0051be392b622f95fda9e363 100644 (file)
@@ -8,7 +8,7 @@ int getUmbrella() {
   return umbrella + umbrella_sub; 
 }
 
-__import_module__ Umbrella2;
+@import Umbrella2;
 
 #include "a1.h"
 #include "b1.h"
@@ -18,7 +18,7 @@ int test() {
   return a1 + b1 + nested2;
 }
 
-__import_module__ nested_umbrella.a;
+@import nested_umbrella.a;
 
 int testNestedUmbrellaA() {
   return nested_umbrella_a;
@@ -28,7 +28,7 @@ int testNestedUmbrellaBFail() {
   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;
index b819d40f25a1a04f90bf06b3fada88c888ed0603..7d218b13593e31b3d527ddb2a5bb26680ec54a75 100644 (file)
@@ -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 @@ __import_module__ std.vector;
 #  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 @@ __import_module__ std.typetraits; // expected-error{{no submodule named 'typetra
 #  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 @@ __import_module__ std; // import everything in 'std'
 #  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)
index b62d48719aece213ceb66cdad794286f5a1a923c..1417446416cdc2d91623efc6c3724cc879640009 100644 (file)
@@ -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 @@ vector<int> vi;
 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;
 
index a8da381347c385bb726cc87cd54df37ce0a1e688..00d95716512ce401c3353073871eb8ac23a12a32 100644 (file)
@@ -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 test_C_One() {
   (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 @@ void test_C_Two() {
   unsigned long *C2_ptr = C2;
 }
 
-__import_module__ B.One;
+@import B.One;
 
 void test_B_One() {
   short *B1_ptr = B1;