]> granicus.if.org Git - clang/commitdiff
Patch to fix a crash trying to access a category name in
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 11 Dec 2009 00:26:36 +0000 (00:26 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 11 Dec 2009 00:26:36 +0000 (00:26 +0000)
objective-c++ mode and also removed dead-code in this area.
(fixes radar 7456710).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91081 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp
lib/Sema/Sema.h
lib/Sema/SemaLookup.cpp
test/Index/complete-objc-message.m
test/SemaObjCXX/category-lookup.mm [new file with mode: 0644]

index 00103ce0f9c02d1c57fc9e8836eca38adfa740af..17f379dace56059b3d18ad2040cdef02755f7020 100644 (file)
@@ -91,7 +91,7 @@ public:
     IDNS_Ordinary = 0x8,
     IDNS_ObjCProtocol = 0x10,
     IDNS_ObjCImplementation = 0x20,
-    IDNS_ObjCCategoryImpl = 0x40,
+    IDNS_ObjCCategoryName = 0x40,
     IDNS_OrdinaryFriend = 0x80,
     IDNS_TagFriend = 0x100,
     IDNS_Using = 0x200
index 2022b4a28cd0cf772dcb85c979b45b4ef0382996..3afb4e44f3eb05c32ebdae56004f983e26659431 100644 (file)
@@ -198,7 +198,6 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
     case NonTypeTemplateParm:
     case ObjCMethod:
     case ObjCContainer:
-    case ObjCCategory:
     case ObjCInterface:
     case ObjCProperty:
     case ObjCCompatibleAlias:
@@ -220,8 +219,9 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
     case ObjCImplementation:
       return IDNS_ObjCImplementation;
 
+    case ObjCCategory:
     case ObjCCategoryImpl:
-      return IDNS_ObjCCategoryImpl;
+      return IDNS_ObjCCategoryName;
 
     case Field:
     case ObjCAtDefsField:
index 7b030cbe93c2352c2cddb0f53e5105673b6fd5c2..88de8da2b381e6919ad1208cdf3d789274ed7613 100644 (file)
@@ -1136,9 +1136,7 @@ public:
     /// Look up the name of an Objective-C protocol.
     LookupObjCProtocolName,
     /// Look up the name of an Objective-C implementation
-    LookupObjCImplementationName,
-    /// Look up the name of an Objective-C category implementation
-    LookupObjCCategoryImplName
+    LookupObjCImplementationName
   };
 
   enum RedeclarationKind {
@@ -1162,7 +1160,6 @@ public:
     case Sema::LookupUsingDeclName:
     case Sema::LookupObjCProtocolName:
     case Sema::LookupObjCImplementationName:
-    case Sema::LookupObjCCategoryImplName:
       return D->isInIdentifierNamespace(IDNS);
 
     case Sema::LookupOperatorName:
@@ -1198,7 +1195,6 @@ public:
                         bool EnteringContext = false);
 
   ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II);
-  ObjCCategoryImplDecl *LookupObjCCategoryImpl(IdentifierInfo *II);
 
   void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
                                     QualType T1, QualType T2,
index 66c846b078fb36484aaa30935b29b2cac10f6ad9..7428e941d5896c7719ea9c40acedce12b9c31ec8 100644 (file)
@@ -234,10 +234,6 @@ getIdentifierNamespacesFromLookupNameKind(Sema::LookupNameKind NameKind,
   case Sema::LookupObjCImplementationName:
     IDNS = Decl::IDNS_ObjCImplementation;
     break;
-
-  case Sema::LookupObjCCategoryImplName:
-    IDNS = Decl::IDNS_ObjCCategoryImpl;
-    break;
   }
   return IDNS;
 }
@@ -640,9 +636,6 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) {
       IDNS = Decl::IDNS_ObjCImplementation;
       break;
 
-    case Sema::LookupObjCCategoryImplName:
-      IDNS = Decl::IDNS_ObjCCategoryImpl;
-      break;
     }
 
     // Scan up the scope chain looking for a decl that matches this
@@ -942,7 +935,6 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx) {
     case LookupNamespaceName:
     case LookupObjCProtocolName:
     case LookupObjCImplementationName:
-    case LookupObjCCategoryImplName:
       // These lookups will never find a member in a C++ class (or base class).
       return false;
       
@@ -1592,13 +1584,6 @@ ObjCProtocolDecl *Sema::LookupProtocol(IdentifierInfo *II) {
   return cast_or_null<ObjCProtocolDecl>(D);
 }
 
-/// \brief Find the Objective-C category implementation with the given
-/// name, if any.
-ObjCCategoryImplDecl *Sema::LookupObjCCategoryImpl(IdentifierInfo *II) {
-  Decl *D = LookupSingleName(TUScope, II, LookupObjCCategoryImplName);
-  return cast_or_null<ObjCCategoryImplDecl>(D);
-}
-
 void Sema::LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
                                         QualType T1, QualType T2,
                                         FunctionSet &Functions) {
index f5827bbea0ca8995538c86d91f9aa7db1e1101dc..1c03095e2a0186544e7b3b609c200296d8a78f5b 100644 (file)
@@ -137,7 +137,6 @@ void test_overload(Overload *ovl) {
 // CHECK-CCA: {TypedText self}
 // CHECK-CCA: TypedefDecl:{TypedText Class}
 // CHECK-CCA: ObjCInterfaceDecl:{TypedText Foo}
-// CHECK-CCA: ObjCCategoryDecl:{TypedText FooTestCategory}
 // CHECK-CCA: FunctionDecl:{TypedText func}{LeftParen (}{RightParen )}
 // CHECK-CCA: TypedefDecl:{TypedText id}
 // CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass}
diff --git a/test/SemaObjCXX/category-lookup.mm b/test/SemaObjCXX/category-lookup.mm
new file mode 100644 (file)
index 0000000..3335d20
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@interface NSObject @end
+
+@interface NSObject (NSScriptClassDescription)
+@end
+
+void f() {
+  NSScriptClassDescription *f; // expected-error {{use of undeclared identifier 'NSScriptClassDescription'}}
+}