Re: r281351 - Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

2016-09-13 Thread Artem Belevich via cfe-commits
Thanks for the quick fix. ASAN is happy now.

--Artem

On Tue, Sep 13, 2016 at 3:09 PM, Manman  wrote:

> I checked in r281404. Hopefully it will fix the issue.
>
> Let me know if it does not.
>
> Thanks,
> Manman
>
> On Sep 13, 2016, at 3:03 PM, Artem Belevich via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Manman,
>
> FYI, It appears that some of your ObjC commits today trigger asan error.
> Sanitizer bots are broken by PR30341, so they don't report the issue yet.
>
> --Artem
>
> $ llvm/tools/clang/clang -cc1 -internal-isystem 
> llvm/tools/clang/staging/include
> -nostdsysteminc -fblocks -fsyntax-only -Wnullable-to-nonnull-conversion
> llvm/tools/clang/test/SemaObjC/parameterized_classes_subst.m -verify
> =
> ==223101==ERROR: AddressSanitizer: use-after-poison on address
> 0x62191288 at pc 0x01a02b3f bp 0x7f2996f0 sp 0x7f2996e8
> WRITE of size 4 at 0x62191288 thread T0
> #0 0x1a02b3e in clang::ObjCTypeParamTypeLoc::
> setProtocolRAngleLoc(clang::SourceLocation) third_party/llvm/llvm/tools/
> clang/include/clang/AST/TypeLoc.h:737:55
> #1 0x213f86b in 
> clang::Sema::actOnObjCTypeArgsAndProtocolQualifiers(clang::Scope*,
> clang::SourceLocation, clang::OpaquePtr,
> clang::SourceLocation, llvm::ArrayRef >, clang::SourceLocation, clang::SourceLocation,
> llvm::ArrayRef, llvm::ArrayRef,
> clang::SourceLocation) third_party/llvm/llvm/tools/
> clang/lib/Sema/SemaType.cpp:1165:13
> #2 0x2060347 in clang::Parser::parseObjCTypeArgsAndProtocolQu
> alifiers(clang::SourceLocation, clang::OpaquePtr, bool,
> clang::SourceLocation&) third_party/llvm/llvm/tools/
> clang/lib/Parse/ParseObjc.cpp:1878:18
> #3 0x1ffca6f in 
> clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool,
> bool, clang::CXXScopeSpec&, bool) third_party/llvm/llvm/tools/
> clang/lib/Parse/Parser.cpp:1770:13
> #4 0x1ffd4fc in clang::Parser::TryAnnotateTypeOrScopeToken(bool,
> bool) third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:1733:10
> #5 0x20df910 in clang::Parser::isTypeSpecifierQualifier()
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseDecl.cpp:4381:9
> #6 0x205ecf5 in clang::Parser::ParseObjCTypeName(clang::ObjCDeclSpec&,
> clang::Declarator::TheContext, clang::ParsedAttributes*)
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1274:7
> #7 0x205c8f9 in clang::Parser::ParseObjCMethodDecl(clang::SourceLocation,
> clang::tok::TokenKind, clang::tok::ObjCKeywordKind, bool)
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1428:22
> #8 0x2058e8b in 
> clang::Parser::ParseObjCInterfaceDeclList(clang::tok::ObjCKeywordKind,
> clang::Decl*) third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:
> 633:11
> #9 0x2053154 in 
> clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation,
> clang::ParsedAttributes&) third_party/llvm/llvm/tools/
> clang/lib/Parse/ParseObjc.cpp:388:3
> #10 0x2051fa9 in clang::Parser::ParseObjCAtDirectives()
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:63:18
> #11 0x1ff7871 in clang::Parser::ParseExternalDeclaration(
> clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*)
> third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:757:12
> #12 0x1ff6c61 in clang::Parser::ParseTopLevelDecl(clang::
> OpaquePtr&) third_party/llvm/llvm/tools/
> clang/lib/Parse/Parser.cpp:628:12
> #13 0x1ff016d in clang::ParseAST(clang::Sema&, bool, bool)
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseAST.cpp:147:18
> #14 0x1ab05d3 in clang::FrontendAction::Execute()
> third_party/llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:458:8
> #15 0x184fbd6 in 
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> third_party/llvm/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:871:11
> #16 0x5c6f47 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
> third_party/llvm/llvm/tools/clang/lib/FrontendTool/
> ExecuteCompilerInvocation.cpp:249:25
> #17 0x5a114d in cc1_main(llvm::ArrayRef, char const*,
> void*) third_party/llvm/llvm/tools/clang/tools/driver/cc1_main.cpp:183:13
> #18 0x5bb3f6 in ExecuteCC1Tool(llvm::ArrayRef,
> llvm::StringRef) third_party/llvm/llvm/tools/
> clang/tools/driver/driver.cpp:299:12
> #19 0x5ba314 in main third_party/llvm/llvm/tools/
> clang/tools/driver/driver.cpp:380:12
>
> 0x62191288 is located 392 bytes inside of 4096-byte region
> [0x62191100,0x62192100)
> allocated by thread T0 here:
> #0 0x58a52c in __interceptor_malloc third_party/llvm/llvm/
> projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64:3
> #1 0x5a5d0b in llvm::MallocAllocator::Allocate(unsigned long,
> unsigned long) third_party/llvm/llvm/include/
> llvm/Support/Allocator.h:95:12
> #2 0x691b67 in llvm::BumpPtrAllocatorImpl 4096ul, 4096ul>::StartNewSlab() third_party/llvm/llvm/include/
> 

Re: r281351 - Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

2016-09-13 Thread Manman via cfe-commits
I checked in r281404. Hopefully it will fix the issue.

Let me know if it does not.

Thanks,
Manman

> On Sep 13, 2016, at 3:03 PM, Artem Belevich via cfe-commits 
>  wrote:
> 
> Manman,
> 
> FYI, It appears that some of your ObjC commits today trigger asan error.
> Sanitizer bots are broken by PR30341, so they don't report the issue yet.
> 
> --Artem
> 
> $ llvm/tools/clang/clang -cc1 -internal-isystem 
> llvm/tools/clang/staging/include -nostdsysteminc -fblocks -fsyntax-only 
> -Wnullable-to-nonnull-conversion 
> llvm/tools/clang/test/SemaObjC/parameterized_classes_subst.m -verify
> =
> ==223101==ERROR: AddressSanitizer: use-after-poison on address 0x62191288 
> at pc 0x01a02b3f bp 0x7f2996f0 sp 0x7f2996e8
> WRITE of size 4 at 0x62191288 thread T0
> #0 0x1a02b3e in 
> clang::ObjCTypeParamTypeLoc::setProtocolRAngleLoc(clang::SourceLocation) 
> third_party/llvm/llvm/tools/clang/include/clang/AST/TypeLoc.h:737:55
> #1 0x213f86b in 
> clang::Sema::actOnObjCTypeArgsAndProtocolQualifiers(clang::Scope*, 
> clang::SourceLocation, clang::OpaquePtr, 
> clang::SourceLocation, llvm::ArrayRef, 
> clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef, 
> llvm::ArrayRef, clang::SourceLocation) 
> third_party/llvm/llvm/tools/clang/lib/Sema/SemaType.cpp:1165:13
> #2 0x2060347 in 
> clang::Parser::parseObjCTypeArgsAndProtocolQualifiers(clang::SourceLocation, 
> clang::OpaquePtr, bool, clang::SourceLocation&) 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1878:18
> #3 0x1ffca6f in 
> clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool, bool, 
> clang::CXXScopeSpec&, bool) 
> third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:1770:13
> #4 0x1ffd4fc in clang::Parser::TryAnnotateTypeOrScopeToken(bool, bool) 
> third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:1733:10
> #5 0x20df910 in clang::Parser::isTypeSpecifierQualifier() 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseDecl.cpp:4381:9
> #6 0x205ecf5 in clang::Parser::ParseObjCTypeName(clang::ObjCDeclSpec&, 
> clang::Declarator::TheContext, clang::ParsedAttributes*) 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1274:7
> #7 0x205c8f9 in clang::Parser::ParseObjCMethodDecl(clang::SourceLocation, 
> clang::tok::TokenKind, clang::tok::ObjCKeywordKind, bool) 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1428:22
> #8 0x2058e8b in 
> clang::Parser::ParseObjCInterfaceDeclList(clang::tok::ObjCKeywordKind, 
> clang::Decl*) third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:633:11
> #9 0x2053154 in 
> clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation, 
> clang::ParsedAttributes&) 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:388:3
> #10 0x2051fa9 in clang::Parser::ParseObjCAtDirectives() 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:63:18
> #11 0x1ff7871 in 
> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
>  clang::ParsingDeclSpec*) 
> third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:757:12
> #12 0x1ff6c61 in 
> clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&) 
> third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:628:12
> #13 0x1ff016d in clang::ParseAST(clang::Sema&, bool, bool) 
> third_party/llvm/llvm/tools/clang/lib/Parse/ParseAST.cpp:147:18
> #14 0x1ab05d3 in clang::FrontendAction::Execute() 
> third_party/llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:458:8
> #15 0x184fbd6 in 
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
> third_party/llvm/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:871:11
> #16 0x5c6f47 in 
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
> third_party/llvm/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:249:25
> #17 0x5a114d in cc1_main(llvm::ArrayRef, char const*, void*) 
> third_party/llvm/llvm/tools/clang/tools/driver/cc1_main.cpp:183:13
> #18 0x5bb3f6 in ExecuteCC1Tool(llvm::ArrayRef, 
> llvm::StringRef) 
> third_party/llvm/llvm/tools/clang/tools/driver/driver.cpp:299:12
> #19 0x5ba314 in main 
> third_party/llvm/llvm/tools/clang/tools/driver/driver.cpp:380:12
> 
> 0x62191288 is located 392 bytes inside of 4096-byte region 
> [0x62191100,0x62192100)
> allocated by thread T0 here:
> #0 0x58a52c in __interceptor_malloc 
> third_party/llvm/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64:3
> #1 0x5a5d0b in llvm::MallocAllocator::Allocate(unsigned long, unsigned 
> long) third_party/llvm/llvm/include/llvm/Support/Allocator.h:95:12
> #2 0x691b67 in llvm::BumpPtrAllocatorImpl 4096ul>::StartNewSlab() 
> third_party/llvm/llvm/include/llvm/Support/Allocator.h:324:31
> #3 0x6916aa in llvm::BumpPtrAllocatorImpl

Re: r281351 - Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

2016-09-13 Thread Artem Belevich via cfe-commits
Manman,

FYI, It appears that some of your ObjC commits today trigger asan error.
Sanitizer bots are broken by PR30341, so they don't report the issue yet.

--Artem

$ llvm/tools/clang/clang -cc1 -internal-isystem
llvm/tools/clang/staging/include -nostdsysteminc -fblocks -fsyntax-only
-Wnullable-to-nonnull-conversion
llvm/tools/clang/test/SemaObjC/parameterized_classes_subst.m -verify
=
==223101==ERROR: AddressSanitizer: use-after-poison on address
0x62191288 at pc 0x01a02b3f bp 0x7f2996f0 sp 0x7f2996e8
WRITE of size 4 at 0x62191288 thread T0
#0 0x1a02b3e in
clang::ObjCTypeParamTypeLoc::setProtocolRAngleLoc(clang::SourceLocation)
third_party/llvm/llvm/tools/clang/include/clang/AST/TypeLoc.h:737:55
#1 0x213f86b in
clang::Sema::actOnObjCTypeArgsAndProtocolQualifiers(clang::Scope*,
clang::SourceLocation, clang::OpaquePtr,
clang::SourceLocation, llvm::ArrayRef,
clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef,
llvm::ArrayRef, clang::SourceLocation)
third_party/llvm/llvm/tools/clang/lib/Sema/SemaType.cpp:1165:13
#2 0x2060347 in
clang::Parser::parseObjCTypeArgsAndProtocolQualifiers(clang::SourceLocation,
clang::OpaquePtr, bool, clang::SourceLocation&)
third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1878:18
#3 0x1ffca6f in
clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool, bool,
clang::CXXScopeSpec&, bool)
third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:1770:13
#4 0x1ffd4fc in clang::Parser::TryAnnotateTypeOrScopeToken(bool, bool)
third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:1733:10
#5 0x20df910 in clang::Parser::isTypeSpecifierQualifier()
third_party/llvm/llvm/tools/clang/lib/Parse/ParseDecl.cpp:4381:9
#6 0x205ecf5 in clang::Parser::ParseObjCTypeName(clang::ObjCDeclSpec&,
clang::Declarator::TheContext, clang::ParsedAttributes*)
third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1274:7
#7 0x205c8f9 in
clang::Parser::ParseObjCMethodDecl(clang::SourceLocation,
clang::tok::TokenKind, clang::tok::ObjCKeywordKind, bool)
third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:1428:22
#8 0x2058e8b in
clang::Parser::ParseObjCInterfaceDeclList(clang::tok::ObjCKeywordKind,
clang::Decl*)
third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:633:11
#9 0x2053154 in
clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation,
clang::ParsedAttributes&)
third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:388:3
#10 0x2051fa9 in clang::Parser::ParseObjCAtDirectives()
third_party/llvm/llvm/tools/clang/lib/Parse/ParseObjc.cpp:63:18
#11 0x1ff7871 in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:757:12
#12 0x1ff6c61 in
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&)
third_party/llvm/llvm/tools/clang/lib/Parse/Parser.cpp:628:12
#13 0x1ff016d in clang::ParseAST(clang::Sema&, bool, bool)
third_party/llvm/llvm/tools/clang/lib/Parse/ParseAST.cpp:147:18
#14 0x1ab05d3 in clang::FrontendAction::Execute()
third_party/llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:458:8
#15 0x184fbd6 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
third_party/llvm/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:871:11
#16 0x5c6f47 in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
third_party/llvm/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:249:25
#17 0x5a114d in cc1_main(llvm::ArrayRef, char const*,
void*) third_party/llvm/llvm/tools/clang/tools/driver/cc1_main.cpp:183:13
#18 0x5bb3f6 in ExecuteCC1Tool(llvm::ArrayRef,
llvm::StringRef)
third_party/llvm/llvm/tools/clang/tools/driver/driver.cpp:299:12
#19 0x5ba314 in main
third_party/llvm/llvm/tools/clang/tools/driver/driver.cpp:380:12

0x62191288 is located 392 bytes inside of 4096-byte region
[0x62191100,0x62192100)
allocated by thread T0 here:
#0 0x58a52c in __interceptor_malloc
third_party/llvm/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64:3
#1 0x5a5d0b in llvm::MallocAllocator::Allocate(unsigned long, unsigned
long) third_party/llvm/llvm/include/llvm/Support/Allocator.h:95:12
#2 0x691b67 in llvm::BumpPtrAllocatorImpl::StartNewSlab()
third_party/llvm/llvm/include/llvm/Support/Allocator.h:324:31
#3 0x6916aa in llvm::BumpPtrAllocatorImpl::Allocate(unsigned long, unsigned long)
third_party/llvm/llvm/include/llvm/Support/Allocator.h:249:5
#4 0x6913d1 in clang::ASTContext::Allocate(unsigned long, unsigned int)
const
third_party/llvm/llvm/tools/clang/include/clang/AST/ASTContext.h:588:22
#5 0x3010c16 in clang::ObjCInterfaceDecl::Create(clang::ASTContext
const&, clang::DeclContext*, clang::SourceLocation, clang::IdentifierInfo*,

r281351 - Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

2016-09-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep 13 11:45:29 2016
New Revision: 281351

URL: http://llvm.org/viewvc/llvm-project?rev=281351=rev
Log:
Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

Now ObjCObjectType extends from ObjCProtocolQualifiers. We save number of
protocols in ObjCProtocolQualifiers.

This is in preparation of adding a new type class ObjCTypeParamType that
can take protocol qualifiers.

rdar://24619481
rdar://25060179

Differential Revision: http://reviews.llvm.org/D23078

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=281351=281350=281351=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Sep 13 11:45:29 2016
@@ -4699,6 +4699,59 @@ public:
   }
 };
 
+/// This class wraps the list of protocol qualifiers. For types that can
+/// take ObjC protocol qualifers, they can subclass this class.
+template 
+class ObjCProtocolQualifiers {
+protected:
+  ObjCProtocolQualifiers() {}
+  ObjCProtocolDecl * const *getProtocolStorage() const {
+return const_cast(this)->getProtocolStorage();
+  }
+
+  ObjCProtocolDecl **getProtocolStorage() {
+return static_cast(this)->getProtocolStorageImpl();
+  }
+  void setNumProtocols(unsigned N) {
+static_cast(this)->setNumProtocolsImpl(N);
+  }
+  void initialize(ArrayRef protocols) {
+setNumProtocols(protocols.size());
+assert(getNumProtocols() == protocols.size() &&
+   "bitfield overflow in protocol count");
+if (!protocols.empty())
+  memcpy(getProtocolStorage(), protocols.data(),
+ protocols.size() * sizeof(ObjCProtocolDecl*));
+  }
+
+public:
+  typedef ObjCProtocolDecl * const *qual_iterator;
+  typedef llvm::iterator_range qual_range;
+
+  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
+  qual_iterator qual_begin() const { return getProtocolStorage(); }
+  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
+
+  bool qual_empty() const { return getNumProtocols() == 0; }
+
+  /// Return the number of qualifying protocols in this type, or 0 if
+  /// there are none.
+  unsigned getNumProtocols() const {
+return static_cast(this)->getNumProtocolsImpl();
+  }
+
+  /// Fetch a protocol by index.
+  ObjCProtocolDecl *getProtocol(unsigned I) const {
+assert(I < getNumProtocols() && "Out-of-range protocol access");
+return qual_begin()[I];
+  }
+
+  /// Retrieve all of the protocol qualifiers.
+  ArrayRef getProtocols() const {
+return ArrayRef(qual_begin(), getNumProtocols());
+  }
+};
+
 /// Represents a class type in Objective C.
 ///
 /// Every Objective C type is a combination of a base type, a set of
@@ -4727,7 +4780,9 @@ public:
 /// 'id' is an ObjCObjectPointerType whose pointee is an ObjCObjectType
 /// with base BuiltinType::ObjCIdType and protocol list [P].  Eventually
 /// this should get its own sugar class to better represent the source.
-class ObjCObjectType : public Type {
+class ObjCObjectType : public Type,
+   public ObjCProtocolQualifiers {
+  friend class ObjCProtocolQualifiers;
   // ObjCObjectType.NumTypeArgs - the number of type arguments stored
   // after the ObjCObjectPointerType node.
   // ObjCObjectType.NumProtocols - the number of protocols stored
@@ -4747,16 +4802,20 @@ class ObjCObjectType : public Type {
   mutable llvm::PointerIntPair
 CachedSuperClassType;
 
-  ObjCProtocolDecl * const *getProtocolStorage() const {
-return const_cast(this)->getProtocolStorage();
-  }
-
   QualType *getTypeArgStorage();
   const QualType *getTypeArgStorage() const {
 return const_cast(this)->getTypeArgStorage();
   }
 
-  ObjCProtocolDecl **getProtocolStorage();
+  ObjCProtocolDecl **getProtocolStorageImpl();
+  /// Return the number of qualifying protocols in this interface type,
+  /// or 0 if there are none.
+  unsigned getNumProtocolsImpl() const {
+return ObjCObjectTypeBits.NumProtocols;
+  }
+  void setNumProtocolsImpl(unsigned N) {
+ObjCObjectTypeBits.NumProtocols = N;
+  }
 
 protected:
   ObjCObjectType(QualType Canonical, QualType Base,
@@ -4833,30 +4892,6 @@ public:
   ObjCObjectTypeBits.NumTypeArgs);
   }
 
-  typedef ObjCProtocolDecl * const *qual_iterator;
-  typedef llvm::iterator_range qual_range;
-
-  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
-  qual_iterator qual_begin() const { return getProtocolStorage(); }
-  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
-
-  bool qual_empty() const { return getNumProtocols() == 0; }
-
-  /// Return the number of qualifying protocols in this interface type,
-  /// or 0 if there are none.
-  unsigned