[cfe-commits] r97847 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Sema/SemaType.cpp test/SemaObjC/check-dup-objc-decls-1.m

Fariborz Jahanian fjahanian at apple.com
Fri Mar 5 14:42:55 PST 2010


Author: fjahanian
Date: Fri Mar  5 16:42:55 2010
New Revision: 97847

URL: http://llvm.org/viewvc/llvm-project?rev=97847&view=rev
Log:
Patch to build qualifier on objective-c
pointer types. Fixes radar 7626768.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=97847&r1=97846&r2=97847&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Mar  5 16:42:55 2010
@@ -621,7 +621,8 @@
   /// given interface decl and the conforming protocol list.
   QualType getObjCObjectPointerType(QualType OIT,
                                     ObjCProtocolDecl **ProtocolList = 0,
-                                    unsigned NumProtocols = 0);
+                                    unsigned NumProtocols = 0,
+                                    unsigned Quals = 0);
 
   /// getTypeOfType - GCC extension.
   QualType getTypeOfExprType(Expr *e);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=97847&r1=97846&r2=97847&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Mar  5 16:42:55 2010
@@ -2240,14 +2240,16 @@
 /// the given interface decl and the conforming protocol list.
 QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
                                               ObjCProtocolDecl **Protocols,
-                                              unsigned NumProtocols) {
+                                              unsigned NumProtocols,
+                                              unsigned Quals) {
   llvm::FoldingSetNodeID ID;
   ObjCObjectPointerType::Profile(ID, InterfaceT, Protocols, NumProtocols);
+  Qualifiers Qs = Qualifiers::fromCVRMask(Quals);
 
   void *InsertPos = 0;
   if (ObjCObjectPointerType *QT =
               ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
-    return QualType(QT, 0);
+    return getQualifiedType(QualType(QT, 0), Qs);
 
   // Sort the protocol list alphabetically to canonicalize it.
   QualType Canonical;
@@ -2282,7 +2284,7 @@
 
   Types.push_back(QType);
   ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
-  return QualType(QType, 0);
+  return getQualifiedType(QualType(QType, 0), Qs);
 }
 
 /// getObjCInterfaceType - Return the unique reference to the type for the

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=97847&r1=97846&r2=97847&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Mar  5 16:42:55 2010
@@ -1034,7 +1034,8 @@
         const ObjCInterfaceType *OIT = T->getAs<ObjCInterfaceType>();
         T = Context.getObjCObjectPointerType(T,
                                          (ObjCProtocolDecl **)OIT->qual_begin(),
-                                         OIT->getNumProtocols());
+                                         OIT->getNumProtocols(),
+                                         DeclType.Ptr.TypeQuals);
         break;
       }
       T = BuildPointerType(T, DeclType.Ptr.TypeQuals, DeclType.Loc, Name);

Modified: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m?rev=97847&r1=97846&r2=97847&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m (original)
+++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Fri Mar  5 16:42:55 2010
@@ -37,3 +37,8 @@
 
 @interface A(Cat)<P> @end // expected-note {{previous definition is here}}
 @interface A(Cat)<Q> @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}}
+
+// rdar 7626768
+ at class NSString;
+NSString * TestBaz;  // expected-note {{previous definition is here}}
+NSString * const TestBaz;  // expected-error {{redefinition of 'TestBaz' with a different type}}





More information about the cfe-commits mailing list