From c48ed9a9f6bbbe77bf7037d499f4dbaa0f374762 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Mon, 8 Sep 2014 20:36:26 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217402 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Serialization/ASTWriter.cpp | 5 ++++- test/Modules/Inputs/pch-used.h | 1 + test/Modules/pch-used.m | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 973d8a28e1..0b65d0a571 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -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; diff --git a/test/Modules/Inputs/pch-used.h b/test/Modules/Inputs/pch-used.h index 60e0097ea9..bc53bb37a9 100644 --- a/test/Modules/Inputs/pch-used.h +++ b/test/Modules/Inputs/pch-used.h @@ -1,2 +1,3 @@ @import cstd.stdio; +@import other_constants.dbl_max; static inline void SPXTrace() { fprintf(__stderrp, ""); } diff --git a/test/Modules/pch-used.m b/test/Modules/pch-used.m index 56961ba404..74f21f5dac 100644 --- a/test/Modules/pch-used.m +++ b/test/Modules/pch-used.m @@ -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 -- 2.50.1