Skip to content

[SourceKit] Fix compiler warning. #15332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2018
Merged

[SourceKit] Fix compiler warning. #15332

merged 2 commits into from
Mar 19, 2018

Conversation

rayfix
Copy link
Contributor

@rayfix rayfix commented Mar 19, 2018

Use const_cast instead of C style cast.

Simple warning fix. Use const cast instead of C-style cast to prevent warning of removing const qualifier. (I am using this trivial PR to get practice.

No SR for this one AFAIK.

Use const_cast instead of C style cast.
@@ -247,7 +247,7 @@ void ResponseBuilder::Dictionary::setCustomBuffer(
std::unique_ptr<llvm::MemoryBuffer> CustomBuf;
CustomBuf = llvm::WritableMemoryBuffer::getNewUninitMemBuffer(
sizeof(uint64_t) + MemBuf->getBufferSize());
char *BufPtr = (char*)CustomBuf->getBufferStart();
char *BufPtr = const_cast<char*>(CustomBuf->getBufferStart());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the real problem is that the unique_ptr owns a llvm::MemoryBuffer instead of a llvm::WritableMemoryBuffer (which does the const_cast for you, the evil thing).

@rayfix
Copy link
Contributor Author

rayfix commented Mar 19, 2018

Good call @CodaFi Updated accordingly.

@CodaFi
Copy link
Contributor

CodaFi commented Mar 19, 2018

Thanks

@swift-ci please smoke test

@DougGregor DougGregor merged commit 8d490ef into swiftlang:master Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants