ObjectiveC ARC. objc_bridge attribute should be applied to
toll-free bridging cf types only. // rdar//15454846 wip.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194640 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 46a85c5..30ddd4d 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -207,10 +207,9 @@
   return RD->getIdentifier() == &Ctx.Idents.get("__CFString");
 }
 
-static inline bool isCFRefType(TypedefNameDecl *TD, ASTContext &Ctx) {
+static inline bool isTollFreeBridgeCFRefType(TypedefNameDecl *TD, ASTContext &Ctx) {
   StringRef TDName = TD->getIdentifier()->getName();
-  return ((TDName.startswith("CF") || TDName.startswith("CG")) &&
-          (TDName.rfind("Ref") != StringRef::npos));
+  return (TDName.startswith("CF") && TDName.endswith("Ref"));
 }
 
 static unsigned getNumAttributeArgs(const AttributeList &Attr) {
@@ -4414,7 +4413,7 @@
       return;
     }
     // Check for T being a CFType goes here.
-    if (!isCFRefType(TD, S.Context)) {
+    if (!isTollFreeBridgeCFRefType(TD, S.Context)) {
       S.Diag(TD->getLocStart(), diag::err_objc_bridge_not_cftype);
       return;
     }