From 32522307d9f062ee121f8906b3a4777132b0d73d Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 14 Aug 2025 10:36:57 -0700 Subject: [PATCH] gen-zam: Fix clang-tidy and pre-commit warnings --- tools/gen-zam/src/Gen-ZAM.cc | 28 +++++++++++++++------------- tools/gen-zam/src/Gen-ZAM.h | 14 ++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/gen-zam/src/Gen-ZAM.cc b/tools/gen-zam/src/Gen-ZAM.cc index dc07544c3d..393c2f9ff6 100644 --- a/tools/gen-zam/src/Gen-ZAM.cc +++ b/tools/gen-zam/src/Gen-ZAM.cc @@ -1,10 +1,12 @@ -// See the file "COPYING" in the toplevel directory for copyright. +// See the file "COPYING" in the main distribution directory for copyright. #include "Gen-ZAM.h" -#include +#include #include +#include #include +#include using namespace std; @@ -654,7 +656,7 @@ void ZAM_OpTemplate::BuildInstruction(const OCVec& oc, const string& params, con Emit("z = GenInst(" + op + ", " + params + ");"); } -static bool skippable_ot(ZAM_OperandClass oc) { +static bool skippable_op_type(ZAM_OperandClass oc) { return oc == ZAM_OC_EVENT_HANDLER || oc == ZAM_OC_AUX || oc == ZAM_OC_LIST; } @@ -677,7 +679,7 @@ string ZAM_OpTemplate::ExpandParams(const OCVec& oc, string eval, const vector 0 && skippable_ot(oc[oc_size - 1]) ) + while ( oc_size > 0 && skippable_op_type(oc[oc_size - 1]) ) --oc_size; auto max_param = oc_size; @@ -869,11 +871,11 @@ void ZAM_OpTemplate::StartDesc(const string& op_code, const string& oc_str) { Emit("\"\","); else { string ots; - for ( auto ot : op_types ) { - if ( ot == ZAM_TYPE_DEFAULT ) + for ( auto typ : op_types ) { + if ( typ == ZAM_TYPE_DEFAULT ) ots += "X"; else - ots += expr_name_types[ot]; + ots += expr_name_types[typ]; } Emit("\"" + ots + "\", "); @@ -2217,8 +2219,8 @@ void ZAMGen::GenMacros() { } } -string ZAMGen::GenOpCode(const ZAM_OpTemplate* ot, const string& suffix, ZAM_InstClass zc) { - auto op = "OP_" + ot->CanonicalName() + suffix; +string ZAMGen::GenOpCode(const ZAM_OpTemplate* op_templ, const string& suffix, ZAM_InstClass zc) { + auto op = "OP_" + op_templ->CanonicalName() + suffix; static unordered_set known_opcodes; @@ -2237,16 +2239,16 @@ string ZAMGen::GenOpCode(const ZAM_OpTemplate* ot, const string& suffix, ZAM_Ins // ... the "flavor" of how it treats its first operand ... auto op_comment = ",\t// " + op; auto op1_always_read = (zc == ZIC_FIELD || zc == ZIC_COND); - auto flavor = op1_always_read ? "OP1_READ" : ot->GetOp1Flavor(); + auto flavor = op1_always_read ? "OP1_READ" : op_templ->GetOp1Flavor(); Emit(Op1Flavor, flavor + op_comment); // ... whether it has side effects ... - auto se = ot->HasSideEffects() ? "true" : "false"; + auto se = op_templ->HasSideEffects() ? "true" : "false"; Emit(OpSideEffects, se + op_comment); // ... and the switch case that maps the enum to a string // representation. - auto name = ot->BaseName(); + auto name = op_templ->BaseName(); transform(name.begin(), name.end(), name.begin(), ::tolower); name += suffix; transform(name.begin(), name.end(), name.begin(), under_to_dash); @@ -2408,7 +2410,7 @@ bool ZAMGen::ParseTemplate() { const auto& op_name = words[1]; // We track issues with the wrong number of template arguments - // up front, to avoid mis-invoking constructors, but we don't + // up front, to avoid misinvoking constructors, but we don't // report these until later because if the template names a // bad operation, it's better to report that as the core problem. const char* args_mismatch = nullptr; diff --git a/tools/gen-zam/src/Gen-ZAM.h b/tools/gen-zam/src/Gen-ZAM.h index a93eabfcd4..54422c3bc4 100644 --- a/tools/gen-zam/src/Gen-ZAM.h +++ b/tools/gen-zam/src/Gen-ZAM.h @@ -1,4 +1,4 @@ -// See the file "COPYING" in the toplevel directory for copyright. +// See the file "COPYING" in the main distribution directory for copyright. // Gen-ZAM is a standalone program that takes as input a file specifying // ZAM operations and from them generates a (large) set of C++ include @@ -9,11 +9,9 @@ #pragma once -#include -#include +#include #include #include -#include #include #include #include @@ -442,15 +440,15 @@ protected: // Generates the C++ case statement for evaluating the given flavor // of operation. - void GenEval(EmitTarget et, const string& ot_str, const string& op_suffix, const string& eval, ZAM_InstClass zc); + void GenEval(EmitTarget et, const string& oc_str, const string& op_suffix, const string& eval, ZAM_InstClass zc); // Generates a description of the ZAM operation suitable for // reflection. - void GenDesc(const string& op_code, const string& ot_str, const string& eval); + void GenDesc(const string& op_code, const string& oc_str, const string& eval); // Generates the first part of a description, up to (but not including) // the evaluation. - void StartDesc(const string& op_code, const string& ot_str); + void StartDesc(const string& op_code, const string& oc_str); // Finishes a description, once the evaluation is done. void EndDesc(); @@ -929,7 +927,7 @@ public: // Generates a ZAM op-code for the given template, suffix, and // instruction class. Also creates auxiliary information associated // with the instruction. - string GenOpCode(const ZAM_OpTemplate* ot, const string& suffix, ZAM_InstClass zc = ZIC_REGULAR); + string GenOpCode(const ZAM_OpTemplate* op_templ, const string& suffix, ZAM_InstClass zc = ZIC_REGULAR); // These methods provide low-level parsing (and error-reporting) // access to ZAM_OpTemplate objects.