Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Serialization/ASTWriter.cpp
Show First 20 Lines • Show All 3,006 Lines • ▼ Show 20 Lines | std::pair<unsigned, unsigned> | ||||
using namespace llvm::support; | using namespace llvm::support; | ||||
endian::Writer LE(Out, little); | endian::Writer LE(Out, little); | ||||
unsigned KeyLen = 2 + (Sel.getNumArgs()? Sel.getNumArgs() * 4 : 4); | unsigned KeyLen = 2 + (Sel.getNumArgs()? Sel.getNumArgs() * 4 : 4); | ||||
LE.write<uint16_t>(KeyLen); | LE.write<uint16_t>(KeyLen); | ||||
unsigned DataLen = 4 + 2 + 2; // 2 bytes for each of the method counts | unsigned DataLen = 4 + 2 + 2; // 2 bytes for each of the method counts | ||||
for (const ObjCMethodList *Method = &Methods.Instance; Method; | for (const ObjCMethodList *Method = &Methods.Instance; Method; | ||||
Method = Method->getNext()) | Method = Method->getNext()) | ||||
if (Method->getMethod()) | if (Method->getMethod() && !Method->getMethod()->isFromASTFile()) | ||||
DataLen += 4; | DataLen += 4; | ||||
for (const ObjCMethodList *Method = &Methods.Factory; Method; | for (const ObjCMethodList *Method = &Methods.Factory; Method; | ||||
Method = Method->getNext()) | Method = Method->getNext()) | ||||
if (Method->getMethod()) | if (Method->getMethod() && !Method->getMethod()->isFromASTFile()) | ||||
DataLen += 4; | DataLen += 4; | ||||
LE.write<uint16_t>(DataLen); | LE.write<uint16_t>(DataLen); | ||||
return std::make_pair(KeyLen, DataLen); | return std::make_pair(KeyLen, DataLen); | ||||
} | } | ||||
void EmitKey(raw_ostream& Out, Selector Sel, unsigned) { | void EmitKey(raw_ostream& Out, Selector Sel, unsigned) { | ||||
using namespace llvm::support; | using namespace llvm::support; | ||||
Show All 15 Lines | void EmitData(raw_ostream& Out, key_type_ref, | ||||
using namespace llvm::support; | using namespace llvm::support; | ||||
endian::Writer LE(Out, little); | endian::Writer LE(Out, little); | ||||
uint64_t Start = Out.tell(); (void)Start; | uint64_t Start = Out.tell(); (void)Start; | ||||
LE.write<uint32_t>(Methods.ID); | LE.write<uint32_t>(Methods.ID); | ||||
unsigned NumInstanceMethods = 0; | unsigned NumInstanceMethods = 0; | ||||
for (const ObjCMethodList *Method = &Methods.Instance; Method; | for (const ObjCMethodList *Method = &Methods.Instance; Method; | ||||
Method = Method->getNext()) | Method = Method->getNext()) | ||||
if (Method->getMethod()) | if (Method->getMethod() && !Method->getMethod()->isFromASTFile()) | ||||
++NumInstanceMethods; | ++NumInstanceMethods; | ||||
unsigned NumFactoryMethods = 0; | unsigned NumFactoryMethods = 0; | ||||
for (const ObjCMethodList *Method = &Methods.Factory; Method; | for (const ObjCMethodList *Method = &Methods.Factory; Method; | ||||
Method = Method->getNext()) | Method = Method->getNext()) | ||||
if (Method->getMethod()) | if (Method->getMethod() && !Method->getMethod()->isFromASTFile()) | ||||
++NumFactoryMethods; | ++NumFactoryMethods; | ||||
unsigned InstanceBits = Methods.Instance.getBits(); | unsigned InstanceBits = Methods.Instance.getBits(); | ||||
assert(InstanceBits < 4); | assert(InstanceBits < 4); | ||||
unsigned InstanceHasMoreThanOneDeclBit = | unsigned InstanceHasMoreThanOneDeclBit = | ||||
Methods.Instance.hasMoreThanOneDecl(); | Methods.Instance.hasMoreThanOneDecl(); | ||||
unsigned FullInstanceBits = (NumInstanceMethods << 3) | | unsigned FullInstanceBits = (NumInstanceMethods << 3) | | ||||
(InstanceHasMoreThanOneDeclBit << 2) | | (InstanceHasMoreThanOneDeclBit << 2) | | ||||
InstanceBits; | InstanceBits; | ||||
unsigned FactoryBits = Methods.Factory.getBits(); | unsigned FactoryBits = Methods.Factory.getBits(); | ||||
assert(FactoryBits < 4); | assert(FactoryBits < 4); | ||||
unsigned FactoryHasMoreThanOneDeclBit = | unsigned FactoryHasMoreThanOneDeclBit = | ||||
Methods.Factory.hasMoreThanOneDecl(); | Methods.Factory.hasMoreThanOneDecl(); | ||||
unsigned FullFactoryBits = (NumFactoryMethods << 3) | | unsigned FullFactoryBits = (NumFactoryMethods << 3) | | ||||
(FactoryHasMoreThanOneDeclBit << 2) | | (FactoryHasMoreThanOneDeclBit << 2) | | ||||
FactoryBits; | FactoryBits; | ||||
LE.write<uint16_t>(FullInstanceBits); | LE.write<uint16_t>(FullInstanceBits); | ||||
LE.write<uint16_t>(FullFactoryBits); | LE.write<uint16_t>(FullFactoryBits); | ||||
for (const ObjCMethodList *Method = &Methods.Instance; Method; | for (const ObjCMethodList *Method = &Methods.Instance; Method; | ||||
Method = Method->getNext()) | Method = Method->getNext()) | ||||
if (Method->getMethod()) | if (Method->getMethod() && !Method->getMethod()->isFromASTFile()) | ||||
LE.write<uint32_t>(Writer.getDeclID(Method->getMethod())); | LE.write<uint32_t>(Writer.getDeclID(Method->getMethod())); | ||||
for (const ObjCMethodList *Method = &Methods.Factory; Method; | for (const ObjCMethodList *Method = &Methods.Factory; Method; | ||||
Method = Method->getNext()) | Method = Method->getNext()) | ||||
if (Method->getMethod()) | if (Method->getMethod() && !Method->getMethod()->isFromASTFile()) | ||||
LE.write<uint32_t>(Writer.getDeclID(Method->getMethod())); | LE.write<uint32_t>(Writer.getDeclID(Method->getMethod())); | ||||
assert(Out.tell() - Start == DataLen && "Data length is wrong"); | assert(Out.tell() - Start == DataLen && "Data length is wrong"); | ||||
} | } | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
▲ Show 20 Lines • Show All 3,759 Lines • Show Last 20 Lines |