NFC: Add GenericSignature::getCanonicalSignature. (#29105)

Motivation: `GenericSignatureImpl::getCanonicalSignature` crashes for
`GenericSignature` with underlying `nullptr`. This led to verbose workarounds
when computing `CanGenericSignature` from `GenericSignature`.

Solution: `GenericSignature::getCanonicalSignature` is a wrapper around
`GenericSignatureImpl::getCanonicalSignature` that returns the canonical
signature, or `nullptr` if the underlying pointer is `nullptr`.

Rewrite all verbose workarounds using `GenericSignature::getCanonicalSignature`.
This commit is contained in:
Dan Zheng
2020-01-12 12:17:41 -08:00
committed by GitHub
parent 0d87a14785
commit 1486d6b346
42 changed files with 184 additions and 189 deletions

View File

@@ -152,7 +152,7 @@ bool SubstitutionMap::isCanonical() const {
SubstitutionMap SubstitutionMap::getCanonical() const {
if (empty()) return *this;
auto canonicalSig = getGenericSignature()->getCanonicalSignature();
auto canonicalSig = getGenericSignature().getCanonicalSignature();
SmallVector<Type, 4> replacementTypes;
for (Type replacementType : getReplacementTypesBuffer()) {
if (replacementType)