[cfe-commits] r136395 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderStmt.cpp

Douglas Gregor dgregor at apple.com
Thu Jul 28 14:16:51 PDT 2011


Author: dgregor
Date: Thu Jul 28 16:16:51 2011
New Revision: 136395

URL: http://llvm.org/viewvc/llvm-project?rev=136395&view=rev
Log:
Use the local -> global mapping functions for selectors more
consistently in the ASTReader.

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=136395&r1=136394&r2=136395&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 28 16:16:51 2011
@@ -1443,13 +1443,17 @@
   /// \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

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=136395&r1=136394&r2=136395&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 28 16:16:51 2011
@@ -542,7 +542,7 @@
 
     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 @@
                            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 @@
     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 @@
   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 @@
   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 @@
   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(

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=136395&r1=136394&r2=136395&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Jul 28 16:16:51 2011
@@ -791,7 +791,7 @@
 
 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 @@
   if (Record[Idx++])
     E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(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);





More information about the cfe-commits mailing list