Fix PCHs that import more than one module
authorBen Langmuir <blangmuir@apple.com>
Mon, 8 Sep 2014 20:36:26 +0000 (20:36 +0000)
committerBen Langmuir <blangmuir@apple.com>
Mon, 8 Sep 2014 20:36:26 +0000 (20:36 +0000)
We were passing < to std::unique, but it expects ==. Since the input is
sorted, we were always trimming it to one entry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217402 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTWriter.cpp
test/Modules/Inputs/pch-used.h
test/Modules/pch-used.m

index 973d8a28e1412ce7e4f3419fcc02560c1575f611..0b65d0a571da185afe14766b47d6de6500ffdbfc 100644 (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;
index 60e0097ea909e2e6dcd13d5c0c1f5fe241fb43dd..bc53bb37a9df36df4667adfd15c2a4ea09102d97 100644 (file)
@@ -1,2 +1,3 @@
 @import cstd.stdio;
+@import other_constants.dbl_max;
 static inline void SPXTrace() { fprintf(__stderrp, ""); }
index 56961ba404cc4d50a86849f782d3bd929ce87192..74f21f5dac0f1f19ded9520337cf4f74fde56765 100644 (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