mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
binpac: Wrap generated switch statements in NOLINTs for bugprone-branch-clone
Binpac generates a lot of switch statements with repeated blocks in them (typically empty blocks). Running clang-tidy on the generated code with bugprone-branch-clone generates a lot of warnings. Instead of doing a ton of analysis in binpac to avoid generating the duplicates, just mark any switch generated with an annotation to avoid reporting them.
This commit is contained in:
parent
670c4dcbcf
commit
54a0e01805
4 changed files with 12 additions and 0 deletions
|
@ -209,6 +209,7 @@ void Expr::GenCaseEval(Output* out_cc, Env* env) {
|
|||
foreach (i, CaseExprList, cases_)
|
||||
(*i)->value()->ForceIDEval(out_cc, env);
|
||||
|
||||
out_cc->println("// NOLINTBEGIN(bugprone-branch-clone)");
|
||||
out_cc->println("switch ( %s ) {", operand_[0]->EvalExpr(out_cc, env));
|
||||
Type* switch_type = operand_[0]->DataType(env);
|
||||
|
||||
|
@ -247,6 +248,7 @@ void Expr::GenCaseEval(Output* out_cc, Env* env) {
|
|||
|
||||
out_cc->dec_indent();
|
||||
out_cc->println("}");
|
||||
out_cc->println("// NOLINTEND(bugprone-branch-clone)");
|
||||
|
||||
env->SetEvaluated(val_var);
|
||||
str_ = env->RValue(val_var);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue