From 0c1b062ac0e139304e4b91ddcce32572e6072be6 Mon Sep 17 00:00:00 2001 From: Meghana Gupta Date: Thu, 11 Jun 2020 14:47:53 -0700 Subject: [PATCH] [NFC] Fix Projection print for Enum kind --- lib/SIL/Utils/Projection.cpp | 48 +++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) 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,