From: Douglas Gregor Date: Tue, 3 Jan 2012 19:32:59 +0000 (+0000) Subject: Eliminate the uglified keyword __import_module__ for importing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c13a34b690d2dc2a03c2fea75a0a1438636c19ce;p=clang 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/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index a5eea3281f..c41e6da1a0 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -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 *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; diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index 277ed84ed6..7841c201b8 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -405,7 +405,6 @@ KEYWORD(__array_extent , KEYCXX) // Apple Extension. KEYWORD(__private_extern__ , KEYALL) -KEYWORD(__import_module__ , KEYALL) KEYWORD(__module_private__ , KEYALL) // Microsoft Extension. diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 53d5f400b3..8c7b0bce3f 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -162,8 +162,8 @@ class Preprocessor : public llvm::RefCountedBase { /// 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. diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 2b7c6a78e7..086bf23dab 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -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, diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 4368ff712c..3da15bde0e 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -40,6 +40,7 @@ IdentifierInfo::IdentifierInfo() { ChangedAfterLoad = false; RevertedTokenID = false; OutOfDate = false; + IsImport = false; FETokenInfo = 0; Entry = 0; } diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 04d92b8a29..138e7d9879 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -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. diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 8722be93d3..046b0dfb01 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -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. diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index b96ff388db..d14b9adce2 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -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(); diff --git a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h index 2a8282cc01..156c22604f 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 98008533f3..be3facd70e 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 0ae3c4fbcb..1990b45b5f 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 e0b06d6cd9..2a0a84e3d7 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 88cbf60977..fce2e48882 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 6f8bb82f8d..fa408ea5ba 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 cbdc2beecc..e3b7593b80 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 6a66ac7831..b65dcf612e 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 8e3e9c6316..df2a0a785d 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 d0f45908cf..4397c194c0 100644 --- a/test/Modules/diamond-pch.c +++ b/test/Modules/diamond-pch.c @@ -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. diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c index 59181c533d..1d8902101e 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 @@ 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. diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c index a3d5aa0534..8f4c299a7e 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 e278eb5aff..bc0b426315 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 2bb53da66f..5e84532e60 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 @@ 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 *); diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 460c482ef9..3fddcc7ff5 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 bdfa2682ce..e972ce2891 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 4d2f59a7ca..2858dabae1 100644 --- a/test/Modules/normal-module-map.cpp +++ b/test/Modules/normal-module-map.cpp @@ -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; diff --git a/test/Modules/submodules-preprocess.cpp b/test/Modules/submodules-preprocess.cpp index b819d40f25..7d218b1359 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 @@ __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) diff --git a/test/Modules/submodules.cpp b/test/Modules/submodules.cpp index b62d48719a..1417446416 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 vi; @@ -9,20 +10,20 @@ vector vi; remove_reference::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 vf; remove_reference::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 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 ints_to_floats2; diff --git a/test/Modules/wildcard-submodule-exports.cpp b/test/Modules/wildcard-submodule-exports.cpp index a8da381347..00d9571651 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 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;