]> granicus.if.org Git - clang/commitdiff
Switch __import__ over to __import_module__, so we don't conflict with
authorDouglas Gregor <dgregor@apple.com>
Wed, 31 Aug 2011 18:19:09 +0000 (18:19 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 31 Aug 2011 18:19:09 +0000 (18:19 +0000)
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

13 files changed:
include/clang/Basic/DiagnosticParseKinds.td
include/clang/Basic/TokenKinds.def
include/clang/Lex/Preprocessor.h
include/clang/Sema/Sema.h
lib/Lex/Preprocessor.cpp
lib/Parse/Parser.cpp
test/Modules/Inputs/diamond_bottom.h
test/Modules/Inputs/diamond_left.h
test/Modules/Inputs/diamond_right.h
test/Modules/diamond.c
test/Modules/load_failure.c
test/Modules/lookup.cpp
test/Modules/lookup.m

index 9a6e7545b4526e394fde348a66f8049d72c354c9..b6039f8e297d2621e6c6cd23afd0c604244de28a 100644 (file)
@@ -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">;
   
index ccc2e612b231e9e5f4d626c6efa0c20b25b4ea92..b5752fe688ac2195fa352df0f48f35715d8acde6 100644 (file)
@@ -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)
index c3557a5e93e1cae3c711fd355a6f53df69bfecb8..f2f3f73b9ba5a1e9fbdb9c94379279d3a86677b3 100644 (file)
@@ -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);
   }
 
index 16411a0fe6aae9e6f2179017c1016c2a2b193667..e6412d3d451cb402c178178251af5f18e60fe3dd 100644 (file)
@@ -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.
   ///
index 51908bdb8789b8c1ec9a433261729bb432b325dc..65a5b99ca12100d314034d19ca92b9e176409d40 100644 (file)
@@ -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) {
index 43e0f034e8297d38c2a27eccdf2976f72f75714b..f1ca3fadefcde8a9278cd328f4e90f2cc7d7b3c3 100644 (file)
@@ -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.
index 6351d028fbc0f804d478e06d4b11a32d1ffb8ea3..e0b06d6cd972c232cc0219f8ccbe3ffa97e7d2d1 100644 (file)
@@ -1,4 +1,4 @@
-__import__ diamond_left;
-__import__ diamond_right;
+__import_module__ diamond_left;
+__import_module__ diamond_right;
 
 char bottom(char *x);
index 8da494cccad1a16e86c9c004e0564a6c1999a1d1..88cbf60977b3a04cab364c366fdee4e94d2e415c 100644 (file)
@@ -1,4 +1,4 @@
-__import__ diamond_top;
+__import_module__ diamond_top;
 
 float left(float *);
 
index 2efa277b1a915bf82ec63a0904678c11180f6764..6f8bb82f8d240a1e10873e45c5caabac588e3470 100644 (file)
@@ -1,4 +1,4 @@
-__import__ diamond_top;
+__import_module__ diamond_top;
 
 double right(double *);
 
index 94381f2033a5b6fda7af0a368d1e100cff329f70..6f6ff7bf466cfbdd3cca85c6263bffe6ba0cdb48 100644 (file)
@@ -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);
index 5b5df38efed4845fb08366fc9d5ba9aae6ffa0c2..b1f3e0fe799d4edf5e231805c9a7702a04a3b3ab 100644 (file)
@@ -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
index cae66211caf714a298b4d9eec47afdc5160fd7dc..7c53106e8a0fa5f90f5c288eb63e109e85f6d95f 100644 (file)
@@ -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) {
index 48d0ba9a373ae7b6a458820088cf81ba688a181a..02898a5dcfce4def1b8e37d1c64271b1eb1b4e99 100644 (file)
@@ -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}}