diff --git a/lib/SIL/Projection.cpp b/lib/SIL/Projection.cpp index d450907549e7b..b826c5859c40a 100644 --- a/lib/SIL/Projection.cpp +++ b/lib/SIL/Projection.cpp @@ -599,20 +599,7 @@ ProjectionPath::expandTypeIntoLeafProjectionPaths(SILType B, SILModule *Mod, LLVM_DEBUG(llvm::dbgs() << "Visiting type: " << Ty << "\n"); - // Get the first level projection of the current type. - Projections.clear(); - Projection::getFirstLevelProjections(Ty, *Mod, Projections); - - // Reached the end of the projection tree, this field can not be expanded - // anymore. - if (Projections.empty()) { - LLVM_DEBUG(llvm::dbgs() << " No projections. " - "Finished projection list\n"); - Paths.push_back(PP); - continue; - } - - // If this is a class type, we also have reached the end of the type + // If this is a class type, we have reached the end of the type // tree for this type. // // We do not push its next level projection into the worklist, @@ -635,6 +622,19 @@ ProjectionPath::expandTypeIntoLeafProjectionPaths(SILType B, SILModule *Mod, continue; } + // Get the first level projection of the current type. + Projections.clear(); + Projection::getFirstLevelProjections(Ty, *Mod, Projections); + + // Reached the end of the projection tree, this field can not be expanded + // anymore. + if (Projections.empty()) { + LLVM_DEBUG(llvm::dbgs() << " No projections. " + "Finished projection list\n"); + Paths.push_back(PP); + continue; + } + // Keep expanding the location. for (auto &P : Projections) { ProjectionPath X(B);