Skip to content

Commit b026a07

Browse files
author
Mark Lacey
committed
Add a scale-test counter for expression type checking.
Also add the first example of using the counter to test for known-exponential typechecking behavior for nil-coalescing.
1 parent 7b06b3d commit b026a07

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
#include "ConstraintSystem.h"
1919
#include "ConstraintGraph.h"
2020
#include "swift/AST/GenericEnvironment.h"
21+
#include "swift/Basic/Statistic.h"
2122
#include "llvm/ADT/SmallString.h"
2223
#include "llvm/Support/Compiler.h"
2324

2425
using namespace swift;
2526
using namespace constraints;
2627

28+
#define DEBUG_TYPE "ConstraintSystem"
29+
2730
ConstraintSystem::ConstraintSystem(TypeChecker &tc, DeclContext *dc,
2831
ConstraintSystemOptions options)
2932
: TC(tc), DC(dc), Options(options),
@@ -37,6 +40,11 @@ ConstraintSystem::~ConstraintSystem() {
3740
delete &CG;
3841
}
3942

43+
void ConstraintSystem::incrementScopeCounter() {
44+
SWIFT_FUNC_STAT;
45+
CountScopes++;
46+
}
47+
4048
bool ConstraintSystem::hasFreeTypeVariables() {
4149
// Look for any free type variables.
4250
for (auto tv : TypeVariables) {

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,7 @@ class ConstraintSystem {
12851285
return TypeCounter++;
12861286
}
12871287

1288-
void incrementScopeCounter() {
1289-
CountScopes++;
1290-
}
1288+
void incrementScopeCounter();
12911289

12921290
public:
12931291
/// \brief Introduces a new solver scope, which any changes to the
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: not %scale-test -O --begin 1 --end 3 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
func t(_ x: Int?) -> Int {
6+
return (x ?? 0)
7+
%for i in range(1, N):
8+
+ (x ?? 0)
9+
%end
10+
}

0 commit comments

Comments
 (0)