-
Notifications
You must be signed in to change notification settings - Fork 593
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
Simplify the API for Reporting Parser Warnings #3052
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
cpp/src/Slice/Parser.h
Outdated
@@ -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; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
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 onDefinitionContext
(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 forerror
and 2 functions forwarning
.One pair takes an explicit file name/line number, the other doesn't (and automatically uses the parser's current position).