Preserve Sema::UndefinedInternals across PCH boundaries. Fixes
-Wundefined-internal warnings with PCH.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173538 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index c03d41e..c048276 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -385,7 +385,7 @@
 
   // Collect all the still-undefined entities with internal linkage.
   SmallVector<UndefinedInternal, 16> undefined;
-  for (llvm::DenseMap<NamedDecl*,SourceLocation>::iterator
+  for (llvm::MapVector<NamedDecl*,SourceLocation>::iterator
          i = S.UndefinedInternals.begin(), e = S.UndefinedInternals.end();
        i != e; ++i) {
     NamedDecl *decl = i->first;
@@ -407,23 +407,9 @@
         continue;
     }
 
-    // We build a FullSourceLoc so that we can sort with array_pod_sort.
-    FullSourceLoc loc(i->second, S.Context.getSourceManager());
-    undefined.push_back(UndefinedInternal(decl, loc));
-  }
-
-  if (undefined.empty()) return;
-
-  // Sort (in order of use site) so that we're not (as) dependent on
-  // the iteration order through an llvm::DenseMap.
-  llvm::array_pod_sort(undefined.begin(), undefined.end());
-
-  for (SmallVectorImpl<UndefinedInternal>::iterator
-         i = undefined.begin(), e = undefined.end(); i != e; ++i) {
-    NamedDecl *decl = i->decl;
     S.Diag(decl->getLocation(), diag::warn_undefined_internal)
       << isa<VarDecl>(decl) << decl;
-    S.Diag(i->useLoc, diag::note_used_here);
+    S.Diag(i->second, diag::note_used_here);
   }
 }
 
@@ -736,6 +722,8 @@
       }
     }
 
+    if (ExternalSource)
+      ExternalSource->ReadUndefinedInternals(UndefinedInternals);
     checkUndefinedInternals(*this);
   }
 
@@ -1080,6 +1068,10 @@
                            SmallVectorImpl<NamespaceDecl *> &Namespaces) {
 }
 
+void ExternalSemaSource::ReadUndefinedInternals(
+                      llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
+}
+
 void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const {
   SourceLocation Loc = this->Loc;
   if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation();