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

Simplify the API for Reporting Parser Warnings #3052

Conversation

InsertCreativityHere
Copy link
Member

This PR simplifies how warnings are reported by the parser and compilers.
Previously we had 2 warnings: one on Unit (think: a compilation run) and one on DefinitionContext (think: a file).

This is already asymetric, but was also a pain since then we had to look up the context using a file name... which was doubly weird since we already had to pass in a file name to warning anyways... and sometimes these could differ.


This PR simplifies all this.
Now, all diagnostic reporting is handled by Unit. There are 2 functions for error and 2 functions for warning.
One pair takes an explicit file name/line number, the other doesn't (and automatically uses the parser's current position).

Copy link
Member

@pepone pepone left a comment

Choose a reason for hiding this comment

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

Looks good

@@ -226,11 +226,9 @@ namespace Slice
bool hasMetadata(std::string_view directive) const;
std::optional<std::string> getMetadataArgs(std::string_view directive) const;

/// Emits a warning unless it should be filtered out by a [["suppress-warning"]].
void warning(WarningCategory category, const std::string& file, int line, const std::string& message) const;
bool shouldSuppressWarning(WarningCategory category) const;
Copy link
Member

Choose a reason for hiding this comment

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

I find this function name odd. It probably should be something like isSuppressed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, that name is simpler.
Changed.

@InsertCreativityHere InsertCreativityHere merged commit 787a4f2 into zeroc-ice:main Nov 4, 2024
19 checks passed
InsertCreativityHere added a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
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