mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:11:04 +01:00
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:
@@ -75,7 +75,7 @@ struct RandomSourceOptions {
|
||||
int comment_line_percent = 0;
|
||||
int blank_line_percent = 0;
|
||||
|
||||
void Validate() {
|
||||
auto Validate() -> void {
|
||||
auto is_percentage = [](int n) { return 0 <= n && n <= 100; };
|
||||
CARBON_CHECK(is_percentage(symbol_percent));
|
||||
CARBON_CHECK(is_percentage(keyword_percent));
|
||||
@@ -244,7 +244,7 @@ class LexerBenchHelper {
|
||||
SourceBuffer source_;
|
||||
};
|
||||
|
||||
void BM_ValidKeywords(benchmark::State& state) {
|
||||
auto BM_ValidKeywords(benchmark::State& state) -> void {
|
||||
absl::BitGen gen;
|
||||
std::array<llvm::StringRef, NumTokens> tokens;
|
||||
for (int i : llvm::seq(NumTokens)) {
|
||||
@@ -266,7 +266,7 @@ void BM_ValidKeywords(benchmark::State& state) {
|
||||
}
|
||||
BENCHMARK(BM_ValidKeywords);
|
||||
|
||||
void BM_ValidKeywordsAsRawIdentifiers(benchmark::State& state) {
|
||||
auto BM_ValidKeywordsAsRawIdentifiers(benchmark::State& state) -> void {
|
||||
absl::BitGen gen;
|
||||
std::array<llvm::StringRef, NumTokens> tokens;
|
||||
for (int i : llvm::seq(NumTokens)) {
|
||||
@@ -291,7 +291,7 @@ BENCHMARK(BM_ValidKeywordsAsRawIdentifiers);
|
||||
|
||||
// This benchmark does a 50-50 split of r-prefixed and r#-prefixed identifiers
|
||||
// to directly compare raw and non-raw performance.
|
||||
void BM_RawIdentifierFocus(benchmark::State& state) {
|
||||
auto BM_RawIdentifierFocus(benchmark::State& state) -> void {
|
||||
llvm::SmallVector<llvm::StringRef> ids =
|
||||
Testing::SourceGen::Global().GetIdentifiers(NumTokens / 2);
|
||||
|
||||
@@ -328,7 +328,7 @@ void BM_RawIdentifierFocus(benchmark::State& state) {
|
||||
BENCHMARK(BM_RawIdentifierFocus);
|
||||
|
||||
template <int MinLength, int MaxLength, bool Uniform>
|
||||
void BM_ValidIdentifiers(benchmark::State& state) {
|
||||
auto BM_ValidIdentifiers(benchmark::State& state) -> void {
|
||||
std::string source = RandomIdentifierSeq(MinLength, MaxLength, Uniform);
|
||||
|
||||
LexerBenchHelper helper(source);
|
||||
@@ -361,7 +361,7 @@ BENCHMARK(BM_ValidIdentifiers<80, 80, /*Uniform=*/true>);
|
||||
// Benchmark to stress the lexing of horizontal whitespace. This sets up what is
|
||||
// nearly a worst-case scenario of short-but-expensive-to-lex tokens with runs
|
||||
// of horizontal whitespace between them.
|
||||
void BM_HorizontalWhitespace(benchmark::State& state) {
|
||||
auto BM_HorizontalWhitespace(benchmark::State& state) -> void {
|
||||
int num_spaces = state.range(0);
|
||||
std::string separator(num_spaces, ' ');
|
||||
std::string source = RandomIdentifierSeq(3, 5, /*uniform=*/true, separator);
|
||||
@@ -381,7 +381,7 @@ void BM_HorizontalWhitespace(benchmark::State& state) {
|
||||
}
|
||||
BENCHMARK(BM_HorizontalWhitespace)->RangeMultiplier(4)->Range(1, 128);
|
||||
|
||||
void BM_RandomSource(benchmark::State& state) {
|
||||
auto BM_RandomSource(benchmark::State& state) -> void {
|
||||
std::string source = RandomSource(DefaultSourceDist);
|
||||
|
||||
LexerBenchHelper helper(source);
|
||||
@@ -407,7 +407,7 @@ void BM_RandomSource(benchmark::State& state) {
|
||||
BENCHMARK(BM_RandomSource);
|
||||
|
||||
// Benchmark to stress opening and closing grouped symbols.
|
||||
void BM_GroupingSymbols(benchmark::State& state) {
|
||||
auto BM_GroupingSymbols(benchmark::State& state) -> void {
|
||||
int curly_brace_depth = state.range(0);
|
||||
int paren_depth = state.range(1);
|
||||
int square_bracket_depth = state.range(2);
|
||||
@@ -495,7 +495,7 @@ BENCHMARK(BM_GroupingSymbols)
|
||||
|
||||
// Benchmark to stress the lexing of blank lines. This uses a simple, easy to
|
||||
// lex token, but separates each one by varying numbers of blank lines.
|
||||
void BM_BlankLines(benchmark::State& state) {
|
||||
auto BM_BlankLines(benchmark::State& state) -> void {
|
||||
int num_blank_lines = state.range(0);
|
||||
std::string separator(num_blank_lines, '\n');
|
||||
std::string source = RandomIdentifierSeq(3, 5, /*uniform=*/true, separator);
|
||||
@@ -521,7 +521,7 @@ BENCHMARK(BM_BlankLines)->RangeMultiplier(4)->Range(1, 128);
|
||||
// Benchmark to stress the lexing of comment lines. This uses a simple, easy to
|
||||
// lex token, but separates each one by varying numbers of comment lines, with
|
||||
// varying comment line length and indentation.
|
||||
void BM_CommentLines(benchmark::State& state) {
|
||||
auto BM_CommentLines(benchmark::State& state) -> void {
|
||||
int num_comment_lines = state.range(0);
|
||||
int comment_length = state.range(1);
|
||||
int comment_indent = state.range(2);
|
||||
|
||||
Reference in New Issue
Block a user