Switch to trailing returns in toolchain and related code. (#4919)

Also makes the style guide explicitly comment on void, but this was the
intent IIRC because it matches Carbon's `-> ()` (and "always" versus
"except for void", which we definitely went back and forth on).

Includes adjusting function pointers, which I definitely forget this
syntax works sometimes.

Excludes utils/tree_sitter/src/scanner.c because it claims to be C, but
really we should probably fix that to be cpp.
This commit is contained in:
Jon Ross-Perkins
2025-02-11 18:11:14 +00:00
committed by GitHub
parent 316a6c59e9
commit 2fef1cb713
38 changed files with 289 additions and 251 deletions
+4 -4
View File
@@ -372,8 +372,8 @@ class CompilationUnit {
// with the actual function name, but marks timings with the appropriate
// phase.
auto LogCall(llvm::StringLiteral logging_label,
llvm::StringLiteral timing_label, llvm::function_ref<void()> fn)
-> void;
llvm::StringLiteral timing_label,
llvm::function_ref<auto()->void> fn) -> void;
// Returns true if the current input file can be dumped.
auto IncludeInDumps() const -> bool;
@@ -409,7 +409,7 @@ class CompilationUnit {
std::optional<Lex::TokenizedBuffer> tokens_;
std::optional<Parse::Tree> parse_tree_;
std::optional<Parse::TreeAndSubtrees> parse_tree_and_subtrees_;
std::optional<std::function<const Parse::TreeAndSubtrees&()>>
std::optional<std::function<auto()->const Parse::TreeAndSubtrees&>>
tree_and_subtrees_getter_;
std::optional<SemIR::File> sem_ir_;
std::unique_ptr<llvm::LLVMContext> llvm_context_;
@@ -710,7 +710,7 @@ auto CompilationUnit::GetParseTreeAndSubtrees()
auto CompilationUnit::LogCall(llvm::StringLiteral logging_label,
llvm::StringLiteral timing_label,
llvm::function_ref<void()> fn) -> void {
llvm::function_ref<auto()->void> fn) -> void {
CARBON_VLOG("*** {0}: {1} ***\n", logging_label, input_filename_);
Timings::ScopedTiming timing(timings_ ? &*timings_ : nullptr, timing_label);
fn();