@@ -17,6 +17,8 @@ using namespace swift;
1717
1818namespace {
1919struct BridgedDiagnosticImpl {
20+ typedef llvm::MallocAllocator Allocator;
21+
2022 InFlightDiagnostic inFlight;
2123 std::vector<StringRef> textBlobs;
2224
@@ -31,8 +33,10 @@ struct BridgedDiagnosticImpl {
3133
3234 ~BridgedDiagnosticImpl () {
3335 inFlight.flush ();
36+
37+ Allocator allocator;
3438 for (auto text : textBlobs) {
35- free (( void *) text.data ());
39+ allocator. Deallocate (text. data (), text.size ());
3640 }
3741 }
3842};
@@ -100,8 +104,8 @@ BridgedDiagnostic Diagnostic_create(BridgedDiagnosticEngine cDiags,
100104 BridgedSourceLoc cLoc,
101105 BridgedString cText) {
102106 StringRef origText = convertString (cText);
103- llvm::MallocAllocator mallocAlloc ;
104- StringRef text = origText.copy (mallocAlloc );
107+ BridgedDiagnosticImpl::Allocator alloc ;
108+ StringRef text = origText.copy (alloc );
105109
106110 SourceLoc loc = convertSourceLoc (cLoc);
107111
@@ -148,8 +152,8 @@ void Diagnostic_fixItReplace(BridgedDiagnostic cDiag,
148152 SourceLoc endLoc = convertSourceLoc (cEndLoc);
149153
150154 StringRef origReplaceText = convertString (cReplaceText);
151- llvm::MallocAllocator mallocAlloc ;
152- StringRef replaceText = origReplaceText.copy (mallocAlloc );
155+ BridgedDiagnosticImpl::Allocator alloc ;
156+ StringRef replaceText = origReplaceText.copy (alloc );
153157
154158 BridgedDiagnosticImpl *diag = convertDiagnostic (cDiag);
155159 diag->textBlobs .push_back (replaceText);
0 commit comments