diff --git a/lib/SIL/Utils/Projection.cpp b/lib/SIL/Utils/Projection.cpp index c54ab49ec5b0f..0cb8127bc26af 100644 --- a/lib/SIL/Utils/Projection.cpp +++ b/lib/SIL/Utils/Projection.cpp @@ -549,42 +549,46 @@ ProjectionPath::removePrefix(const ProjectionPath &Path, } void Projection::print(raw_ostream &os, SILType baseType) const { - if (isNominalKind()) { + switch (getKind()) { + case ProjectionKind::Struct: + case ProjectionKind::Class: { auto *Decl = getVarDecl(baseType); os << "Field: "; Decl->print(os); - return; - } - - if (getKind() == ProjectionKind::Tuple) { - os << "Index: " << getIndex(); - return; + break; } - if (getKind() == ProjectionKind::BitwiseCast) { - os << "BitwiseCast"; - return; + case ProjectionKind::Enum: { + auto *Decl = getEnumElementDecl(baseType); + os << "Enum: "; + Decl->print(os); + break; } - if (getKind() == ProjectionKind::Index) { + case ProjectionKind::Index: + case ProjectionKind::Tuple: { os << "Index: " << getIndex(); - return; + break; + } + case ProjectionKind::Box: { + os << " Box over"; + break; } - if (getKind() == ProjectionKind::Upcast) { + case ProjectionKind::Upcast: { os << "UpCast"; - return; + break; } - if (getKind() == ProjectionKind::RefCast) { + case ProjectionKind::RefCast: { os << "RefCast"; - return; + break; } - if (getKind() == ProjectionKind::Box) { - os << " Box over"; - return; + case ProjectionKind::BitwiseCast: { + os << "BitwiseCast"; + break; } - if (getKind() == ProjectionKind::TailElems) { + case ProjectionKind::TailElems: { os << " TailElems"; - return; + break; + } } - os << ""; } raw_ostream &ProjectionPath::print(raw_ostream &os, SILModule &M,