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

[SR-13774] Utilize DefineDiagnosticMacros.h to shorten macro expansion arrays #56171

Closed
swift-ci opened this issue Oct 25, 2020 · 9 comments
Closed
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13774
Radar rdar://problem/70686874
Original Reporter hassaneldesouky (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, StarterBug
Assignee hassaneldesouky (JIRA)
Priority Medium

md5: 532d5c577999649781cbabde1b39b8a9

Issue Description:

There are a few arrays in the compiler's diagnostic engine that uses macro expansion to fill its content.

For example, the diagnosticStrings[] in DiagnosticEngine.cpp... it's defined as the following:

static constexpr const char *const debugDiagnosticStrings[] = {
#define ERROR(ID, Options, Text, Signature) Text " [" #ID "]",
#define WARNING(ID, Options, Text, Signature) Text " [" #ID "]",
#define NOTE(ID, Options, Text, Signature) Text " [" #ID "]",
#define REMARK(ID, Options, Text, Signature) Text " [" #ID "]",
#include "swift/AST/DiagnosticsAll.def"
    "<not a diagnostic>",
};

Based on DefineDiagnosticMacros.h we can shorten these lines to one line like the following:

static constexpr const char *const debugDiagnosticStrings[] = {
#define DIAG(KIND, ID, Options, Text, Signature) Text " [" #ID "]",
#include "swift/AST/DiagnosticsAll.def"
    "<not a diagnostic>",
};

The task is to shorten all of the similar arrays.

@swift-ci
Copy link
Collaborator Author

Comment by Hassan ElDesouky (JIRA)

@xedin, owenvoorhees (JIRA User) I think this can be a nice starter bug. If so, do you think this is nicely written to help new contributors?

@swift-ci
Copy link
Collaborator Author

Comment by Owen Voorhees (JIRA)

Looks like a good starter bug to me!. For anyone working on this, you should be able to find all instances of the pattern by searching the codebase for imports of swift/AST/DiagnosticsAll.def. There may also be a few cases where only a subset of the diagnostic types (error/warning/note/remark) are defined, and in those cases we shouldn't make any changes.

@typesanitizer
Copy link

@swift-ci create

@xedin
Copy link
Member

xedin commented Oct 26, 2020

Thank you, hassaneldesouky (JIRA User)!

@swift-ci
Copy link
Collaborator Author

Comment by Mohammed Al-Dahleh (JIRA)

I'm interested in trying this out.

@swift-ci
Copy link
Collaborator Author

Comment by Saidhon Orifov (JIRA)

Hey maldahleh (JIRA User), are you still working on this? I have changes ready for this story

@swift-ci
Copy link
Collaborator Author

Comment by Mohammed Al-Dahleh (JIRA)

Hey saidhon (JIRA User), I didn't do much on it yet, so feel free to assign it to yourself.

@swift-ci
Copy link
Collaborator Author

Comment by Saidhon Orifov (JIRA)

Thank you, maldahleh (JIRA User)

@LucianoPAlmeida
Copy link
Collaborator

Resolved by #34488

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement
Projects
None yet
Development

No branches or pull requests

4 participants