-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Combine DiagnosticConverter into DiagnosticEmitter #4878
Combine DiagnosticConverter into DiagnosticEmitter #4878
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.
Nice, I like how this sifted out. Minor stuff inline.
toolchain/check/check.cpp
Outdated
@@ -320,9 +320,12 @@ auto CheckParseTrees(llvm::MutableArrayRef<Unit> units, bool prelude_import, | |||
// UnitAndImports is big due to its SmallVectors, so we default to 0 on the | |||
// stack. | |||
llvm::SmallVector<UnitAndImports, 0> unit_infos; | |||
llvm::SmallVector<Parse::GetTreeAndSubtreesFn> all_trees_and_subtrees; |
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.
WDYT about naming this all_tree_getters
or something to indicate these are callable things, not the trees themselves?
(And maybe can just mention tree
here given its just a local variable?)
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.
Renamed to tree_and_subtrees_getters
. I prefer to include the "and subtree" given we typically say "tree" for Parse::Tree
. I'm assuming you suggested "all" because I had it before, but I was just trying to emphasize the plural there.
toolchain/lex/tokenized_buffer.h
Outdated
|
||
private: | ||
const TokenizedBuffer* tokens_; | ||
Lex::TokenizedBuffer* tokens_; |
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.
const
doesn't work here any more? Not a huge deal, just a bit surprising.
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.
Fixed (also the unnecessary namespace)
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.
LGTM!
2c33d7e
to
d6351d5
Compare
At present, we typically define a DiagnosticConverter, then store an instance of it and a DiagnosticEmitter that wraps it. This is relatively minor in general, but I've been trying to create more self-contained DiagnosticEmitter classes (which hold their own DiagnosticConverter, similar to NullDiagnosticEmitter), and there it just gets in the way.
Since we don't reuse DiagnosticConverter instances, this combines the definition into DiagnosticEmitter. Mainly this means we don't have a separate object in play, and less to carry around.
The most impact is probably to SemIRDiagnosticConverter, which was also the most complex. Now
SemIRLocDiagnosticEmitter
, this gets some different construction flow. Note in the PR I've split the file rename to its own commit, to try to help delta views. However, the most substantial parts of the refactoring are split into #4876, which this depends upon.