File tree Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -2712,13 +2712,18 @@ namespace {
2712
2712
return Impl.importDecl (decl->getSpecializedTemplate (),
2713
2713
Impl.CurrentVersion );
2714
2714
2715
+ bool isPair = decl->getSpecializedTemplate ()->isInStdNamespace () &&
2716
+ decl->getSpecializedTemplate ()->getName () == " pair" ;
2717
+
2715
2718
// Before we go any further, check if we've already got tens of thousands
2716
2719
// of specializations. If so, it means we're likely instantiating a very
2717
2720
// deep/complex template, or we've run into an infinite loop. In either
2718
2721
// case, its not worth the compile time, so bail.
2719
2722
// TODO: this could be configurable at some point.
2720
- if (llvm::size (decl->getSpecializedTemplate ()->specializations ()) >
2721
- 1000 ) {
2723
+ size_t specializationLimit = !isPair ? 1000 : 10000 ;
2724
+ if (!isPair &&
2725
+ llvm::size (decl->getSpecializedTemplate ()->specializations ()) >
2726
+ specializationLimit) {
2722
2727
std::string name;
2723
2728
llvm::raw_string_ostream os (name);
2724
2729
decl->printQualifiedName (os);
Original file line number Diff line number Diff line change @@ -22,3 +22,8 @@ module StdSet {
22
22
header "std-set.h"
23
23
requires cplusplus
24
24
}
25
+
26
+ module StdPair {
27
+ header "std-pair.h"
28
+ requires cplusplus
29
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include < utility>
4
+
5
+ using PairInts = std::pair<int , int >;
6
+
7
+ // FIXME: return pair by value, but it causes IRGen crash atm.
8
+ inline const PairInts &getIntPair () {
9
+ static PairInts value = { -5 , 12 };
10
+ return value;
11
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
2
+ //
3
+ // REQUIRES: executable_test
4
+ //
5
+ // REQUIRES: OS=macosx || OS=linux-gnu
6
+
7
+ import StdlibUnittest
8
+ import StdPair
9
+ import CxxStdlib
10
+ import Cxx
11
+
12
+ var StdPairTestSuite = TestSuite ( " StdPair " )
13
+
14
+ StdPairTestSuite . test ( " StdPair.elements " ) {
15
+ var pi = getIntPair ( ) . pointee
16
+ expectEqual ( pi. first, - 5 )
17
+ expectEqual ( pi. second, 12 )
18
+ pi. first = 11
19
+ expectEqual ( pi. first, 11 )
20
+ expectEqual ( pi. second, 12 )
21
+ }
22
+
23
+ runAllTests ( )
You can’t perform that action at this time.
0 commit comments