mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Try to move towards the Google style guide declaration order. (#221)
This patch tries to make everything adhere to the Google declaration order. This is tricky as there doesn't appear to be a `clang-tidy` check that helps us here at all. One of the complex cases are the `enum`-wrapping classes we use. These need to have a *public* conversion operator to the nested `enum` type to support `switch` statements and the like. However, this makes it impossible to fully respect the Google declaration order. We need to define the enum type before the public API in order to use it in contexts like the conversion operator. Even defining out-of-line won't help avoid this. It is weird to have a type in the public API that is private, but again this is only intended to be used for implicit conversions within a `switch` statement or a `case` label. In one case, we had the non-conforming order of declaration. I've added a comment to explain why there. In the other case, the conversion operator is actually *private* rather than public, which doesn't actually work in practice. I've made this public and moved the declaration order to match with a matching comment.
This commit is contained in:
@@ -25,12 +25,6 @@ class ParseTree::Parser {
|
||||
private:
|
||||
struct SubtreeStart;
|
||||
|
||||
ParseTree& tree;
|
||||
TokenizedBuffer& tokens;
|
||||
|
||||
TokenizedBuffer::TokenIterator position;
|
||||
TokenizedBuffer::TokenIterator end;
|
||||
|
||||
explicit Parser(ParseTree& tree_arg, TokenizedBuffer& tokens_arg)
|
||||
: tree(tree_arg),
|
||||
tokens(tokens_arg),
|
||||
@@ -127,6 +121,12 @@ class ParseTree::Parser {
|
||||
// skipping errors, can be parsed, it is returned. There may be parse errors
|
||||
// even when a node is returned.
|
||||
auto ParseDeclaration() -> llvm::Optional<Node>;
|
||||
|
||||
ParseTree& tree;
|
||||
TokenizedBuffer& tokens;
|
||||
|
||||
TokenizedBuffer::TokenIterator position;
|
||||
TokenizedBuffer::TokenIterator end;
|
||||
};
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user