Fix PCHs that import more than one module

We were passing < to std::unique, but it expects ==. Since the input is
sorted, we were always trimming it to one entry.

llvm-svn: 217402
This commit is contained in:
Ben Langmuir 2014-09-08 20:36:26 +00:00
parent 18f0a986c1
commit 5f95c8fc5f
3 changed files with 6 additions and 1 deletions

View File

@ -4617,10 +4617,13 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
auto Cmp = [](const ModuleInfo &A, const ModuleInfo &B) {
return A.ID < B.ID;
};
auto Eq = [](const ModuleInfo &A, const ModuleInfo &B) {
return A.ID == B.ID;
};
// Sort and deduplicate module IDs.
std::sort(Imports.begin(), Imports.end(), Cmp);
Imports.erase(std::unique(Imports.begin(), Imports.end(), Cmp),
Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
Imports.end());
RecordData ImportedModules;

View File

@ -1,2 +1,3 @@
@import cstd.stdio;
@import other_constants.dbl_max;
static inline void SPXTrace() { fprintf(__stderrp, ""); }

View File

@ -4,5 +4,6 @@
// RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s
void f() { SPXTrace(); }
void g() { double x = DBL_MAX; }
// CHECK: define internal void @SPXTrace