[cfe-commits] r158860 - in /cfe/trunk: include/clang/Basic/ObjCRuntime.h lib/AST/DeclBase.cpp lib/Basic/ObjCRuntime.cpp lib/Lex/PPMacroExpansion.cpp

John McCall rjmccall at apple.com
Wed Jun 20 14:58:03 PDT 2012


Author: rjmccall
Date: Wed Jun 20 16:58:02 2012
New Revision: 158860

URL: http://llvm.org/viewvc/llvm-project?rev=158860&view=rev
Log:
Introduce ObjCRuntime::hasWeakClassImport() and use it in the appropriate
places.  I've turned this off for the GNU runtimes --- I don't know if
they support weak class import, but it's easy enough for them to opt in.

Also tweak a comment per review by Jordan.

Modified:
    cfe/trunk/include/clang/Basic/ObjCRuntime.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/Basic/ObjCRuntime.cpp
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/include/clang/Basic/ObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ObjCRuntime.h?rev=158860&r1=158859&r2=158860&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/ObjCRuntime.h (original)
+++ cfe/trunk/include/clang/Basic/ObjCRuntime.h Wed Jun 20 16:58:02 2012
@@ -160,6 +160,18 @@
     llvm_unreachable("bad kind");
   }
 
+  /// Does this runtime support weakly importing classes?
+  bool hasWeakClassImport() const {
+    switch (getKind()) {
+    case MacOSX: return true;
+    case iOS: return true;
+    case FragileMacOSX: return false;
+    case FragileGNU: return false;
+    case GNU: return false;
+    }
+    llvm_unreachable("bad kind");
+  }
+
   /// Try to parse an Objective-C runtime specification from the given string.
   ///
   /// Return true on error.

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=158860&r1=158859&r2=158860&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Jun 20 16:58:02 2012
@@ -430,7 +430,7 @@
 
   // Objective-C classes, if this is the non-fragile runtime.
   } else if (isa<ObjCInterfaceDecl>(this) &&
-             getASTContext().getLangOpts().ObjCRuntime.isNonFragile()) {
+             getASTContext().getLangOpts().ObjCRuntime.hasWeakClassImport()) {
     return true;
 
   // Nothing else.

Modified: cfe/trunk/lib/Basic/ObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/ObjCRuntime.cpp?rev=158860&r1=158859&r2=158860&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/ObjCRuntime.cpp (original)
+++ cfe/trunk/lib/Basic/ObjCRuntime.cpp Wed Jun 20 16:58:02 2012
@@ -43,8 +43,9 @@
   // Look for the last dash.
   std::size_t dash = input.rfind('-');
 
-  // We permit (1) dashes in the runtime name and (2) the version to
-  // be omitted, so ignore dashes that aren't followed by a digit.
+  // We permit dashes in the runtime name, and we also permit the
+  // version to be omitted, so if we see a dash not followed by a
+  // digit then we need to ignore it.
   if (dash != StringRef::npos && dash + 1 != input.size() &&
       (input[dash+1] < '0' || input[dash+1] > '9')) {
     dash = StringRef::npos;

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=158860&r1=158859&r2=158860&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Jun 20 16:58:02 2012
@@ -644,7 +644,7 @@
            .Case("objc_instancetype", LangOpts.ObjC2)
            .Case("objc_modules", LangOpts.ObjC2 && LangOpts.Modules)
            .Case("objc_nonfragile_abi", LangOpts.ObjCRuntime.isNonFragile())
-           .Case("objc_weak_class", LangOpts.ObjCRuntime.isNonFragile())
+           .Case("objc_weak_class", LangOpts.ObjCRuntime.hasWeakClassImport())
            .Case("ownership_holds", true)
            .Case("ownership_returns", true)
            .Case("ownership_takes", true)





More information about the cfe-commits mailing list