[cfe-commits] r147455 - in /cfe/trunk: include/clang/Basic/ include/clang/Lex/ lib/Basic/ lib/Lex/ lib/Parse/ test/Modules/ test/Modules/Inputs/ test/Modules/Inputs/DependsOnModule.framework/Headers/ test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/ test/Modules/Inputs/Module.framework/Headers/

Douglas Gregor dgregor at apple.com
Tue Jan 3 10:24:15 PST 2012


Author: dgregor
Date: Tue Jan  3 12:24:14 2012
New Revision: 147455

URL: http://llvm.org/viewvc/llvm-project?rev=147455&view=rev
Log:
Under -fmodules, accept #public <macroname> and #private <macroname>
to make a macro public (the default for headers) or private,
respectively.

Modified:
    cfe/trunk/include/clang/Basic/TokenKinds.def
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Basic/IdentifierTable.cpp
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
    cfe/trunk/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
    cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h
    cfe/trunk/test/Modules/Inputs/macros.h
    cfe/trunk/test/Modules/decldef.mm
    cfe/trunk/test/Modules/header-import.m
    cfe/trunk/test/Modules/lookup.m
    cfe/trunk/test/Modules/macros.c
    cfe/trunk/test/Modules/objc-categories.m
    cfe/trunk/test/Modules/on-demand-build-warnings.m
    cfe/trunk/test/Modules/on-demand-build.m
    cfe/trunk/test/Modules/on-demand-macros.m
    cfe/trunk/test/Modules/redeclarations.m

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Jan  3 12:24:14 2012
@@ -90,8 +90,8 @@
 PPKEYWORD(unassert)
 
 // Clang extensions
-PPKEYWORD(__export_macro__)
-PPKEYWORD(__private_macro__)
+PPKEYWORD(public)
+PPKEYWORD(private)
 
 //===----------------------------------------------------------------------===//
 // Language keywords.

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Jan  3 12:24:14 2012
@@ -1197,7 +1197,7 @@
   void HandleDigitDirective(Token &Tok);
   void HandleUserDiagnosticDirective(Token &Tok, bool isWarning);
   void HandleIdentSCCSDirective(Token &Tok);
-  void HandleMacroExportDirective(Token &Tok);
+  void HandleMacroPublicDirective(Token &Tok);
   void HandleMacroPrivateDirective(Token &Tok);
 
   // File inclusion.

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue Jan  3 12:24:14 2012
@@ -216,18 +216,17 @@
   CASE( 6, 'i', 'n', ifndef);
   CASE( 6, 'i', 'p', import);
   CASE( 6, 'p', 'a', pragma);
-
+  CASE( 6, 'p', 'b', public);
+      
   CASE( 7, 'd', 'f', defined);
   CASE( 7, 'i', 'c', include);
+  CASE( 7, 'p', 'i', private);
   CASE( 7, 'w', 'r', warning);
 
   CASE( 8, 'u', 'a', unassert);
   CASE(12, 'i', 'c', include_next);
 
   CASE(16, '_', 'i', __include_macros);
-  CASE(16, '_', 'e', __export_macro__);
-      
-  CASE(17, '_', 'p', __private_macro__);
 #undef CASE
 #undef HASH
   }

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Jan  3 12:24:14 2012
@@ -682,10 +682,15 @@
       //isExtension = true;  // FIXME: implement #unassert
       break;
         
-    case tok::pp___export_macro__:
-      return HandleMacroExportDirective(Result);
-    case tok::pp___private_macro__:
-      return HandleMacroPrivateDirective(Result);
+    case tok::pp_public:
+      if (getLangOptions().Modules)
+        return HandleMacroPublicDirective(Result);
+      break;
+        
+    case tok::pp_private:
+      if (getLangOptions().Modules)
+        return HandleMacroPrivateDirective(Result);
+      break;
     }
     break;
   }
@@ -1038,8 +1043,8 @@
   }
 }
 
-/// \brief Handle a #__export_macro__ directive.
-void Preprocessor::HandleMacroExportDirective(Token &Tok) {
+/// \brief Handle a #public directive.
+void Preprocessor::HandleMacroPublicDirective(Token &Tok) {
   Token MacroNameTok;
   ReadMacroName(MacroNameTok, 2);
   
@@ -1047,8 +1052,8 @@
   if (MacroNameTok.is(tok::eod))
     return;
 
-  // Check to see if this is the last token on the #__export_macro__ line.
-  CheckEndOfDirective("__export_macro__");
+  // Check to see if this is the last token on the #public line.
+  CheckEndOfDirective("public");
 
   // Okay, we finally have a valid identifier to undef.
   MacroInfo *MI = getMacroInfo(MacroNameTok.getIdentifierInfo());
@@ -1069,7 +1074,7 @@
     MI->setChangedAfterLoad();
 }
 
-/// \brief Handle a #__private_macro__ directive.
+/// \brief Handle a #private directive.
 void Preprocessor::HandleMacroPrivateDirective(Token &Tok) {
   Token MacroNameTok;
   ReadMacroName(MacroNameTok, 2);
@@ -1078,8 +1083,8 @@
   if (MacroNameTok.is(tok::eod))
     return;
   
-  // Check to see if this is the last token on the #__private_macro__ line.
-  CheckEndOfDirective("__private_macro__");
+  // Check to see if this is the last token on the #private line.
+  CheckEndOfDirective("private");
   
   // Okay, we finally have a valid identifier to undef.
   MacroInfo *MI = getMacroInfo(MacroNameTok.getIdentifierInfo());

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Jan  3 12:24:14 2012
@@ -67,7 +67,11 @@
     SingleDecl = ParseObjCPropertyDynamic(AtLoc);
     break;
   case tok::objc_import:
-    return ParseModuleImport(AtLoc);
+    if (getLang().Modules)
+      return ParseModuleImport(AtLoc);
+      
+    // Fall through
+      
   default:
     Diag(AtLoc, diag::err_unexpected_at);
     SkipUntil(tok::semi);

Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h (original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h Tue Jan  3 12:24:14 2012
@@ -1,5 +1,5 @@
 #include <Module/Module.h> //expected-warning{{treating #include as an import of module 'Module'}}
 
 #define DEPENDS_ON_MODULE 1
-#__private_macro__ DEPENDS_ON_MODULE
+#private DEPENDS_ON_MODULE
 

Modified: cfe/trunk/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h (original)
+++ cfe/trunk/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h Tue Jan  3 12:24:14 2012
@@ -1,5 +1,5 @@
 #ifndef MODULE_SUBFRAMEWORK_H
 #define MODULE_SUBFRAMEWORK_H
-#__private_macro__ MODULE_SUBFRAMEWORK_H
+#private MODULE_SUBFRAMEWORK_H
 char *module_subframework;
 #endif

Modified: cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h (original)
+++ cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h Tue Jan  3 12:24:14 2012
@@ -14,7 +14,7 @@
 @end
 
 #define MODULE_H_MACRO 1
-#__private_macro__ MODULE_H_MACRO
+#private MODULE_H_MACRO
 
 #include <Module/Sub.h>
 #include <Module/Buried/Treasure.h>

Modified: cfe/trunk/test/Modules/Inputs/macros.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/macros.h?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/macros.h (original)
+++ cfe/trunk/test/Modules/Inputs/macros.h Tue Jan  3 12:24:14 2012
@@ -3,8 +3,8 @@
 #define FLOAT float
 #define DOUBLE double
 
-#__export_macro__ INTEGER
-#__private_macro__ FLOAT
-#__private_macro__ MODULE
+#public INTEGER
+#private FLOAT
+#private MODULE
 
 int (INTEGER);

Modified: cfe/trunk/test/Modules/decldef.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/decldef.mm?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/decldef.mm (original)
+++ cfe/trunk/test/Modules/decldef.mm Tue Jan  3 12:24:14 2012
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I %S/Inputs -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -I %S/Inputs -fmodule-cache-path %t %s -verify
 
 
 // in other file: expected-note{{previous definition is here}}

Modified: cfe/trunk/test/Modules/header-import.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/header-import.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/header-import.m (original)
+++ cfe/trunk/test/Modules/header-import.m Tue Jan  3 12:24:14 2012
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
 
 #import "point.h"
 @import Module;

Modified: cfe/trunk/test/Modules/lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/lookup.m (original)
+++ cfe/trunk/test/Modules/lookup.m Tue Jan  3 12:24:14 2012
@@ -9,10 +9,10 @@
 }
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -verify %s
-// RUN: %clang_cc1 -ast-print -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -verify %s
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
 
 // CHECK-PRINT: - (int) method;
 // CHECK-PRINT: - (double) method

Modified: cfe/trunk/test/Modules/macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/macros.c (original)
+++ cfe/trunk/test/Modules/macros.c Tue Jan  3 12:24:14 2012
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map
-// RUN: %clang_cc1 -verify -fmodule-cache-path %t %s
-// RUN: %clang_cc1 -E -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// 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
 
 __import_module__ macros;
 
@@ -21,7 +21,7 @@
 double d;
 DOUBLE *dp = &d;
 
-#__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE'}}
+#public WIBBLE // expected-error{{no macro named 'WIBBLE'}}
 
 void f() {
   // CHECK-PREPROCESSED: int i = INTEGER;

Modified: cfe/trunk/test/Modules/objc-categories.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-categories.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/objc-categories.m (original)
+++ cfe/trunk/test/Modules/objc-categories.m Tue Jan  3 12:24:14 2012
@@ -1,9 +1,9 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
 
 @import category_bottom;
 

Modified: cfe/trunk/test/Modules/on-demand-build-warnings.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/on-demand-build-warnings.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/on-demand-build-warnings.m (original)
+++ cfe/trunk/test/Modules/on-demand-build-warnings.m Tue Jan  3 12:24:14 2012
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
 
 @import Module; // expected-warning{{building module 'Module' from source}}
 

Modified: cfe/trunk/test/Modules/on-demand-build.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/on-demand-build.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/on-demand-build.m (original)
+++ cfe/trunk/test/Modules/on-demand-build.m Tue Jan  3 12:24:14 2012
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -verify %s
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -verify %s
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -verify %s
 #define FOO
 @import Module;
 @interface OtherClass

Modified: cfe/trunk/test/Modules/on-demand-macros.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/on-demand-macros.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/on-demand-macros.m (original)
+++ cfe/trunk/test/Modules/on-demand-macros.m Tue Jan  3 12:24:14 2012
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -verify %s
 
 @import CmdLine;
 

Modified: cfe/trunk/test/Modules/redeclarations.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/redeclarations.m?rev=147455&r1=147454&r2=147455&view=diff
==============================================================================
--- cfe/trunk/test/Modules/redeclarations.m (original)
+++ cfe/trunk/test/Modules/redeclarations.m Tue Jan  3 12:24:14 2012
@@ -5,7 +5,7 @@
 @end
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
 





More information about the cfe-commits mailing list