diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-11 00:14:32 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-11 00:14:32 +0000 |
commit | 3ed42cb0b3705eae3d54224d068a7a0970c3c2f9 (patch) | |
tree | 2455b74ea4d684f073ba960956266f3928b1f22a /clang/lib/Frontend/PCHReader.cpp | |
parent | df24000d2495ede0ea449c03a831b40e522082c9 (diff) | |
download | bcm5719-llvm-3ed42cb0b3705eae3d54224d068a7a0970c3c2f9.tar.gz bcm5719-llvm-3ed42cb0b3705eae3d54224d068a7a0970c3c2f9.zip |
Store unique IDs for identifiers in the PCH file. Use some bitmangling
so that we only need to perform the lookup and identifier resolution
once per identifier in the PCH file.
llvm-svn: 68846
Diffstat (limited to 'clang/lib/Frontend/PCHReader.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 345e673b471..b21beed307a 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -477,7 +477,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCHBlock() { return IgnorePCH; break; - case pch::TARGET_TRIPLE: + case pch::TARGET_TRIPLE: { std::string TargetTriple(BlobStart, BlobLen); if (TargetTriple != Context.Target.getTargetTriple()) { Diag(diag::warn_pch_target_triple) @@ -487,6 +487,27 @@ PCHReader::PCHReadResult PCHReader::ReadPCHBlock() { } break; } + + case pch::IDENTIFIER_TABLE: + IdentifierTable = BlobStart; + break; + + case pch::IDENTIFIER_OFFSET: + if (!IdentifierData.empty()) { + Error("Duplicate IDENTIFIER_OFFSET record in PCH file"); + return Failure; + } + IdentifierData.swap(Record); +#ifndef NDEBUG + for (unsigned I = 0, N = IdentifierData.size(); I != N; ++I) { + if ((IdentifierData[I] & 0x01) == 0) { + Error("Malformed identifier table in the precompiled header"); + return Failure; + } + } +#endif + break; + } } Error("Premature end of bitstream"); @@ -927,13 +948,22 @@ void PCHReader::PrintStats() { const IdentifierInfo *PCHReader::GetIdentifierInfo(const RecordData &Record, unsigned &Idx) { - // FIXME: we need unique IDs for identifiers. - std::string Str; - unsigned Length = Record[Idx++]; - Str.resize(Length); - for (unsigned I = 0; I != Length; ++I) - Str[I] = Record[Idx++]; - return &Context.Idents.get(Str); + pch::IdentID ID = Record[Idx++]; + if (ID == 0) + return 0; + + if (!IdentifierTable || IdentifierData.empty()) { + Error("No identifier table in PCH file"); + return 0; + } + + if (IdentifierData[ID - 1] & 0x01) { + uint64_t Offset = IdentifierData[ID - 1]; + IdentifierData[ID - 1] = reinterpret_cast<uint64_t>( + &Context.Idents.get(IdentifierTable + Offset)); + } + + return reinterpret_cast<const IdentifierInfo *>(IdentifierData[ID - 1]); } DeclarationName |