From: Douglas Gregor Date: Fri, 6 Jan 2012 16:09:53 +0000 (+0000) Subject: Teach DeclContext deserialization to pay attention to endianness, from X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b8b20f7a4e2d2557fc49149ebd0df7a7b2c57dd;p=clang Teach DeclContext deserialization to pay attention to endianness, from David Fang and Takumi Nakamura. Fixes many PCH failures on PowerPC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147657 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index a7d143b030..2864fcf48b 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -747,7 +747,7 @@ ASTDeclContextNameLookupTrait::ReadData(internal_key_type, unsigned DataLen) { using namespace clang::io; unsigned NumDecls = ReadUnalignedLE16(d); - DeclID *Start = (DeclID *)d; + LE32DeclID *Start = (LE32DeclID *)d; return std::make_pair(Start, Start + NumDecls); } diff --git a/lib/Serialization/ASTReaderInternals.h b/lib/Serialization/ASTReaderInternals.h index fb6c8307ca..635f95fe59 100644 --- a/lib/Serialization/ASTReaderInternals.h +++ b/lib/Serialization/ASTReaderInternals.h @@ -15,6 +15,7 @@ #include "clang/Basic/OnDiskHashTable.h" #include "clang/AST/DeclarationName.h" +#include "llvm/Support/Endian.h" #include #include @@ -41,7 +42,8 @@ public: /// /// Note that these declaration IDs are local to the module that contains this /// particular lookup t - typedef std::pair data_type; + typedef llvm::support::ulittle32_t LE32DeclID; + typedef std::pair data_type; /// \brief Special internal key for declaration names. /// The hash table creates keys for comparison; we do not create