aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-31 18:19:09 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-31 18:19:09 +0000
commit65030af6526748ce11534e92f0ccefc44091ba13 (patch)
treeeeed9bb3744e31b499e15c8169a653f05a1bdc26
parent140ab234c23f392d5422691c5de1ee3c15026def (diff)
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
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td2
-rw-r--r--include/clang/Basic/TokenKinds.def2
-rw-r--r--include/clang/Lex/Preprocessor.h4
-rw-r--r--include/clang/Sema/Sema.h2
-rw-r--r--lib/Lex/Preprocessor.cpp10
-rw-r--r--lib/Parse/Parser.cpp5
-rw-r--r--test/Modules/Inputs/diamond_bottom.h4
-rw-r--r--test/Modules/Inputs/diamond_left.h2
-rw-r--r--test/Modules/Inputs/diamond_right.h2
-rw-r--r--test/Modules/diamond.c2
-rw-r--r--test/Modules/load_failure.c6
-rw-r--r--test/Modules/lookup.cpp4
-rw-r--r--test/Modules/lookup.m4
13 files changed, 25 insertions, 24 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index 9a6e7545b4..b6039f8e29 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -571,7 +571,7 @@ def err_seh___finally_block : Error<
// 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 ccc2e612b2..b5752fe688 100644
--- a/include/clang/Basic/TokenKinds.def
+++ b/include/clang/Basic/TokenKinds.def
@@ -397,7 +397,7 @@ KEYWORD(__array_extent , KEYCXX)
// 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 c3557a5e93..f2f3f73b9b 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -554,8 +554,8 @@ public:
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 16411a0fe6..e6412d3d45 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -1078,7 +1078,7 @@ public:
/// \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 51908bdb87..65a5b99ca1 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -513,7 +513,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
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 @@ void Preprocessor::HandleModuleImport(Token &Import) {
*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 43e0f034e8..f1ca3fadef 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -676,7 +676,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
ParseMicrosoftIfExistsExternalDeclaration();
return DeclGroupPtrTy();
- case tok::kw___import__:
+ case tok::kw___import_module__:
return ParseModuleImport();
default:
@@ -1543,7 +1543,8 @@ void Parser::ParseMicrosoftIfExistsExternalDeclaration() {
}
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 6351d028fb..e0b06d6cd9 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 8da494ccca..88cbf60977 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 2efa277b1a..6f8bb82f8d 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 94381f2033..6f6ff7bf46 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 5b5df38efe..b1f3e0fe79 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 cae66211ca..7c53106e8a 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 48d0ba9a37..02898a5dcf 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}}