r217402 - Fix PCHs that import more than one module

Ben Langmuir blangmuir at apple.com
Mon Sep 8 13:36:27 PDT 2014


Author: benlangmuir
Date: Mon Sep  8 15:36:26 2014
New Revision: 217402

URL: http://llvm.org/viewvc/llvm-project?rev=217402&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/test/Modules/Inputs/pch-used.h
    cfe/trunk/test/Modules/pch-used.m

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=217402&r1=217401&r2=217402&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Sep  8 15:36:26 2014
@@ -4617,10 +4617,13 @@ void ASTWriter::WriteASTCore(Sema &SemaR
       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;

Modified: cfe/trunk/test/Modules/Inputs/pch-used.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/pch-used.h?rev=217402&r1=217401&r2=217402&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/pch-used.h (original)
+++ cfe/trunk/test/Modules/Inputs/pch-used.h Mon Sep  8 15:36:26 2014
@@ -1,2 +1,3 @@
 @import cstd.stdio;
+ at import other_constants.dbl_max;
 static inline void SPXTrace() { fprintf(__stderrp, ""); }

Modified: cfe/trunk/test/Modules/pch-used.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pch-used.m?rev=217402&r1=217401&r2=217402&view=diff
==============================================================================
--- cfe/trunk/test/Modules/pch-used.m (original)
+++ cfe/trunk/test/Modules/pch-used.m Mon Sep  8 15:36:26 2014
@@ -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





More information about the cfe-commits mailing list