Skip to content

Commit cab6982

Browse files
committed
Sema: Fancier assertions in ConstraintGraph
1 parent 0c53543 commit cab6982

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Diff for: lib/Sema/ConstraintGraph.cpp

+20-8
Original file line numberDiff line numberDiff line change
@@ -289,26 +289,38 @@ void ConstraintGraphNode::truncateEquivalenceClass(unsigned prevSize) {
289289

290290
void ConstraintGraphNode::addReferencedVar(TypeVariableType *typeVar) {
291291
bool inserted = References.insert(typeVar);
292-
assert(inserted && "Attempt to reference a duplicate type variable");
293-
(void)inserted;
292+
if (!inserted) {
293+
llvm::errs() << "$T" << TypeVar->getImpl().getID() << " already "
294+
<< "references $T" << typeVar->getImpl().getID() << "\n";
295+
abort();
296+
}
294297
}
295298

296299
void ConstraintGraphNode::addReferencedBy(TypeVariableType *typeVar) {
297300
bool inserted = ReferencedBy.insert(typeVar);
298-
assert(inserted && "Already referenced by the given type variable");
299-
(void)inserted;
301+
if (!inserted) {
302+
llvm::errs() << "$T" << TypeVar->getImpl().getID() << " already "
303+
<< "referenced by $T" << typeVar->getImpl().getID() << "\n";
304+
abort();
305+
}
300306
}
301307

302308
void ConstraintGraphNode::removeReference(TypeVariableType *typeVar) {
303309
auto removed = References.remove(typeVar);
304-
assert(removed && "Variables are not connected");
305-
(void)removed;
310+
if (!removed) {
311+
llvm::errs() << "$T" << TypeVar->getImpl().getID() << " does not "
312+
<< "reference $T" << typeVar->getImpl().getID() << "\n";
313+
abort();
314+
}
306315
}
307316

308317
void ConstraintGraphNode::removeReferencedBy(TypeVariableType *typeVar) {
309318
auto removed = ReferencedBy.remove(typeVar);
310-
assert(removed && "Variables are not connected");
311-
(void)removed;
319+
if (!removed) {
320+
llvm::errs() << "$T" << TypeVar->getImpl().getID() << " not "
321+
<< "referenced by $T" << typeVar->getImpl().getID() << "\n";
322+
abort();
323+
}
312324
}
313325

314326
inference::PotentialBindings &ConstraintGraphNode::getCurrentBindings() {

0 commit comments

Comments
 (0)