Sema: Add some asserts

This commit is contained in:
Slava Pestov
2016-12-25 13:25:59 -05:00
parent fd3101ef7c
commit 71df32fd7d
2 changed files with 7 additions and 2 deletions

View File

@@ -1387,7 +1387,9 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
bool isDynamicResult bool isDynamicResult
= choice.getKind() == OverloadChoiceKind::DeclViaDynamic; = choice.getKind() == OverloadChoiceKind::DeclViaDynamic;
// Retrieve the type of a reference to the specific declaration choice. // Retrieve the type of a reference to the specific declaration choice.
if (choice.getBaseType()) { if (auto baseTy = choice.getBaseType()) {
assert(!baseTy->hasTypeParameter());
auto getDotBase = [](const Expr *E) -> const DeclRefExpr * { auto getDotBase = [](const Expr *E) -> const DeclRefExpr * {
if (E == nullptr) return nullptr; if (E == nullptr) return nullptr;
switch (E->getKind()) { switch (E->getKind()) {
@@ -1406,7 +1408,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
auto anchor = locator ? locator->getAnchor() : nullptr; auto anchor = locator ? locator->getAnchor() : nullptr;
auto base = getDotBase(anchor); auto base = getDotBase(anchor);
std::tie(openedFullType, refType) std::tie(openedFullType, refType)
= getTypeOfMemberReference(choice.getBaseType(), choice.getDecl(), = getTypeOfMemberReference(baseTy, choice.getDecl(),
isTypeReference, isDynamicResult, isTypeReference, isDynamicResult,
choice.getFunctionRefKind(), choice.getFunctionRefKind(),
locator, base, nullptr); locator, base, nullptr);

View File

@@ -105,6 +105,7 @@ public:
FunctionRefKind functionRefKind) FunctionRefKind functionRefKind)
: BaseAndBits(base, isSpecialized ? IsSpecializedBit : 0), : BaseAndBits(base, isSpecialized ? IsSpecializedBit : 0),
TheFunctionRefKind(functionRefKind) { TheFunctionRefKind(functionRefKind) {
assert(!base || !base->hasTypeParameter());
assert((reinterpret_cast<uintptr_t>(value) & (uintptr_t)0x03) == 0 && assert((reinterpret_cast<uintptr_t>(value) & (uintptr_t)0x03) == 0 &&
"Badly aligned decl"); "Badly aligned decl");
@@ -115,6 +116,7 @@ public:
FunctionRefKind functionRefKind) FunctionRefKind functionRefKind)
: BaseAndBits(base, isSpecialized ? IsSpecializedBit : 0), : BaseAndBits(base, isSpecialized ? IsSpecializedBit : 0),
TheFunctionRefKind(functionRefKind) { TheFunctionRefKind(functionRefKind) {
assert(!base || !base->hasTypeParameter());
assert((reinterpret_cast<uintptr_t>(type) & (uintptr_t)0x03) == 0 assert((reinterpret_cast<uintptr_t>(type) & (uintptr_t)0x03) == 0
&& "Badly aligned decl"); && "Badly aligned decl");
DeclOrKind = reinterpret_cast<uintptr_t>(type) | 0x01; DeclOrKind = reinterpret_cast<uintptr_t>(type) | 0x01;
@@ -125,6 +127,7 @@ public:
DeclOrKind((uintptr_t)kind << 2 | (uintptr_t)0x03), DeclOrKind((uintptr_t)kind << 2 | (uintptr_t)0x03),
TheFunctionRefKind(FunctionRefKind::Unapplied) { TheFunctionRefKind(FunctionRefKind::Unapplied) {
assert(base && "Must have a base type for overload choice"); assert(base && "Must have a base type for overload choice");
assert(!base->hasTypeParameter());
assert(kind != OverloadChoiceKind::Decl && assert(kind != OverloadChoiceKind::Decl &&
kind != OverloadChoiceKind::DeclViaDynamic && kind != OverloadChoiceKind::DeclViaDynamic &&
kind != OverloadChoiceKind::TypeDecl && kind != OverloadChoiceKind::TypeDecl &&