Skip to content

Commit 520636c

Browse files
authored
Merge pull request #63635 from apple/compnerd/stack-corruption
IRGen: correct Twine handling
2 parents 4148684 + bba913b commit 520636c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/IRGen/GenTuple.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,13 @@ namespace {
8686
auto slot = IGF.Builder.CreateInBoundsGEP(IGF.IGM.TupleTypeMetadataTy,
8787
asTuple, indices);
8888

89-
Twine name = [&]() -> Twine {
90-
if (auto *constantIndex = dyn_cast<llvm::ConstantInt>(index)) {
91-
return metadata->getName() + "." +
92-
Twine(constantIndex->getValue().getLimitedValue()) + ".offset";
93-
} else {
94-
return metadata->getName() + ".dynamic.offset";
95-
}
96-
}();
89+
std::string name;
90+
if (auto *constantIndex = dyn_cast<llvm::ConstantInt>(index))
91+
name = (metadata->getName() + "." +
92+
Twine(constantIndex->getValue().getLimitedValue()) + ".offset")
93+
.str();
94+
else
95+
name = (metadata->getName() + ".dynamic.offset").str();
9796

9897
return IGF.Builder.CreateLoad(slot, IGF.IGM.Int32Ty,
9998
IGF.IGM.getPointerAlignment(), name);

0 commit comments

Comments
 (0)