Skip to content

[Diag] Print the diagnostic ID name from localization #34319

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 10 commits into from
Mar 24, 2021

Conversation

HassanElDesouky
Copy link
Contributor

@xedin xedin self-requested a review October 15, 2020 18:46
@HassanElDesouky HassanElDesouky requested a review from xedin October 21, 2020 00:09
@HassanElDesouky HassanElDesouky force-pushed the localization-debug-diagnostics branch from 7f4cb0c to 651655e Compare March 14, 2021 15:39
Copy link
Contributor Author

@HassanElDesouky HassanElDesouky left a comment

Choose a reason for hiding this comment

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

I've been away from the project and C++ for quite some time now, so hopefully it's okay and I didn't made the problem worse with the allocator 😅

cc @xedin, @owenv

@HassanElDesouky HassanElDesouky requested a review from owenv March 17, 2021 08:44
Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

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

I don't entirely understand why it's important for the llvm::StringSaver to be an optional argument to the Localization producer constructors, but the rest of this change looks good to me for the most part 👍

@owenv
Copy link
Contributor

owenv commented Mar 20, 2021

@swift-ci please smoke test

@HassanElDesouky
Copy link
Contributor Author

I don't entirely understand why it's important for the llvm::StringSaver to be an optional argument to the Localization producer constructors.

My motive behind this was because localization producers might be used in a other places where it doesn't make sense to use either the StringSaver or printDiagnosticName flag. I.e. you can check the swift-serialize-diagnostics.cpp that's why I wanted to make both StringSaver and printDiagnosticName have default values. Do you think that make sense?

@owenv
Copy link
Contributor

owenv commented Mar 21, 2021

My motive behind this was because localization producers might be used in a other places where it doesn't make sense to use either the StringSaver or printDiagnosticName flag. I.e. you can check the swift-serialize-diagnostics.cpp that's why I wanted to make both StringSaver and printDiagnosticName have default values. Do you think that make sense?

Oh, I see, thanks for the explanation! I think that's reasonable, but could you add an assert that if printDiagnosticNames is true, the llvm::StringSaver is also present? I think that will make it a little easier to understand how the different pieces of this fit together

@HassanElDesouky
Copy link
Contributor Author

but could you add an assert that if printDiagnosticNames is true, the llvm::StringSaver is also present? I think that will make it a little easier to understand how the different pieces of this fit together

Yes of course! Going to add it now.

@HassanElDesouky HassanElDesouky requested a review from owenv March 21, 2021 19:03
@owenv
Copy link
Contributor

owenv commented Mar 21, 2021

@swift-ci please smoke test

@HassanElDesouky
Copy link
Contributor Author

@owenv I think the failure in macOS isn't related to my changes.

@HassanElDesouky HassanElDesouky requested a review from xedin March 23, 2021 08:47
Copy link
Contributor

@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.

Looks much better now, still needs a bit more work to get this across the finish line.

@HassanElDesouky HassanElDesouky requested a review from xedin March 23, 2021 20:42
Copy link
Contributor

@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.

LGTM!

// RUN: swift-serialize-diagnostics --input-file-path=%S/Inputs/en.yaml --output-directory=%t/ 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -debug-diagnostic-names -localization-path %S/Inputs -locale fr -typecheck %s 2>&1 | %FileCheck %s --check-prefix=CHECK_NAMES

// CHECK: These diagnostic IDs are no longer availiable: 'not_available_in_def, not_available_in_def_2, not_available_in_def_3, not_available_in_def_4, not_available_in_def_5'
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please remove these diagnostics from yaml in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course! But can you explain why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean shouldn't we be testing/checking on yaml.unknownIDs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since .def file is still a source of truth and if it doesn't have it the that diagnostic is no longer viable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay... makes sense thank you!

@xedin
Copy link
Contributor

xedin commented Mar 23, 2021

@swift-ci please smoke test

@HassanElDesouky
Copy link
Contributor Author

@xedin I'm not sure why CI is failing on macOS. I tried to take a look at the console output, however I can't quite understand it.

@xedin
Copy link
Contributor

xedin commented Mar 23, 2021

Don't worry, it's a driver issue people are already looking into.

@xedin
Copy link
Contributor

xedin commented Mar 24, 2021

@swift-ci please smoke test macOS platform

1 similar comment
@xedin
Copy link
Contributor

xedin commented Mar 24, 2021

@swift-ci please smoke test macOS platform

@xedin xedin merged commit 2eb57d2 into swiftlang:main Mar 24, 2021
@HassanElDesouky HassanElDesouky deleted the localization-debug-diagnostics branch March 25, 2021 20:17
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