diff --git a/lib/AST/CASTBridging.cpp b/lib/AST/CASTBridging.cpp index c9f4c14a1790c..0bd565f008521 100644 --- a/lib/AST/CASTBridging.cpp +++ b/lib/AST/CASTBridging.cpp @@ -120,17 +120,19 @@ void *SwiftIdentifierExpr_create(void *ctx, BridgedIdentifier base, void *loc) { void *SwiftStringLiteralExpr_create(void *ctx, const uint8_t *_Nullable string, long len, void *TokenLoc) { ASTContext &Context = *static_cast(ctx); - return new (Context) StringLiteralExpr( - StringRef{reinterpret_cast(string), size_t(len)}, - getSourceLocFromPointer(TokenLoc)); + auto stringRef = Context.AllocateCopy( + StringRef{reinterpret_cast(string), size_t(len)}); + return new (Context) + StringLiteralExpr(stringRef, getSourceLocFromPointer(TokenLoc)); } void *SwiftIntegerLiteralExpr_create(void *ctx, const uint8_t *_Nullable string, long len, void *TokenLoc) { ASTContext &Context = *static_cast(ctx); - return new (Context) IntegerLiteralExpr( - StringRef{reinterpret_cast(string), size_t(len)}, - getSourceLocFromPointer(TokenLoc)); + auto stringRef = Context.AllocateCopy( + StringRef{reinterpret_cast(string), size_t(len)}); + return new (Context) + IntegerLiteralExpr(stringRef, getSourceLocFromPointer(TokenLoc)); } void *SwiftBooleanLiteralExpr_create(void *ctx, bool value, void *TokenLoc) {