diff --git a/.clang-tidy b/.clang-tidy index d44f89fe1fd1..8e643f6b0361 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -143,3 +143,12 @@ CheckOptions: # Don't require writing a return type on lambdas. - key: modernize-use-trailing-return-type.TransformLambdas value: none + + # Use lines rather than statements to measure function size, because + # for readability purposes we care about the code as written, before + # preprocessing. + - key: readability-function-size.StatementThreshold + value: none + - key: readability-function-size.LineThreshold + # Chose 800 to match the default for StatementThreshold. + value: 800 diff --git a/toolchain/check/check_unit.cpp b/toolchain/check/check_unit.cpp index 95bd1bf11c0d..872d6e0f2667 100644 --- a/toolchain/check/check_unit.cpp +++ b/toolchain/check/check_unit.cpp @@ -374,7 +374,6 @@ auto CheckUnit::ImportOtherPackages(SemIR::TypeId namespace_type_id) -> void { // Loops over all nodes in the tree. On some errors, this may return early, // for example if an unrecoverable state is encountered. -// NOLINTNEXTLINE(readability-function-size) auto CheckUnit::ProcessNodeIds() -> bool { NodeIdTraversal traversal(&context_); diff --git a/toolchain/check/check_unit.h b/toolchain/check/check_unit.h index d4af2119ba04..5c937c520d99 100644 --- a/toolchain/check/check_unit.h +++ b/toolchain/check/check_unit.h @@ -185,7 +185,6 @@ class CheckUnit { // Loops over all nodes in the tree. On some errors, this may return early, // for example if an unrecoverable state is encountered. - // NOLINTNEXTLINE(readability-function-size) auto ProcessNodeIds() -> bool; UnitAndImports* unit_and_imports_; diff --git a/toolchain/check/node_stack.cpp b/toolchain/check/node_stack.cpp index 49b9deea4a7e..f779e43535ae 100644 --- a/toolchain/check/node_stack.cpp +++ b/toolchain/check/node_stack.cpp @@ -37,7 +37,6 @@ auto NodeStack::PrintForStackDump(int indent, llvm::raw_ostream& output) const } } -// NOLINTNEXTLINE(readability-function-size) auto NodeStack::CheckIdKindTable() -> void { #define CARBON_PARSE_NODE_KIND(Name) \ { \ diff --git a/toolchain/lower/constant.cpp b/toolchain/lower/constant.cpp index 14cbc8bb1250..0500857137c4 100644 --- a/toolchain/lower/constant.cpp +++ b/toolchain/lower/constant.cpp @@ -325,7 +325,6 @@ static auto MaybeEmitAsConstant(ConstantContext& context, InstT inst) } } -// NOLINTNEXTLINE(readability-function-size): Macro-generated. auto LowerConstants(FileContext& file_context, FileContext::LoweredConstantStore& constants) -> void { ConstantContext context(file_context, &constants); diff --git a/toolchain/lower/function_context.cpp b/toolchain/lower/function_context.cpp index bf886ae8d933..eb5551cc32b9 100644 --- a/toolchain/lower/function_context.cpp +++ b/toolchain/lower/function_context.cpp @@ -113,7 +113,6 @@ static auto LowerInstHelper(FunctionContext& context, SemIR::InstId inst_id, // TODO: Consider renaming Handle##Name, instead relying on typed_inst overload // resolution. That would allow putting the nonexistent handler implementations // in `requires`-style overloads. -// NOLINTNEXTLINE(readability-function-size): The define confuses lint. auto FunctionContext::LowerInst(SemIR::InstId inst_id) -> void { // Skip over constants. `FileContext::GetConstant` lowers them as needed. if (sem_ir().constant_values().Get(inst_id).is_constant()) { diff --git a/toolchain/sem_ir/expr_info.cpp b/toolchain/sem_ir/expr_info.cpp index 4b3db5831167..0a0f5fc2caa6 100644 --- a/toolchain/sem_ir/expr_info.cpp +++ b/toolchain/sem_ir/expr_info.cpp @@ -22,7 +22,6 @@ static auto AsAnyInstId(Inst::ArgAndKind arg) -> InstId { return arg.As(); } -// NOLINTBEGIN(readability-function-size) auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { const File* ir = &file; @@ -137,7 +136,6 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { } } } -// NOLINTEND(readability-function-size) auto FindReturnSlotArgForInitializer(const File& sem_ir, InstId init_id) -> InstId { diff --git a/toolchain/sem_ir/stringify.cpp b/toolchain/sem_ir/stringify.cpp index 3f1d0bfbfa8a..70a9d8b95c47 100644 --- a/toolchain/sem_ir/stringify.cpp +++ b/toolchain/sem_ir/stringify.cpp @@ -734,7 +734,6 @@ class Stringifier { } // namespace -// NOLINTNEXTLINE(readability-function-size) static auto Stringify(const File& sem_ir, StepStack& step_stack) -> std::string { RawStringOstream out;