Skip to content

Commit 6f68ab2

Browse files
committed
Swap create APIs to take in a StringRef
1 parent 8d58ba8 commit 6f68ab2

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

tools/SourceKit/tools/sourcekitd/include/sourcekitd/Internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ void handleRequest(sourcekitd_object_t Request, ResponseReceiver Receiver);
160160
void printRequestObject(sourcekitd_object_t Obj, llvm::raw_ostream &OS);
161161
void printResponse(sourcekitd_response_t Resp, llvm::raw_ostream &OS);
162162

163-
sourcekitd_response_t createErrorRequestInvalid(const char *Description);
163+
sourcekitd_response_t createErrorRequestInvalid(llvm::StringRef Description);
164164
sourcekitd_response_t createErrorRequestFailed(llvm::StringRef Description);
165-
sourcekitd_response_t createErrorRequestInterrupted(const char *Description);
165+
sourcekitd_response_t createErrorRequestInterrupted(llvm::StringRef Descr);
166166
sourcekitd_response_t createErrorRequestCancelled();
167167

168168
/// Send notification object.

tools/SourceKit/tools/sourcekitd/lib/API/sourcekitdAPI-InProc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,15 +792,15 @@ Optional<int64_t> RequestDict::getOptionalInt64(SourceKit::UIdent Key) {
792792
}
793793

794794
sourcekitd_response_t
795-
sourcekitd::createErrorRequestInvalid(const char *Description) {
795+
sourcekitd::createErrorRequestInvalid(StringRef Description) {
796796
return retained(new SKDError(SOURCEKITD_ERROR_REQUEST_INVALID,
797-
StringRef(Description)));
797+
Description));
798798
}
799799

800800
sourcekitd_response_t
801801
sourcekitd::createErrorRequestFailed(StringRef Description) {
802802
return retained(new SKDError(SOURCEKITD_ERROR_REQUEST_FAILED,
803-
Description));
803+
Description));
804804
}
805805

806806
sourcekitd_response_t

tools/SourceKit/tools/sourcekitd/lib/API/sourcekitdAPI-XPC.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,25 @@ class CustomXPCData {
6969
return getPtr()+1;
7070
}
7171

72-
static CustomXPCData createErrorRequestInvalid(const char *Description) {
72+
static CustomXPCData createErrorRequestInvalid(StringRef Description) {
7373
return createKindAndString(Kind::ErrorRequestInvalid, Description);
7474
}
75-
static CustomXPCData createErrorRequestFailed(const char *Description) {
75+
static CustomXPCData createErrorRequestFailed(StringRef Description) {
7676
return createKindAndString(Kind::ErrorRequestFailed, Description);
7777
}
78-
static CustomXPCData createErrorRequestInterrupted(const char *Description) {
78+
static CustomXPCData createErrorRequestInterrupted(StringRef Description) {
7979
return createKindAndString(Kind::ErrorRequestInterrupted, Description);
8080
}
81-
static CustomXPCData createErrorRequestCancelled(const char *Description) {
81+
static CustomXPCData createErrorRequestCancelled(StringRef Description) {
8282
return createKindAndString(Kind::ErrorRequestCancelled, Description);
8383
}
8484

8585
private:
86-
static CustomXPCData createKindAndString(Kind K, const char *Str) {
86+
static CustomXPCData createKindAndString(Kind K, StringRef Str) {
8787
llvm::SmallVector<char, 128> Buf;
8888
Buf.push_back((char)K);
89-
Buf.append(Str, Str+strlen(Str)+1);
89+
Buf.append(Str.begin(), Str.end());
90+
Buf.push_back('\0');
9091
return CustomXPCData(xpc_data_create(Buf.begin(), Buf.size()));
9192
}
9293

@@ -375,21 +376,20 @@ Optional<int64_t> RequestDict::getOptionalInt64(SourceKit::UIdent Key) {
375376
}
376377

377378
sourcekitd_response_t
378-
sourcekitd::createErrorRequestInvalid(const char *Description) {
379+
sourcekitd::createErrorRequestInvalid(StringRef Description) {
379380
return CustomXPCData::createErrorRequestInvalid(Description).getXObj();
380381
}
381382
sourcekitd_response_t
382-
sourcekitd::createErrorRequestFailed(StringRef DescRef) {
383-
std::string Desc = DescRef.str();
384-
return CustomXPCData::createErrorRequestFailed(Desc.c_str()).getXObj();
383+
sourcekitd::createErrorRequestFailed(StringRef Description) {
384+
return CustomXPCData::createErrorRequestFailed(Description).getXObj();
385385
}
386386
sourcekitd_response_t
387-
sourcekitd::createErrorRequestInterrupted(const char *Description) {
387+
sourcekitd::createErrorRequestInterrupted(StringRef Description) {
388388
return CustomXPCData::createErrorRequestInterrupted(Description).getXObj();
389389
}
390390
sourcekitd_response_t
391391
sourcekitd::createErrorRequestCancelled() {
392-
return CustomXPCData::createErrorRequestCancelled("").getXObj();
392+
return CustomXPCData::createErrorRequestCancelled(StringRef("")).getXObj();
393393
}
394394

395395
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)