Switch __import__ over to __import_module__, so we don't conflict with
existing practice with Python extension modules. Not that Python
extension modules should be using a double-underscored identifier
anyway, but...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138870 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index 9a6e754..b6039f8 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -571,7 +571,7 @@
// Modules
def err_module_expected_ident : Error<
- "expected a module name after '__import__'">;
+ "expected a module name after '__import_module__'">;
def err_module_expected_semi : Error<
"expected a semicolon name after module name">;
diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def
index ccc2e61..b5752fe 100644
--- a/include/clang/Basic/TokenKinds.def
+++ b/include/clang/Basic/TokenKinds.def
@@ -397,7 +397,7 @@
// Apple Extension.
KEYWORD(__private_extern__ , KEYALL)
-KEYWORD(__import__ , KEYALL)
+KEYWORD(__import_module__ , KEYALL)
// Microsoft Extension.
KEYWORD(__declspec , KEYALL)
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index c3557a5..f2f3f73 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -554,8 +554,8 @@
CachingLex(Result);
--LexDepth;
- // If we have the __import__ keyword, handle the module import now.
- if (Result.getKind() == tok::kw___import__ && LexDepth == 0)
+ // If we have the __import_module__ keyword, handle the module import now.
+ if (Result.getKind() == tok::kw___import_module__ && LexDepth == 0)
HandleModuleImport(Result);
}
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 16411a0..e6412d3 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -1078,7 +1078,7 @@
/// \brief The parser has processed a module import declaration.
///
- /// \param ImportLoc The location of the '__import__' keyword.
+ /// \param ImportLoc The location of the '__import_module__' keyword.
///
/// \param ModuleName The name of the module.
///
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 51908bd..65a5b99 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -513,7 +513,7 @@
void Preprocessor::HandleModuleImport(Token &Import) {
// The token sequence
//
- // __import__ identifier
+ // __import_module__ identifier
//
// indicates a module import directive. We load the module and then
// leave the token sequence for the parser.
@@ -525,10 +525,10 @@
*ModuleNameTok.getIdentifierInfo(),
ModuleNameTok.getLocation());
- // FIXME: Transmogrify __import__ into some kind of AST-only __import__ that
- // is not recognized by the preprocessor but is recognized by the parser.
- // It would also be useful to stash the ModuleKey somewhere, so we don't try
- // to load the module twice.
+ // FIXME: Transmogrify __import_module__ into some kind of AST-only
+ // __import_module__ that is not recognized by the preprocessor but is
+ // recognized by the parser. It would also be useful to stash the ModuleKey
+ // somewhere, so we don't try to load the module twice.
}
void Preprocessor::AddCommentHandler(CommentHandler *Handler) {
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 43e0f03..f1ca3fa 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -676,7 +676,7 @@
ParseMicrosoftIfExistsExternalDeclaration();
return DeclGroupPtrTy();
- case tok::kw___import__:
+ case tok::kw___import_module__:
return ParseModuleImport();
default:
@@ -1543,7 +1543,8 @@
}
Parser::DeclGroupPtrTy Parser::ParseModuleImport() {
- assert(Tok.is(tok::kw___import__) && "Improper start to module import");
+ assert(Tok.is(tok::kw___import_module__) &&
+ "Improper start to module import");
SourceLocation ImportLoc = ConsumeToken();
// Parse the module name.
diff --git a/test/Modules/Inputs/diamond_bottom.h b/test/Modules/Inputs/diamond_bottom.h
index 6351d02..e0b06d6 100644
--- a/test/Modules/Inputs/diamond_bottom.h
+++ b/test/Modules/Inputs/diamond_bottom.h
@@ -1,4 +1,4 @@
-__import__ diamond_left;
-__import__ diamond_right;
+__import_module__ diamond_left;
+__import_module__ diamond_right;
char bottom(char *x);
diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h
index 8da494c..88cbf60 100644
--- a/test/Modules/Inputs/diamond_left.h
+++ b/test/Modules/Inputs/diamond_left.h
@@ -1,4 +1,4 @@
-__import__ diamond_top;
+__import_module__ diamond_top;
float left(float *);
diff --git a/test/Modules/Inputs/diamond_right.h b/test/Modules/Inputs/diamond_right.h
index 2efa277..6f8bb82 100644
--- a/test/Modules/Inputs/diamond_right.h
+++ b/test/Modules/Inputs/diamond_right.h
@@ -1,4 +1,4 @@
-__import__ diamond_top;
+__import_module__ diamond_top;
double right(double *);
diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c
index 94381f2..6f6ff7b 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__ diamond_bottom;
+__import_module__ diamond_bottom;
void test_diamond(int i, float f, double d, char c) {
top(&i);
diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c
index 5b5df38..b1f3e0f 100644
--- a/test/Modules/load_failure.c
+++ b/test/Modules/load_failure.c
@@ -1,14 +1,14 @@
#ifdef NONEXISTENT
-__import__ load_nonexistent;
+__import_module__ load_nonexistent;
#endif
#ifdef FAILURE
-__import__ load_failure;
+__import_module__ load_failure;
#endif
// RUN: %clang_cc1 -x c++ -emit-module -o %T/load_failure.pcm %S/Inputs/load_failure.h
// RUN: %clang_cc1 -I %T %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
-// CHECK-NONEXISTENT: load_failure.c:2:12: fatal error: module 'load_nonexistent' not found
+// CHECK-NONEXISTENT: load_failure.c:2:19: fatal error: module 'load_nonexistent' not found
// RUN: %clang_cc1 -I %T %s -DFAILURE 2>&1 | FileCheck -check-prefix=CHECK-FAILURE %s
// FIXME: Clean up diagnostic text below and give it a location
diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp
index cae6621..7c53106 100644
--- a/test/Modules/lookup.cpp
+++ b/test/Modules/lookup.cpp
@@ -1,7 +1,7 @@
-#define import __import__
+#define import __import_module__
import lookup_left_cxx;
-#define IMPORT(X) __import__ X
+#define IMPORT(X) __import_module__ X
IMPORT(lookup_right_cxx);
void test(int i, float f) {
diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m
index 48d0ba9..02898a5 100644
--- a/test/Modules/lookup.m
+++ b/test/Modules/lookup.m
@@ -1,8 +1,8 @@
// lookup_left.h: expected-note{{using}}
// lookup_right.h: expected-note{{also found}}
-__import__ lookup_left_objc;
-__import__ lookup_right_objc;
+__import_module__ lookup_left_objc;
+__import_module__ lookup_right_objc;
void test(id x) {
[x method]; // expected-warning{{multiple methods named 'method' found}}