[cfe-commits] r140651 - in /cfe/trunk: lib/Frontend/InitPreprocessor.cpp test/SemaObjCXX/arc-libcxx.mm

Douglas Gregor dgregor at apple.com
Tue Sep 27 15:48:19 PDT 2011


Author: dgregor
Date: Tue Sep 27 17:48:19 2011
New Revision: 140651

URL: http://llvm.org/viewvc/llvm-project?rev=140651&view=rev
Log:
Remove the egregious hack that made Objective-C++ ARC work with older
versions of libc++. Newer versions of libc++ know how to deal with ARC
properly. Fixes <rdar://problem/10062179>.

Removed:
    cfe/trunk/test/SemaObjCXX/arc-libcxx.mm
Modified:
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=140651&r1=140650&r2=140651&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Sep 27 17:48:19 2011
@@ -222,72 +222,6 @@
 }
 
 /// \brief Add definitions required for a smooth interaction between
-/// Objective-C++ automatic reference counting and libc++.
-static void AddObjCXXARCLibcxxDefines(const LangOptions &LangOpts, 
-                                      MacroBuilder &Builder) {
-  Builder.defineMacro("_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF");
-  
-  std::string Result;
-  {
-    // Provide overloads of the function std::__1::addressof() that accept
-    // references to lifetime-qualified objects. libc++'s (more general)
-    // std::__1::addressof() template fails to instantiate with such types,
-    // because it attempts to convert the object to a char& before 
-    // dereferencing.
-    llvm::raw_string_ostream Out(Result);
-    
-    Out << "#pragma clang diagnostic push\n"
-        << "#pragma clang diagnostic ignored \"-Wc++0x-extensions\"\n"
-        << "namespace std { inline namespace __1 {\n"
-        << "\n";
-    
-    Out << "template <class _Tp>\n"
-        << "inline __attribute__ ((__visibility__(\"hidden\"), "
-        << "__always_inline__))\n"
-        << "__attribute__((objc_ownership(strong))) _Tp*\n"
-        << "addressof(__attribute__((objc_ownership(strong))) _Tp& __x) {\n"
-        << "  return &__x;\n"
-        << "}\n"
-        << "\n";
-      
-    if (LangOpts.ObjCRuntimeHasWeak) {
-      Out << "template <class _Tp>\n"
-          << "inline __attribute__ ((__visibility__(\"hidden\"),"
-          << "__always_inline__))\n"
-          << "__attribute__((objc_ownership(weak))) _Tp*\n"
-          << "addressof(__attribute__((objc_ownership(weak))) _Tp& __x) {\n"
-          << "  return &__x;\n"
-          << "};\n"
-          << "\n";
-    }
-      
-    Out << "template <class _Tp>\n"
-        << "inline __attribute__ ((__visibility__(\"hidden\"),"
-        << "__always_inline__))\n"
-        << "__attribute__((objc_ownership(autoreleasing))) _Tp*\n"
-        << "addressof(__attribute__((objc_ownership(autoreleasing))) _Tp& __x) "
-        << "{\n"
-        << " return &__x;\n"
-        << "}\n"
-        << "\n";
-    
-    Out << "template <class _Tp>\n"
-        << "inline __attribute__ ((__visibility__(\"hidden\"), "
-        << "__always_inline__))\n"
-        << "__unsafe_unretained _Tp* addressof(__unsafe_unretained _Tp& __x)"
-        << " {\n"
-        << "  return &__x;\n"
-        << "}\n";
-      
-    Out << "\n"
-        << "} }\n"
-        << "#pragma clang diagnostic pop\n"
-        << "\n";    
-  }
-  Builder.append(Result);
-}
-
-/// \brief Add definitions required for a smooth interaction between
 /// Objective-C++ automated reference counting and libstdc++ (4.2).
 static void AddObjCXXARCLibstdcxxDefines(const LangOptions &LangOpts, 
                                          MacroBuilder &Builder) {
@@ -726,10 +660,7 @@
     if (LangOpts.ObjC1 && LangOpts.CPlusPlus && LangOpts.ObjCAutoRefCount) {
       switch (InitOpts.ObjCXXARCStandardLibrary) {
       case ARCXX_nolib:
-        break;
-
-      case ARCXX_libcxx:
-        AddObjCXXARCLibcxxDefines(LangOpts, Builder);
+        case ARCXX_libcxx:
         break;
 
       case ARCXX_libstdcxx:

Removed: cfe/trunk/test/SemaObjCXX/arc-libcxx.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-libcxx.mm?rev=140650&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/arc-libcxx.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-libcxx.mm (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-arc-cxxlib=libc++ -fobjc-nonfragile-abi -fobjc-runtime-has-weak -verify %s
-
- at interface A @end
-
-void f(__strong id &sir, __weak id &wir, __autoreleasing id &air,
-       __unsafe_unretained id &uir) {
-  __strong id *sip = std::addressof(sir);
-  __weak id *wip = std::addressof(wir);
-  __autoreleasing id *aip = std::addressof(air);
-  __unsafe_unretained id *uip = std::addressof(uir);
-}





More information about the cfe-commits mailing list