diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-12-27 22:14:15 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-12-27 22:14:15 +0000 |
commit | ff4b35e6e73ee97bd1437908ce657c62b8a179e5 (patch) | |
tree | 1647c8f0c96367351bcec1d6f5623c2f615f27b0 /clang/lib/Serialization/ASTReader.cpp | |
parent | 6e3a582809efea34253dfdfd7327c89c3f9f4800 (diff) | |
download | bcm5719-llvm-ff4b35e6e73ee97bd1437908ce657c62b8a179e5.tar.gz bcm5719-llvm-ff4b35e6e73ee97bd1437908ce657c62b8a179e5.zip |
Objective-C: Serialize "more than one decl" state of ObjCMethodList.
This fixes PR21587, what r221933 fixed for regular programs is now also
fixed for decls coming from PCH files.
Use another bit from the count/bits uint16_t for storing the "more than one
decl" bit. This reduces the number of bits for the count from 14 to 13.
The selector with the most overloads in Cocoa.h has ~55 overloads, so 13 bits
should still be plenty. Since this changes the meaning of a serialized bit
pattern, also increase clang::serialization::VERSION_MAJOR.
Storing the "more than one decl" state of only the first overload isn't quite
correct, but Sema::AreMultipleMethodsInGlobalPool() currently only looks at
the state of the first overload so it's good enough for now.
llvm-svn: 224892
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index b3bac25a076..7d6565aac38 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -650,14 +650,14 @@ ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d, Result.ID = Reader.getGlobalSelectorID( F, endian::readNext<uint32_t, little, unaligned>(d)); - unsigned NumInstanceMethodsAndBits = - endian::readNext<uint16_t, little, unaligned>(d); - unsigned NumFactoryMethodsAndBits = - endian::readNext<uint16_t, little, unaligned>(d); - Result.InstanceBits = NumInstanceMethodsAndBits & 0x3; - Result.FactoryBits = NumFactoryMethodsAndBits & 0x3; - unsigned NumInstanceMethods = NumInstanceMethodsAndBits >> 2; - unsigned NumFactoryMethods = NumFactoryMethodsAndBits >> 2; + unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d); + unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d); + Result.InstanceBits = FullInstanceBits & 0x3; + Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1; + Result.FactoryBits = FullFactoryBits & 0x3; + Result.FactoryHasMoreThanOneDecl = (FullFactoryBits >> 2) & 0x1; + unsigned NumInstanceMethods = FullInstanceBits >> 3; + unsigned NumFactoryMethods = FullFactoryBits >> 3; // Load instance methods for (unsigned I = 0; I != NumInstanceMethods; ++I) { @@ -7061,6 +7061,8 @@ namespace clang { namespace serialization { unsigned PriorGeneration; unsigned InstanceBits; unsigned FactoryBits; + bool InstanceHasMoreThanOneDecl; + bool FactoryHasMoreThanOneDecl; SmallVector<ObjCMethodDecl *, 4> InstanceMethods; SmallVector<ObjCMethodDecl *, 4> FactoryMethods; @@ -7068,7 +7070,8 @@ namespace clang { namespace serialization { ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, unsigned PriorGeneration) : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration), - InstanceBits(0), FactoryBits(0) {} + InstanceBits(0), FactoryBits(0), InstanceHasMoreThanOneDecl(false), + FactoryHasMoreThanOneDecl(false) {} static bool visit(ModuleFile &M, void *UserData) { ReadMethodPoolVisitor *This @@ -7103,6 +7106,8 @@ namespace clang { namespace serialization { This->FactoryMethods.append(Data.Factory.begin(), Data.Factory.end()); This->InstanceBits = Data.InstanceBits; This->FactoryBits = Data.FactoryBits; + This->InstanceHasMoreThanOneDecl = Data.InstanceHasMoreThanOneDecl; + This->FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl; return true; } @@ -7118,6 +7123,10 @@ namespace clang { namespace serialization { unsigned getInstanceBits() const { return InstanceBits; } unsigned getFactoryBits() const { return FactoryBits; } + bool instanceHasMoreThanOneDecl() const { + return InstanceHasMoreThanOneDecl; + } + bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; } }; } } // end namespace clang::serialization @@ -7156,7 +7165,9 @@ void ASTReader::ReadMethodPool(Selector Sel) { addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first); addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second); Pos->second.first.setBits(Visitor.getInstanceBits()); + Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl()); Pos->second.second.setBits(Visitor.getFactoryBits()); + Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl()); } void ASTReader::ReadKnownNamespaces( |