Skip to content
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

[Diag] Refactor diagnosticStringFor to return StringRef #33502

Merged
merged 1 commit into from Aug 17, 2020

Conversation

HassanElDesouky
Copy link
Contributor

@HassanElDesouky HassanElDesouky commented Aug 17, 2020

To make #33422 easier to review, I decided to open this PR.

When I was testing #33422 and returning diagnostic messages from the hash table, there was a mismatch in some diagnostic messages because there was an extra 0x01 byte at the end of every diagnostic message.

Currently, diagnosticStringFor returns a const char * obtained by calling data() on a StringRef coming from LocalizationProducer::getMessageOr. Since, StringRef isn't null-terminated, when converting it to a pointer and then back to a StringRef later - in DiagnosticInfo - causes the length to be wrong.

When changing diagnosticStringFor to return an llvm::StringRef instead and removing the calls to data(), the tests in #33422 will pass.

cc @xedin, @owenv

Signed-off-by: HassanElDesouky <hassaneldesouky@icloud.com>
Copy link
Member

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Makes sense, thank you!

@xedin
Copy link
Member

xedin commented Aug 17, 2020

@swift-ci please test

@xedin xedin merged commit e7086d1 into apple:master Aug 17, 2020
@HassanElDesouky HassanElDesouky deleted the localization-refactor-DE branch August 18, 2020 07:19
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.

None yet

2 participants