From 2d2689ab787c6d54cb985c28ff3f16370bc01b0f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 28 Jul 2011 21:16:51 +0000 Subject: [PATCH] Use the local -> global mapping functions for selectors more consistently in the ASTReader. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136395 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Serialization/ASTReader.h | 10 +++++++--- lib/Serialization/ASTReader.cpp | 21 +++++++++++++-------- lib/Serialization/ASTReaderStmt.cpp | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 319c231cfa..f64e5eb458 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1443,13 +1443,17 @@ public: /// \brief Read the source location entry with index ID. virtual bool ReadSLocEntry(int ID); - Selector DecodeSelector(unsigned Idx); + /// \brief Retrieve a selector from the given module with its local ID + /// number. + Selector getLocalSelector(Module &M, unsigned LocalID); + + Selector DecodeSelector(serialization::SelectorID Idx); virtual Selector GetExternalSelector(serialization::SelectorID ID); uint32_t GetNumExternalSelectors(); - Selector GetSelector(const RecordData &Record, unsigned &Idx) { - return DecodeSelector(Record[Idx++]); + Selector ReadSelector(Module &M, const RecordData &Record, unsigned &Idx) { + return getLocalSelector(M, Record[Idx++]); } /// \brief Retrieve the global selector ID that corresponds to this diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 1c9c106f1d..0fc9d216a0 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -542,7 +542,7 @@ public: data_type Result; - Result.ID = ReadUnalignedLE32(d); + Result.ID = Reader.getGlobalSelectorID(F, ReadUnalignedLE32(d)); unsigned NumInstanceMethods = ReadUnalignedLE16(d); unsigned NumFactoryMethods = ReadUnalignedLE16(d); @@ -649,7 +649,7 @@ public: const unsigned char* d, unsigned DataLen) { using namespace clang::io; - IdentID ID = ReadUnalignedLE32(d); + IdentID ID = Reader.getGlobalSelectorID(F, ReadUnalignedLE32(d)); bool IsInteresting = ID & 0x01; // Wipe out the "is interesting" bit. @@ -883,12 +883,13 @@ public: case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCMultiArgSelector: Key.Data = - (uint64_t)Reader.DecodeSelector(ReadUnalignedLE32(d)).getAsOpaquePtr(); + (uint64_t)Reader.getLocalSelector(F, ReadUnalignedLE32(d)) + .getAsOpaquePtr(); break; case DeclarationName::CXXConstructorName: case DeclarationName::CXXDestructorName: case DeclarationName::CXXConversionFunctionName: - Key.Data = ReadUnalignedLE32(d); // TypeID + Key.Data = Reader.getGlobalTypeID(F, ReadUnalignedLE32(d)); // TypeID break; case DeclarationName::CXXOperatorName: Key.Data = *d++; // OverloadedOperatorKind @@ -1747,12 +1748,12 @@ typedef OnDiskChainedHashTable HeaderFileInfoLookupTable; void ASTReader::SetIdentifierIsMacro(IdentifierInfo *II, Module &F, - uint64_t Offset) { + uint64_t LocalOffset) { // Note that this identifier has a macro definition. II->setHasMacroDefinition(true); // Adjust the offset to a global offset. - UnreadMacroRecordOffsets[II] = F.GlobalBitOffset + Offset; + UnreadMacroRecordOffsets[II] = F.GlobalBitOffset + LocalOffset; } void ASTReader::ReadDefinedMacros() { @@ -4774,7 +4775,11 @@ bool ASTReader::ReadSLocEntry(int ID) { return ReadSLocEntryRecord(ID) != Success; } -Selector ASTReader::DecodeSelector(unsigned ID) { +Selector ASTReader::getLocalSelector(Module &M, unsigned LocalID) { + return DecodeSelector(getGlobalSelectorID(M, LocalID)); +} + +Selector ASTReader::DecodeSelector(serialization::SelectorID ID) { if (ID == 0) return Selector(); @@ -4825,7 +4830,7 @@ ASTReader::ReadDeclarationName(Module &F, case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCMultiArgSelector: - return DeclarationName(GetSelector(Record, Idx)); + return DeclarationName(ReadSelector(F, Record, Idx)); case DeclarationName::CXXConstructorName: return Context->DeclarationNames.getCXXConstructorName( diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 5e8262b947..cfe46d75b1 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -791,7 +791,7 @@ void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { VisitExpr(E); - E->setSelector(Reader.GetSelector(Record, Idx)); + E->setSelector(Reader.ReadSelector(F, Record, Idx)); E->setAtLoc(ReadSourceLocation(Record, Idx)); E->setRParenLoc(ReadSourceLocation(Record, Idx)); } @@ -867,7 +867,7 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { if (Record[Idx++]) E->setMethodDecl(ReadDeclAs(Record, Idx)); else - E->setSelector(Reader.GetSelector(Record, Idx)); + E->setSelector(Reader.ReadSelector(F, Record, Idx)); E->LBracLoc = ReadSourceLocation(Record, Idx); E->RBracLoc = ReadSourceLocation(Record, Idx); -- 2.40.0