Revert my changes that try to avoid creating StringMap entries for
identifiers. They don't yet work, but will inhibit future
optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70071 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 918fd93..005436d 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1245,8 +1245,8 @@
   static std::pair<unsigned, unsigned>
   ReadKeyDataLength(const unsigned char*& d) {
     using namespace clang::io;
-    unsigned DataLen = ReadUnalignedLE16(d);
     unsigned KeyLen = ReadUnalignedLE16(d);
+    unsigned DataLen = ReadUnalignedLE16(d);
     return std::make_pair(KeyLen, DataLen);
   }
     
@@ -1282,7 +1282,8 @@
     // the new IdentifierInfo.
     IdentifierInfo *II = KnownII;
     if (!II)
-      II = &Reader.BuildIdentifierInfoInsidePCH((const unsigned char *)k.first);
+      II = &Reader.getIdentifierTable().CreateIdentifierInfo(
+                                                 k.first, k.first + k.second);
     Reader.SetIdentifierInfo(ID, II);
 
     // Set or check the various bits in the IdentifierInfo structure.
@@ -2848,19 +2849,6 @@
   return IdentifiersLoaded[ID - 1];
 }
 
-IdentifierInfo &
-PCHReader::BuildIdentifierInfoInsidePCH(const unsigned char *Str) {
-  // Allocate the object.
-  std::pair<IdentifierInfo,const unsigned char*> *Mem =
-    Alloc.Allocate<std::pair<IdentifierInfo,const unsigned char*> >();
-
-  // Build the IdentifierInfo itself.
-  Mem->second = Str;
-  assert(Str[0] != '\0');
-  IdentifierInfo *II = new ((void*) Mem) IdentifierInfo();
-  return *II;
-}
-
 Selector PCHReader::DecodeSelector(unsigned ID) {
   if (ID == 0)
     return Selector();
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 7eb398c..4ac8364 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -2013,6 +2013,7 @@
     EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II, 
                       pch::IdentID ID) {
     unsigned KeyLen = strlen(II->getName()) + 1;
+    clang::io::Emit16(Out, KeyLen);
     unsigned DataLen = 4 + 4; // 4 bytes for token ID, builtin, flags
                               // 4 bytes for the persistent ID
     if (II->hasMacroDefinition() && 
@@ -2022,14 +2023,7 @@
                                    DEnd = IdentifierResolver::end();
          D != DEnd; ++D)
       DataLen += sizeof(pch::DeclID);
-
-    // We emit the data length before the key length, because we want
-    // the key length to immediately precede the actual string
-    // data. This is so that our identifier length + key layout
-    // matches that of the identifier hash table for pretokenized
-    // headers.
     clang::io::Emit16(Out, DataLen);
-    clang::io::Emit16(Out, KeyLen);
     return std::make_pair(KeyLen, DataLen);
   }