diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-03-28 20:32:17 +0000 | 
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-03-28 20:32:17 +0000 | 
| commit | a0dafb77eb3baf6404a1081f963ecf9b05b3a9e1 (patch) | |
| tree | 9b7a763532d7b843815db1fe260852528821440b /clang/lib/Serialization | |
| parent | d42773bcc8fc3cd44f6eaa1100928045a3c07bc1 (diff) | |
| download | bcm5719-llvm-a0dafb77eb3baf6404a1081f963ecf9b05b3a9e1.tar.gz bcm5719-llvm-a0dafb77eb3baf6404a1081f963ecf9b05b3a9e1.zip  | |
Revert "OnDiskHashTable: Use Endian.h to read little endian ostreams"
This reverts commit r205045.
llvm-svn: 205048
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 132 | ||||
| -rw-r--r-- | clang/lib/Serialization/GlobalModuleIndex.cpp | 14 | 
2 files changed, 62 insertions, 84 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index ff0b1dd6294..2d3408c5841 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -470,19 +470,19 @@ unsigned ASTSelectorLookupTrait::ComputeHash(Selector Sel) {  std::pair<unsigned, unsigned>  ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) { -  using namespace llvm::support; -  unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d); -  unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d); +  using namespace clang::io; +  unsigned KeyLen = ReadUnalignedLE16(d); +  unsigned DataLen = ReadUnalignedLE16(d);    return std::make_pair(KeyLen, DataLen);  }  ASTSelectorLookupTrait::internal_key_type   ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) { -  using namespace llvm::support; +  using namespace clang::io;    SelectorTable &SelTable = Reader.getContext().Selectors; -  unsigned N = endian::readNext<uint16_t, little, unaligned>(d); -  IdentifierInfo *FirstII = Reader.getLocalIdentifier( -      F, endian::readNext<uint32_t, little, unaligned>(d)); +  unsigned N = ReadUnalignedLE16(d); +  IdentifierInfo *FirstII +    = Reader.getLocalIdentifier(F, ReadUnalignedLE32(d));    if (N == 0)      return SelTable.getNullarySelector(FirstII);    else if (N == 1) @@ -491,8 +491,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {    SmallVector<IdentifierInfo *, 16> Args;    Args.push_back(FirstII);    for (unsigned I = 1; I != N; ++I) -    Args.push_back(Reader.getLocalIdentifier( -        F, endian::readNext<uint32_t, little, unaligned>(d))); +    Args.push_back(Reader.getLocalIdentifier(F, ReadUnalignedLE32(d)));    return SelTable.getSelector(N, Args.data());  } @@ -500,16 +499,13 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {  ASTSelectorLookupTrait::data_type   ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,                                    unsigned DataLen) { -  using namespace llvm::support; +  using namespace clang::io;    data_type Result; -  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.ID = Reader.getGlobalSelectorID(F, ReadUnalignedLE32(d)); +  unsigned NumInstanceMethodsAndBits = ReadUnalignedLE16(d); +  unsigned NumFactoryMethodsAndBits = ReadUnalignedLE16(d);    Result.InstanceBits = NumInstanceMethodsAndBits & 0x3;    Result.FactoryBits = NumFactoryMethodsAndBits & 0x3;    unsigned NumInstanceMethods = NumInstanceMethodsAndBits >> 2; @@ -517,15 +513,15 @@ ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,    // Load instance methods    for (unsigned I = 0; I != NumInstanceMethods; ++I) { -    if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>( -            F, endian::readNext<uint32_t, little, unaligned>(d))) +    if (ObjCMethodDecl *Method +          = Reader.GetLocalDeclAs<ObjCMethodDecl>(F, ReadUnalignedLE32(d)))        Result.Instance.push_back(Method);    }    // Load factory methods    for (unsigned I = 0; I != NumFactoryMethods; ++I) { -    if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>( -            F, endian::readNext<uint32_t, little, unaligned>(d))) +    if (ObjCMethodDecl *Method +          = Reader.GetLocalDeclAs<ObjCMethodDecl>(F, ReadUnalignedLE32(d)))        Result.Factory.push_back(Method);    } @@ -538,9 +534,9 @@ unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type& a) {  std::pair<unsigned, unsigned>  ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) { -  using namespace llvm::support; -  unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d); -  unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d); +  using namespace clang::io; +  unsigned DataLen = ReadUnalignedLE16(d); +  unsigned KeyLen = ReadUnalignedLE16(d);    return std::make_pair(KeyLen, DataLen);  } @@ -563,8 +559,8 @@ static bool isInterestingIdentifier(IdentifierInfo &II) {  IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,                                                     const unsigned char* d,                                                     unsigned DataLen) { -  using namespace llvm::support; -  unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d); +  using namespace clang::io; +  unsigned RawID = ReadUnalignedLE32(d);    bool IsInteresting = RawID & 0x01;    // Wipe out the "is interesting" bit. @@ -590,8 +586,8 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,      return II;    } -  unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d); -  unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d); +  unsigned ObjCOrBuiltinID = ReadUnalignedLE16(d); +  unsigned Bits = ReadUnalignedLE16(d);    bool CPlusPlusOperatorKeyword = Bits & 0x01;    Bits >>= 1;    bool HasRevertedTokenIDToIdentifier = Bits & 0x01; @@ -640,13 +636,11 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,    // If this identifier is a macro, deserialize the macro    // definition.    if (hadMacroDefinition) { -    uint32_t MacroDirectivesOffset = -        endian::readNext<uint32_t, little, unaligned>(d); +    uint32_t MacroDirectivesOffset = ReadUnalignedLE32(d);      DataLen -= 4;      SmallVector<uint32_t, 8> LocalMacroIDs;      if (hasSubmoduleMacros) { -      while (uint32_t LocalMacroID = -                 endian::readNext<uint32_t, little, unaligned>(d)) { +      while (uint32_t LocalMacroID = ReadUnalignedLE32(d)) {          DataLen -= 4;          LocalMacroIDs.push_back(LocalMacroID);        } @@ -694,8 +688,7 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,    if (DataLen > 0) {      SmallVector<uint32_t, 4> DeclIDs;      for (; DataLen > 0; DataLen -= 4) -      DeclIDs.push_back(Reader.getGlobalDeclID( -          F, endian::readNext<uint32_t, little, unaligned>(d))); +      DeclIDs.push_back(Reader.getGlobalDeclID(F, ReadUnalignedLE32(d)));      Reader.SetGloballyVisibleDecls(II, DeclIDs);    } @@ -763,37 +756,34 @@ ASTDeclContextNameLookupTrait::GetInternalKey(  std::pair<unsigned, unsigned>  ASTDeclContextNameLookupTrait::ReadKeyDataLength(const unsigned char*& d) { -  using namespace llvm::support; -  unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d); -  unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d); +  using namespace clang::io; +  unsigned KeyLen = ReadUnalignedLE16(d); +  unsigned DataLen = ReadUnalignedLE16(d);    return std::make_pair(KeyLen, DataLen);  }  ASTDeclContextNameLookupTrait::internal_key_type   ASTDeclContextNameLookupTrait::ReadKey(const unsigned char* d, unsigned) { -  using namespace llvm::support; +  using namespace clang::io;    DeclNameKey Key;    Key.Kind = (DeclarationName::NameKind)*d++;    switch (Key.Kind) {    case DeclarationName::Identifier: -    Key.Data = (uint64_t)Reader.getLocalIdentifier( -        F, endian::readNext<uint32_t, little, unaligned>(d)); +    Key.Data = (uint64_t)Reader.getLocalIdentifier(F, ReadUnalignedLE32(d));      break;    case DeclarationName::ObjCZeroArgSelector:    case DeclarationName::ObjCOneArgSelector:    case DeclarationName::ObjCMultiArgSelector:      Key.Data = -        (uint64_t)Reader.getLocalSelector( -                             F, endian::readNext<uint32_t, little, unaligned>( -                                    d)).getAsOpaquePtr(); +       (uint64_t)Reader.getLocalSelector(F, ReadUnalignedLE32(d)) +                   .getAsOpaquePtr();      break;    case DeclarationName::CXXOperatorName:      Key.Data = *d++; // OverloadedOperatorKind      break;    case DeclarationName::CXXLiteralOperatorName: -    Key.Data = (uint64_t)Reader.getLocalIdentifier( -        F, endian::readNext<uint32_t, little, unaligned>(d)); +    Key.Data = (uint64_t)Reader.getLocalIdentifier(F, ReadUnalignedLE32(d));      break;    case DeclarationName::CXXConstructorName:    case DeclarationName::CXXDestructorName: @@ -810,8 +800,8 @@ ASTDeclContextNameLookupTrait::data_type  ASTDeclContextNameLookupTrait::ReadData(internal_key_type,                                           const unsigned char* d,                                          unsigned DataLen) { -  using namespace llvm::support; -  unsigned NumDecls = endian::readNext<uint16_t, little, unaligned>(d); +  using namespace clang::io; +  unsigned NumDecls = ReadUnalignedLE16(d);    LE32DeclID *Start = reinterpret_cast<LE32DeclID *>(                          const_cast<unsigned char *>(d));    return std::make_pair(Start, Start + NumDecls); @@ -1364,18 +1354,16 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {  std::pair<unsigned, unsigned>  HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) { -  using namespace llvm::support; -  unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d); +  unsigned KeyLen = (unsigned) clang::io::ReadUnalignedLE16(d);    unsigned DataLen = (unsigned) *d++;    return std::make_pair(KeyLen, DataLen);  }  HeaderFileInfoTrait::internal_key_type  HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) { -  using namespace llvm::support;    internal_key_type ikey; -  ikey.Size = off_t(endian::readNext<uint64_t, little, unaligned>(d)); -  ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d)); +  ikey.Size = off_t(clang::io::ReadUnalignedLE64(d)); +  ikey.ModTime = time_t(clang::io::ReadUnalignedLE64(d));    ikey.Filename = (const char *)d;    return ikey;  } @@ -1384,7 +1372,7 @@ HeaderFileInfoTrait::data_type  HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,                                unsigned DataLen) {    const unsigned char *End = d + DataLen; -  using namespace llvm::support; +  using namespace clang::io;    HeaderFileInfo HFI;    unsigned Flags = *d++;    HFI.HeaderRole = static_cast<ModuleMap::ModuleHeaderRole> @@ -1394,11 +1382,10 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,    HFI.DirInfo = (Flags >> 2) & 0x03;    HFI.Resolved = (Flags >> 1) & 0x01;    HFI.IndexHeaderMapHeader = Flags & 0x01; -  HFI.NumIncludes = endian::readNext<uint16_t, little, unaligned>(d); -  HFI.ControllingMacroID = Reader.getGlobalIdentifierID( -      M, endian::readNext<uint32_t, little, unaligned>(d)); -  if (unsigned FrameworkOffset = -          endian::readNext<uint32_t, little, unaligned>(d)) { +  HFI.NumIncludes = ReadUnalignedLE16(d); +  HFI.ControllingMacroID = Reader.getGlobalIdentifierID(M,  +                                                        ReadUnalignedLE32(d)); +  if (unsigned FrameworkOffset = ReadUnalignedLE32(d)) {      // The framework offset is 1 greater than the actual offset,       // since 0 is used as an indicator for "no framework name".      StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1); @@ -1406,7 +1393,7 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,    }    if (d != End) { -    uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d); +    uint32_t LocalSMID = ReadUnalignedLE32(d);      if (LocalSMID) {        // This header is part of a module. Associate it with the module to enable        // implicit module import. @@ -2750,8 +2737,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {        ContinuousRangeMap<uint32_t, int, 2>::Builder TypeRemap(F.TypeRemap);        while(Data < DataEnd) { -        using namespace llvm::support; -        uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data); +        uint16_t Len = io::ReadUnalignedLE16(Data);          StringRef Name = StringRef((const char*)Data, Len);          Data += Len;          ModuleFile *OM = ModuleMgr.lookup(Name); @@ -2760,23 +2746,15 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {            return true;          } -        uint32_t SLocOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t IdentifierIDOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t MacroIDOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t PreprocessedEntityIDOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t SubmoduleIDOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t SelectorIDOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t DeclIDOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); -        uint32_t TypeIndexOffset = -            endian::readNext<uint32_t, little, unaligned>(Data); - +        uint32_t SLocOffset = io::ReadUnalignedLE32(Data); +        uint32_t IdentifierIDOffset = io::ReadUnalignedLE32(Data); +        uint32_t MacroIDOffset = io::ReadUnalignedLE32(Data); +        uint32_t PreprocessedEntityIDOffset = io::ReadUnalignedLE32(Data); +        uint32_t SubmoduleIDOffset = io::ReadUnalignedLE32(Data); +        uint32_t SelectorIDOffset = io::ReadUnalignedLE32(Data); +        uint32_t DeclIDOffset = io::ReadUnalignedLE32(Data); +        uint32_t TypeIndexOffset = io::ReadUnalignedLE32(Data); +                  // Source location offset is mapped to OM->SLocEntryBaseOffset.          SLocRemap.insert(std::make_pair(SLocOffset,            static_cast<int>(OM->SLocEntryBaseOffset - SLocOffset))); diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index ada02efc3f8..b9e6130bad8 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -82,9 +82,9 @@ public:    static std::pair<unsigned, unsigned>    ReadKeyDataLength(const unsigned char*& d) { -    using namespace llvm::support; -    unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d); -    unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d); +    using namespace clang::io; +    unsigned KeyLen = ReadUnalignedLE16(d); +    unsigned DataLen = ReadUnalignedLE16(d);      return std::make_pair(KeyLen, DataLen);    } @@ -101,11 +101,11 @@ public:    static data_type ReadData(const internal_key_type& k,                              const unsigned char* d,                              unsigned DataLen) { -    using namespace llvm::support; +    using namespace clang::io;      data_type Result;      while (DataLen > 0) { -      unsigned ID = endian::readNext<uint32_t, little, unaligned>(d); +      unsigned ID = ReadUnalignedLE32(d);        Result.push_back(ID);        DataLen -= 4;      } @@ -459,8 +459,8 @@ namespace {                         unsigned DataLen) {        // The first bit indicates whether this identifier is interesting.        // That's all we care about. -      using namespace llvm::support; -      unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d); +      using namespace clang::io; +      unsigned RawID = ReadUnalignedLE32(d);        bool IsInteresting = RawID & 0x01;        return std::make_pair(k, IsInteresting);      }  | 

