From 0878f15531c6a853d20fa0b8da4a4e77dc034b3f Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Fri, 28 Mar 2014 20:32:11 +0000 Subject: [PATCH] Revert "OnDiskHashTable: Use EndianStream.h to write little endian ostreams" This reverts commit r205044. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205047 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/OnDiskHashTable.h | 55 +++++++-- lib/Frontend/CacheTokens.cpp | 59 +++------ lib/Lex/PTHLexer.cpp | 1 - lib/Serialization/ASTWriter.cpp | 154 ++++++++++-------------- lib/Serialization/GlobalModuleIndex.cpp | 12 +- 5 files changed, 128 insertions(+), 153 deletions(-) diff --git a/include/clang/Basic/OnDiskHashTable.h b/include/clang/Basic/OnDiskHashTable.h index 8c2cd8d5f3..1c398d5772 100644 --- a/include/clang/Basic/OnDiskHashTable.h +++ b/include/clang/Basic/OnDiskHashTable.h @@ -17,7 +17,6 @@ #include "clang/Basic/LLVM.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/EndianStream.h" #include "llvm/Support/Host.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" @@ -30,11 +29,45 @@ namespace io { typedef uint32_t Offset; +inline void Emit8(raw_ostream& Out, uint32_t V) { + Out << (unsigned char)(V); +} + +inline void Emit16(raw_ostream& Out, uint32_t V) { + Out << (unsigned char)(V); + Out << (unsigned char)(V >> 8); + assert((V >> 16) == 0); +} + +inline void Emit24(raw_ostream& Out, uint32_t V) { + Out << (unsigned char)(V); + Out << (unsigned char)(V >> 8); + Out << (unsigned char)(V >> 16); + assert((V >> 24) == 0); +} + +inline void Emit32(raw_ostream& Out, uint32_t V) { + Out << (unsigned char)(V); + Out << (unsigned char)(V >> 8); + Out << (unsigned char)(V >> 16); + Out << (unsigned char)(V >> 24); +} + +inline void Emit64(raw_ostream& Out, uint64_t V) { + Out << (unsigned char)(V); + Out << (unsigned char)(V >> 8); + Out << (unsigned char)(V >> 16); + Out << (unsigned char)(V >> 24); + Out << (unsigned char)(V >> 32); + Out << (unsigned char)(V >> 40); + Out << (unsigned char)(V >> 48); + Out << (unsigned char)(V >> 56); +} + inline void Pad(raw_ostream& Out, unsigned A) { - using namespace llvm::support; Offset off = (Offset) Out.tell(); for (uint32_t n = llvm::OffsetToAlignment(off, A); n; --n) - endian::Writer(Out).write(0); + Emit8(Out, 0); } } // end namespace io @@ -116,8 +149,7 @@ public: } io::Offset Emit(raw_ostream &out, Info &InfoObj) { - using namespace llvm::support; - endian::Writer LE(out); + using namespace clang::io; // Emit the payload of the table. for (unsigned i = 0; i < NumBuckets; ++i) { @@ -129,12 +161,12 @@ public: assert(B.off && "Cannot write a bucket at offset 0. Please add padding."); // Write out the number of items in the bucket. - LE.write(B.length); + Emit16(out, B.length); assert(B.length != 0 && "Bucket has a head but zero length?"); // Write out the entries in the bucket. for (Item *I = B.head; I ; I = I->next) { - LE.write(I->hash); + Emit32(out, I->hash); const std::pair& Len = InfoObj.EmitKeyDataLength(out, I->key, I->data); InfoObj.EmitKey(out, I->key, Len.first); @@ -143,12 +175,11 @@ public: } // Emit the hashtable itself. - io::Pad(out, 4); + Pad(out, 4); io::Offset TableOff = out.tell(); - LE.write(NumBuckets); - LE.write(NumEntries); - for (unsigned i = 0; i < NumBuckets; ++i) - LE.write(Buckets[i].off); + Emit32(out, NumBuckets); + Emit32(out, NumEntries); + for (unsigned i = 0; i < NumBuckets; ++i) Emit32(out, Buckets[i].off); return TableOff; } diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp index 2cb65826ad..0fca5130c5 100644 --- a/lib/Frontend/CacheTokens.cpp +++ b/lib/Frontend/CacheTokens.cpp @@ -23,7 +23,6 @@ #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/Support/EndianStream.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -79,23 +78,21 @@ public: unsigned getKind() const { return (unsigned) Kind; } void EmitData(raw_ostream& Out) { - using namespace llvm::support; - endian::Writer LE(Out); switch (Kind) { case IsFE: { // Emit stat information. llvm::sys::fs::UniqueID UID = FE->getUniqueID(); - LE.write(UID.getFile()); - LE.write(UID.getDevice()); - LE.write(FE->getModificationTime()); - LE.write(FE->getSize()); + ::Emit64(Out, UID.getFile()); + ::Emit64(Out, UID.getDevice()); + ::Emit64(Out, FE->getModificationTime()); + ::Emit64(Out, FE->getSize()); } break; case IsDE: // Emit stat information. - LE.write(Data->UniqueID.getFile()); - LE.write(Data->UniqueID.getDevice()); - LE.write(Data->ModTime); - LE.write(Data->Size); + ::Emit64(Out, Data->UniqueID.getFile()); + ::Emit64(Out, Data->UniqueID.getDevice()); + ::Emit64(Out, Data->ModTime); + ::Emit64(Out, Data->Size); delete Data; break; default: @@ -123,36 +120,32 @@ public: static std::pair EmitKeyDataLength(raw_ostream& Out, PTHEntryKeyVariant V, const PTHEntry& E) { - using namespace llvm::support; - endian::Writer LE(Out); unsigned n = V.getString().size() + 1 + 1; - LE.write(n); + ::Emit16(Out, n); unsigned m = V.getRepresentationLength() + (V.isFile() ? 4 + 4 : 0); - LE.write(m); + ::Emit8(Out, m); return std::make_pair(n, m); } static void EmitKey(raw_ostream& Out, PTHEntryKeyVariant V, unsigned n){ - using namespace llvm::support; // Emit the entry kind. - endian::Writer(Out).write((unsigned)V.getKind()); + ::Emit8(Out, (unsigned) V.getKind()); // Emit the string. Out.write(V.getString().data(), n - 1); } static void EmitData(raw_ostream& Out, PTHEntryKeyVariant V, const PTHEntry& E, unsigned) { - using namespace llvm::support; - endian::Writer LE(Out); + // For file entries emit the offsets into the PTH file for token data // and the preprocessor blocks table. if (V.isFile()) { - LE.write(E.getTokenOffset()); - LE.write(E.getPPCondTableOffset()); + ::Emit32(Out, E.getTokenOffset()); + ::Emit32(Out, E.getPPCondTableOffset()); } // Emit any other data associated with the key (i.e., stat information). @@ -193,28 +186,18 @@ class PTHWriter { /// Emit a token to the PTH file. void EmitToken(const Token& T); - void Emit8(uint32_t V) { - using namespace llvm::support; - endian::Writer(Out).write(V); - } + void Emit8(uint32_t V) { ::Emit8(Out, V); } - void Emit16(uint32_t V) { - using namespace llvm::support; - endian::Writer(Out).write(V); - } + void Emit16(uint32_t V) { ::Emit16(Out, V); } - void Emit32(uint32_t V) { - using namespace llvm::support; - endian::Writer(Out).write(V); - } + void Emit32(uint32_t V) { ::Emit32(Out, V); } void EmitBuf(const char *Ptr, unsigned NumBytes) { Out.write(Ptr, NumBytes); } void EmitString(StringRef V) { - using namespace llvm::support; - endian::Writer(Out).write(V.size()); + ::Emit16(Out, V.size()); EmitBuf(V.data(), V.size()); } @@ -601,9 +584,8 @@ public: static std::pair EmitKeyDataLength(raw_ostream& Out, const PTHIdKey* key, uint32_t) { - using namespace llvm::support; unsigned n = key->II->getLength() + 1; - endian::Writer(Out).write(n); + ::Emit16(Out, n); return std::make_pair(n, sizeof(uint32_t)); } @@ -616,8 +598,7 @@ public: static void EmitData(raw_ostream& Out, PTHIdKey*, uint32_t pID, unsigned) { - using namespace llvm::support; - endian::Writer(Out).write(pID); + ::Emit32(Out, pID); } }; } // end anonymous namespace diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index 1ca16d39b4..0e2ceb3cd9 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -23,7 +23,6 @@ #include "clang/Lex/Token.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/Support/EndianStream.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/system_error.h" #include diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 36e1cf82d7..30eaa3a431 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -46,7 +46,6 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Bitcode/BitstreamWriter.h" -#include "llvm/Support/EndianStream.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -1466,31 +1465,26 @@ namespace { std::pair EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) { - using namespace llvm::support; - endian::Writer Writer(Out); unsigned KeyLen = strlen(key.Filename) + 1 + 8 + 8; - Writer.write(KeyLen); + clang::io::Emit16(Out, KeyLen); unsigned DataLen = 1 + 2 + 4 + 4; if (Data.isModuleHeader) DataLen += 4; - Writer.write(DataLen); + clang::io::Emit8(Out, DataLen); return std::make_pair(KeyLen, DataLen); } void EmitKey(raw_ostream& Out, key_type_ref key, unsigned KeyLen) { - using namespace llvm::support; - endian::Writer LE(Out); - LE.write(key.FE->getSize()); + clang::io::Emit64(Out, key.FE->getSize()); KeyLen -= 8; - LE.write(key.FE->getModificationTime()); + clang::io::Emit64(Out, key.FE->getModificationTime()); KeyLen -= 8; Out.write(key.Filename, KeyLen); } void EmitData(raw_ostream &Out, key_type_ref key, data_type_ref Data, unsigned DataLen) { - using namespace llvm::support; - endian::Writer LE(Out); + using namespace clang::io; uint64_t Start = Out.tell(); (void)Start; unsigned char Flags = (Data.HeaderRole << 6) @@ -1499,13 +1493,13 @@ namespace { | (Data.DirInfo << 2) | (Data.Resolved << 1) | Data.IndexHeaderMapHeader; - LE.write(Flags); - LE.write(Data.NumIncludes); + Emit8(Out, (uint8_t)Flags); + Emit16(Out, (uint16_t) Data.NumIncludes); if (!Data.ControllingMacro) - LE.write(Data.ControllingMacroID); + Emit32(Out, (uint32_t)Data.ControllingMacroID); else - LE.write(Writer.getIdentifierRef(Data.ControllingMacro)); + Emit32(Out, (uint32_t)Writer.getIdentifierRef(Data.ControllingMacro)); unsigned Offset = 0; if (!Data.Framework.empty()) { @@ -1522,11 +1516,11 @@ namespace { } else Offset = Pos->second; } - LE.write(Offset); + Emit32(Out, Offset); if (Data.isModuleHeader) { Module *Mod = HS.findModuleForHeader(key.FE).getModule(); - LE.write(Writer.getExistingSubmoduleID(Mod)); + Emit32(Out, Writer.getExistingSubmoduleID(Mod)); } assert(Out.tell() - Start == DataLen && "Wrong data length"); @@ -1584,10 +1578,9 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot) { SmallString<4096> TableData; uint32_t BucketOffset; { - using namespace llvm::support; llvm::raw_svector_ostream Out(TableData); // Make sure that no bucket is at offset 0 - endian::Writer(Out).write(0); + clang::io::Emit32(Out, 0); BucketOffset = Generator.Emit(Out, GeneratorTrait); } @@ -1842,14 +1835,12 @@ public: } static void EmitKey(raw_ostream& Out, key_type_ref Key, unsigned KeyLen) { - using namespace llvm::support; - endian::Writer(Out).write(Key); + clang::io::Emit32(Out, Key); } static void EmitData(raw_ostream& Out, key_type_ref Key, data_type_ref Data, unsigned) { - using namespace llvm::support; - endian::Writer(Out).write(Data.MacroDirectivesOffset); + clang::io::Emit32(Out, Data.MacroDirectivesOffset); } }; } // end anonymous namespace @@ -2045,10 +2036,9 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { SmallString<4096> MacroTable; uint32_t BucketOffset; { - using namespace llvm::support; llvm::raw_svector_ostream Out(MacroTable); // Make sure that no bucket is at offset 0 - endian::Writer(Out).write(0); + clang::io::Emit32(Out, 0); BucketOffset = Generator.Emit(Out); } @@ -2719,10 +2709,8 @@ public: std::pair EmitKeyDataLength(raw_ostream& Out, Selector Sel, data_type_ref Methods) { - using namespace llvm::support; - endian::Writer LE(Out); unsigned KeyLen = 2 + (Sel.getNumArgs()? Sel.getNumArgs() * 4 : 4); - LE.write(KeyLen); + clang::io::Emit16(Out, KeyLen); unsigned DataLen = 4 + 2 + 2; // 2 bytes for each of the method counts for (const ObjCMethodList *Method = &Methods.Instance; Method; Method = Method->getNext()) @@ -2732,31 +2720,27 @@ public: Method = Method->getNext()) if (Method->Method) DataLen += 4; - LE.write(DataLen); + clang::io::Emit16(Out, DataLen); return std::make_pair(KeyLen, DataLen); } void EmitKey(raw_ostream& Out, Selector Sel, unsigned) { - using namespace llvm::support; - endian::Writer LE(Out); uint64_t Start = Out.tell(); assert((Start >> 32) == 0 && "Selector key offset too large"); Writer.SetSelectorOffset(Sel, Start); unsigned N = Sel.getNumArgs(); - LE.write(N); + clang::io::Emit16(Out, N); if (N == 0) N = 1; for (unsigned I = 0; I != N; ++I) - LE.write( - Writer.getIdentifierRef(Sel.getIdentifierInfoForSlot(I))); + clang::io::Emit32(Out, + Writer.getIdentifierRef(Sel.getIdentifierInfoForSlot(I))); } void EmitData(raw_ostream& Out, key_type_ref, data_type_ref Methods, unsigned DataLen) { - using namespace llvm::support; - endian::Writer LE(Out); uint64_t Start = Out.tell(); (void)Start; - LE.write(Methods.ID); + clang::io::Emit32(Out, Methods.ID); unsigned NumInstanceMethods = 0; for (const ObjCMethodList *Method = &Methods.Instance; Method; Method = Method->getNext()) @@ -2776,16 +2760,16 @@ public: unsigned FactoryBits = Methods.Factory.getBits(); assert(FactoryBits < 4); unsigned NumFactoryMethodsAndBits = (NumFactoryMethods << 2) | FactoryBits; - LE.write(NumInstanceMethodsAndBits); - LE.write(NumFactoryMethodsAndBits); + clang::io::Emit16(Out, NumInstanceMethodsAndBits); + clang::io::Emit16(Out, NumFactoryMethodsAndBits); for (const ObjCMethodList *Method = &Methods.Instance; Method; Method = Method->getNext()) if (Method->Method) - LE.write(Writer.getDeclID(Method->Method)); + clang::io::Emit32(Out, Writer.getDeclID(Method->Method)); for (const ObjCMethodList *Method = &Methods.Factory; Method; Method = Method->getNext()) if (Method->Method) - LE.write(Writer.getDeclID(Method->Method)); + clang::io::Emit32(Out, Writer.getDeclID(Method->Method)); assert(Out.tell() - Start == DataLen && "Data length is wrong"); } @@ -2854,11 +2838,10 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) { SmallString<4096> MethodPool; uint32_t BucketOffset; { - using namespace llvm::support; ASTMethodPoolTrait Trait(*this); llvm::raw_svector_ostream Out(MethodPool); // Make sure that no bucket is at offset 0 - endian::Writer(Out).write(0); + clang::io::Emit32(Out, 0); BucketOffset = Generator.Emit(Out, Trait); } @@ -3103,14 +3086,11 @@ public: D != DEnd; ++D) DataLen += sizeof(DeclID); } - using namespace llvm::support; - endian::Writer LE(Out); - - LE.write(DataLen); + clang::io::Emit16(Out, DataLen); // We emit the key length after the data length so that every // string is preceded by a 16-bit length. This matches the PTH // format for storing identifiers. - LE.write(KeyLen); + clang::io::Emit16(Out, KeyLen); return std::make_pair(KeyLen, DataLen); } @@ -3125,28 +3105,24 @@ public: static void emitMacroOverrides(raw_ostream &Out, llvm::ArrayRef Overridden) { if (!Overridden.empty()) { - using namespace llvm::support; - endian::Writer LE(Out); - LE.write(Overridden.size() | 0x80000000U); + clang::io::Emit32(Out, Overridden.size() | 0x80000000U); for (unsigned I = 0, N = Overridden.size(); I != N; ++I) - LE.write(Overridden[I]); + clang::io::Emit32(Out, Overridden[I]); } } void EmitData(raw_ostream& Out, IdentifierInfo* II, IdentID ID, unsigned) { - using namespace llvm::support; - endian::Writer LE(Out); MacroDirective *Macro = 0; if (!isInterestingIdentifier(II, Macro)) { - LE.write(ID << 1); + clang::io::Emit32(Out, ID << 1); return; } - LE.write((ID << 1) | 0x01); + clang::io::Emit32(Out, (ID << 1) | 0x01); uint32_t Bits = (uint32_t)II->getObjCOrBuiltinID(); assert((Bits & 0xffff) == Bits && "ObjCOrBuiltinID too big for ASTReader."); - LE.write(Bits); + clang::io::Emit16(Out, Bits); Bits = 0; bool HadMacroDefinition = hadMacroDefinition(II, Macro); Bits = (Bits << 1) | unsigned(HadMacroDefinition); @@ -3155,10 +3131,10 @@ public: Bits = (Bits << 1) | unsigned(II->isPoisoned()); Bits = (Bits << 1) | unsigned(II->hasRevertedTokenIDToIdentifier()); Bits = (Bits << 1) | unsigned(II->isCPlusPlusOperatorKeyword()); - LE.write(Bits); + clang::io::Emit16(Out, Bits); if (HadMacroDefinition) { - LE.write(Writer.getMacroDirectivesOffset(II)); + clang::io::Emit32(Out, Writer.getMacroDirectivesOffset(II)); if (IsModule) { // Write the IDs of macros coming from different submodules. SubmoduleID ModID; @@ -3171,14 +3147,14 @@ public: if (DefMacroDirective *DefMD = dyn_cast(MD)) { InfoID = Writer.getMacroID(DefMD->getInfo()); assert(InfoID); - LE.write(InfoID << 1); + clang::io::Emit32(Out, InfoID << 1); } else { assert(isa(MD)); - LE.write((ModID << 1) | 1); + clang::io::Emit32(Out, (ModID << 1) | 1); } } emitMacroOverrides(Out, Overridden); - LE.write(0); + clang::io::Emit32(Out, 0); } } @@ -3193,7 +3169,7 @@ public: for (SmallVectorImpl::reverse_iterator D = Decls.rbegin(), DEnd = Decls.rend(); D != DEnd; ++D) - LE.write(Writer.getDeclID(getMostRecentLocalDecl(*D))); + clang::io::Emit32(Out, Writer.getDeclID(getMostRecentLocalDecl(*D))); } /// \brief Returns the most recent local decl or the given decl if there are @@ -3262,11 +3238,10 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP, SmallString<4096> IdentifierTable; uint32_t BucketOffset; { - using namespace llvm::support; ASTIdentifierTableTrait Trait(*this, PP, IdResolver, IsModule); llvm::raw_svector_ostream Out(IdentifierTable); // Make sure that no bucket is at offset 0 - endian::Writer(Out).write(0); + clang::io::Emit32(Out, 0); BucketOffset = Generator.Emit(Out, Trait); } @@ -3355,8 +3330,6 @@ public: std::pair EmitKeyDataLength(raw_ostream& Out, DeclarationName Name, data_type_ref Lookup) { - using namespace llvm::support; - endian::Writer LE(Out); unsigned KeyLen = 1; switch (Name.getNameKind()) { case DeclarationName::Identifier: @@ -3375,35 +3348,35 @@ public: case DeclarationName::CXXUsingDirective: break; } - LE.write(KeyLen); + clang::io::Emit16(Out, KeyLen); // 2 bytes for num of decls and 4 for each DeclID. unsigned DataLen = 2 + 4 * Lookup.size(); - LE.write(DataLen); + clang::io::Emit16(Out, DataLen); return std::make_pair(KeyLen, DataLen); } void EmitKey(raw_ostream& Out, DeclarationName Name, unsigned) { - using namespace llvm::support; - endian::Writer LE(Out); - LE.write(Name.getNameKind()); + using namespace clang::io; + + Emit8(Out, Name.getNameKind()); switch (Name.getNameKind()) { case DeclarationName::Identifier: - LE.write(Writer.getIdentifierRef(Name.getAsIdentifierInfo())); + Emit32(Out, Writer.getIdentifierRef(Name.getAsIdentifierInfo())); return; case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCMultiArgSelector: - LE.write(Writer.getSelectorRef(Name.getObjCSelector())); + Emit32(Out, Writer.getSelectorRef(Name.getObjCSelector())); return; case DeclarationName::CXXOperatorName: assert(Name.getCXXOverloadedOperator() < NUM_OVERLOADED_OPERATORS && "Invalid operator?"); - LE.write(Name.getCXXOverloadedOperator()); + Emit8(Out, Name.getCXXOverloadedOperator()); return; case DeclarationName::CXXLiteralOperatorName: - LE.write(Writer.getIdentifierRef(Name.getCXXLiteralIdentifier())); + Emit32(Out, Writer.getIdentifierRef(Name.getCXXLiteralIdentifier())); return; case DeclarationName::CXXConstructorName: case DeclarationName::CXXDestructorName: @@ -3417,13 +3390,11 @@ public: void EmitData(raw_ostream& Out, key_type_ref, data_type Lookup, unsigned DataLen) { - using namespace llvm::support; - endian::Writer LE(Out); uint64_t Start = Out.tell(); (void)Start; - LE.write(Lookup.size()); + clang::io::Emit16(Out, Lookup.size()); for (DeclContext::lookup_iterator I = Lookup.begin(), E = Lookup.end(); I != E; ++I) - LE.write(Writer.GetDeclRef(*I)); + clang::io::Emit32(Out, Writer.GetDeclRef(*I)); assert(Out.tell() - Start == DataLen && "Data length is wrong"); } @@ -3516,8 +3487,7 @@ ASTWriter::GenerateNameLookupTable(const DeclContext *DC, // Create the on-disk hash table in a buffer. llvm::raw_svector_ostream Out(LookupTable); // Make sure that no bucket is at offset 0 - using namespace llvm::support; - endian::Writer(Out).write(0); + clang::io::Emit32(Out, 0); return Generator.Emit(Out, Trait); } @@ -4217,19 +4187,17 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, for (ModuleManager::ModuleConstIterator M = Chain->ModuleMgr.begin(), MEnd = Chain->ModuleMgr.end(); M != MEnd; ++M) { - using namespace llvm::support; - endian::Writer LE(Out); StringRef FileName = (*M)->FileName; - LE.write(FileName.size()); + io::Emit16(Out, FileName.size()); Out.write(FileName.data(), FileName.size()); - LE.write((*M)->SLocEntryBaseOffset); - LE.write((*M)->BaseIdentifierID); - LE.write((*M)->BaseMacroID); - LE.write((*M)->BasePreprocessedEntityID); - LE.write((*M)->BaseSubmoduleID); - LE.write((*M)->BaseSelectorID); - LE.write((*M)->BaseDeclID); - LE.write((*M)->BaseTypeIndex); + io::Emit32(Out, (*M)->SLocEntryBaseOffset); + io::Emit32(Out, (*M)->BaseIdentifierID); + io::Emit32(Out, (*M)->BaseMacroID); + io::Emit32(Out, (*M)->BasePreprocessedEntityID); + io::Emit32(Out, (*M)->BaseSubmoduleID); + io::Emit32(Out, (*M)->BaseSelectorID); + io::Emit32(Out, (*M)->BaseDeclID); + io::Emit32(Out, (*M)->BaseTypeIndex); } } Record.clear(); diff --git a/lib/Serialization/GlobalModuleIndex.cpp b/lib/Serialization/GlobalModuleIndex.cpp index 14b149f078..ada02efc3f 100644 --- a/lib/Serialization/GlobalModuleIndex.cpp +++ b/lib/Serialization/GlobalModuleIndex.cpp @@ -631,12 +631,10 @@ public: std::pair EmitKeyDataLength(raw_ostream& Out, key_type_ref Key, data_type_ref Data) { - using namespace llvm::support; - endian::Writer LE(Out); unsigned KeyLen = Key.size(); unsigned DataLen = Data.size() * 4; - LE.write(KeyLen); - LE.write(DataLen); + clang::io::Emit16(Out, KeyLen); + clang::io::Emit16(Out, DataLen); return std::make_pair(KeyLen, DataLen); } @@ -646,9 +644,8 @@ public: void EmitData(raw_ostream& Out, key_type_ref Key, data_type_ref Data, unsigned DataLen) { - using namespace llvm::support; for (unsigned I = 0, N = Data.size(); I != N; ++I) - endian::Writer(Out).write(Data[I]); + clang::io::Emit32(Out, Data[I]); } }; @@ -710,10 +707,9 @@ void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) { SmallString<4096> IdentifierTable; uint32_t BucketOffset; { - using namespace llvm::support; llvm::raw_svector_ostream Out(IdentifierTable); // Make sure that no bucket is at offset 0 - endian::Writer(Out).write(0); + clang::io::Emit32(Out, 0); BucketOffset = Generator.Emit(Out, Trait); } -- 2.40.0