{ "tokens": { "input": 391710, "cache_read": 76587, "cache_write": 1563, "output": 25132 }, "reviews": [ { "key": [ "https://ftp.debian.org/debian/pool/main/l/lp-solve/lp-solve_5.5.2.14.orig.tar.gz", "main lp_solve/lp_rlp.h:832:1: style: Parameter 'lp_yylval_param' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`YY_DECL` expands to a function whose two parameters, `lp_yylval_param` and `lp_yyscanner`, both get the macro location 832:1. The old comparator ordered variables only by file, line and column, so it treated these two parameters as the same variable inside the set and mixed up their const/non-const tracking. In the code, `lp_yylval_param` is assigned to `lp_yylval`, which in flex reentrant scanners is the non-const `YYSTYPE*` member `lp_yyg->lp_yylval_r`. Declaring the parameter as pointer to const would therefore not compile, so the removed warning was a false positive. The PR's new test covers exactly this case of parameters declared through a macro." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4356:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The `MSA_FN_IMM8` macro expands at line 4356 into a function where `pws` points to `env->active_fpu.fpr[ws].wr`. It is only read, in `~(pws->b[i] | i8)`. Only `pwd` is written, so `pws` can be `const wr_t *`. Before this PR, the set comparator ordered variables by file/line/column. All tokens of the macro expansion share the same location, so `pws` compared equal to `pwd` and was dropped from the set. That caused a false negative. Ordering with `precedes()` keeps both variables, so this new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4357:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The `MSA_FN_IMM8(xori_b, ...)` macro expands to a function where `pws` points into `env->active_fpu.fpr[ws].wr` and is only read (`pws->b[i] ^ i8`). Only `pwd` is written, so `pws` can indeed be `const wr_t *`, making this a true positive. Before the PR, the set of variables was ordered by file/line/column. Variables declared inside a macro expansion share the same location, so they compared equal and some were silently dropped from the set, which lost this warning. Ordering by token position with `precedes()` keeps them distinct, so the warning now appears. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4361:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The `MSA_FN_IMM8` macro declares `wr_t *pws = &(...)`. In the `bmnzi_b` expansion, `pws` is only read (`pws->b[i]`); only `pwd` is written. So `pws` can be pointer to const, and this holds for every expansion of the macro, so changing the macro is safe. Previously the old comparator treated `pwd` and `pws` as the same set entry because both come from the same macro invocation and share file/line/column, so the warning for `pws` was dropped. Using `precedes()` keeps them distinct, so this is a newly found true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4366:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_FN_IMM8(bmzi_b, ...)` expands to a function with two locals, `pwd` and `pws`. In the expanded body, `pws` is only read (`pws->b[i]` as an argument to `BIT_MOVE_IF_ZERO`) and is never written through or passed on as non-const, so it can be `const wr_t *`. Before the PR, both variables came from the same macro and got the same file, line and column. The comparator therefore treated them as equal, and the set dropped `pws`, which is why this warning was missed. Comparing with `precedes()` keeps the two apart, so this new true positive is reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4371:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_FN_IMM8(bseli_b, ...)` expands to a function in which `wr_t *pws = &(env->active_fpu.fpr[ws].wr);` is only read, through `pws->b[i]`. So `pws` can be declared `const wr_t *`, and the warning is a true positive. Before the PR, `CompareVariables` ordered variables by file, line and column. All tokens from a macro expansion share the same location, so variables like `pwd` and `pws` compared equal and only one survived in the set. Switching to `precedes()` orders them by token position, so `pws` is now checked and correctly reported. This is exactly the bug the PR fixes (#15222). The warning points at the macro invocation line, which is the usual behaviour for macro-generated code." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4451:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro MSA_BINOP_IMM_DF expands to a function where 'pws' is only read (pws->b[i], pws->h[i], etc.) and never written through, so it could be declared as 'const wr_t *'. That makes this a true positive. Before the PR, CompareVariables ordered variables by file, line and column. Every variable from a macro expansion has the same location, so the comparator saw distinct variables as equal and dropped them from the set, losing warnings. Using precedes() orders them by token position, so the warning is now reported. One caveat is that fixing it requires editing the macro, but the diagnostic itself is correct." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4452:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The function generated by MSA_BINOP_IMM_DF(ceqi, ceq) only reads through pws (pws->b[i], pws->h[i], etc. are passed by value to msa_ceq_df). So pws can be declared as 'const wr_t *', and the warning is a true positive. Main missed it because macro-expanded variables share the same line and column, so the old CompareVariables treated distinct variables as equal in the set and dropped them. The PR compares with precedes() instead, which fixes this, so the new warnings are correct." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4453:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro MSA_BINOP_IMM_DF expands at line 4453 into a function where 'pws' is only read (pws->b[i], pws->h[i], etc., passed by value to msa_*_df). So it can be declared 'const wr_t *', and the warning is a true positive. Before the PR, the variable comparator ordered variables by file, line and column. Every token from a macro expansion shares the same line and column, so different variables (pwd, pws) compared as equal in the std::set and some were dropped. Using precedes() fixes this, so the missed true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4456:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The function is generated by the macro MSA_BINOP_IMM_DF, so every variable in it has the same line and column. The old comparator ordered variables only by file, line and column. That made 'pwd' and 'pws' compare equal in the set, so 'pws' was silently dropped. Using precedes() now tells them apart. In the expanded function 'pws' is only read ('pws->b[i]', 'pws->h[i]', and so on) and never written through, so it can be declared as 'const wr_t *'. This is a newly found true positive, matching the test case for #15222." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4457:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro expands to a function with `wr_t *pws = &(env->active_fpu.fpr[ws].wr);`. Its only use is reading `pws->b[i]`, `pws->h[i]`, `pws->w[i]` and `pws->d[i]` by value, so it can be pointer to const. This is a true positive. Before the PR, the old comparator ordered variables by file, line and column. Inside a macro expansion, `pwd` and `pws` share the same location, so they compared equal and `pws` was dropped from the set. Using `precedes()` keeps both variables, so the missing true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4458:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_IMM_DF expands to a function where `pws = &(env->active_fpu.fpr[ws].wr)` is only read (`pws->b[i]`, `pws->h[i]`, etc.) and never written through, so it could be `const wr_t *`. The warning is a true positive. Before the PR, CompareVariables ordered variables by file, line and column. All tokens from a macro expansion share the same location, so `pwd` and `pws` compared equal and were deduplicated in the set, and the warning was lost. Using `precedes()` keeps them distinct, so this true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4459:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The function at line 4459 comes from the MSA_BINOP_IMM_DF macro. Inside it, 'pws' points to env->active_fpu.fpr[ws].wr and is only read (pws->b[i], pws->h[i], and so on). It is never written through, so declaring it 'const wr_t *' would be valid and the warning is a true positive. Before the PR, all variables from one macro expansion had the same file, line and column, so CompareVariables treated them as equal. The set then dropped some of them, such as 'pws' when 'pwd' was already present. Using precedes() orders the tokens properly, so these variables are now checked. This is the same case as #15222, and the new warning is a correct addition." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4460:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_BINOP_IMM_DF(mini_u, min_u)` expands to a function in which `pws = &(env->active_fpu.fpr[ws].wr)` is only read (`pws->b[i]`, `pws->h[i]`, ...), while `pwd` is written. So `pws` can be `const wr_t *`, and the warning is a true positive. Before the PR, the variable set compared variables by file, line and column. All tokens from a macro expansion share the same location, so `pws` was treated as a duplicate of `pwd` and dropped. Ordering by token with `precedes()` keeps distinct variables, so this valid warning is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4544:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro MSA_BINOP_IMMU_DF expands to a function where pws = &env->active_fpu.fpr[ws].wr is only read (pws->b[i], pws->h[i], etc.), so 'const wr_t *pws' would work and the warning is a true positive. All tokens from a macro expansion share the same line and column. The old comparator treated pwd and pws as equal, so the std::set dropped pws. precedes() orders the tokens by their real position, so pws is now kept and reported. This matches the test added in the PR (#15222)." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4547:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro-generated function helper_msa_bseti_df declares 'wr_t *pws' and only reads through it (pws->b[i], pws->h[i], etc.). So 'pws' could be declared as pointer to const, and the warning is a true positive. Before the PR, CompareVariables ordered variables only by file, line and column. Inside a macro expansion all tokens share the same location, so pwd and pws compared as equivalent and collapsed into one std::set entry. That dropped the warning. Using precedes() keeps both variables, so the PR adds a correct warning." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4549:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The function body comes from the MSA_BINOP_IMMU_DF macro. Inside it, 'pws' is only read (pws->b[i], pws->h[i] and so on), so it can be declared as const wr_t *. The warning is a true positive. The old comparator ordered variables only by file, line and column. All variables expanded from the macro share the same location, so 'pwd' and 'pws' compared equal and 'pws' was dropped from the std::set. Using precedes() keeps both variables, so this valid warning is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4550:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro MSA_BINOP_IMMU_DF expands at line 4550. Inside it, 'pws' is only read (pws->b[i], pws->h[i], and so on, passed by value), so it could be declared as pointer to const. The warning is a true positive. Before the PR, CompareVariables compared variables only by file, line and column. Variables from the same macro expansion share the same location, so a std::set using this comparator treated 'pwd' and 'pws' as equal and dropped 'pws'. Using precedes() orders the tokens correctly, so the missed warning is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4551:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The MSA_BINOP_IMMU_DF macro expands to a function where 'pws' only ever appears in reads like pws->b[i]. Nothing is written through it, so it could be declared 'const wr_t *', and the warning is a true positive. Before the PR, the variables pwd and pws come from one macro expansion and share the same file, line and column. CompareVariables then treated them as equivalent, so pws was dropped from the set and never reported. Using precedes() orders the tokens by their position in the token list, so each expansion now reports pws correctly. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4552:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The macro MSA_BINOP_IMMU_DF expands to a helper where 'pws' (wr_t *pws = &env->...fpr[ws].wr) is only read (pws->b[i], pws->h[i], etc. passed by value to msa_*_df). So it really can be declared as pointer to const. Before the PR, CompareVariables compared variables by file/line/column. All 'pws' variables from the macro expansions have the same location, so the std::set treated them as equal and dropped all but one warning. Using precedes() gives distinct ordering, so this correct warning for the srlri expansion is now reported. It is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4594:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The function generated by MSA_TEROP_IMMU_DF(binsri, binsr) only reads through 'pws' (pws->b[i], pws->h[i], pws->w[i], pws->d[i]), so 'wr_t *pws' could be 'const wr_t *pws'. The warning is a true positive. Before the PR, every token from the macro expansion had the same file, line and column. CompareVariables therefore treated 'pwd' and 'pws' as equal, and the std::set silently dropped 'pws'. Using precedes() tells the two variables apart, so this valid warning is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4805:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_BINOP_DF(func)` expands into a helper function that declares the locals `pwd`, `pws` and `pwt`. Because they come from one macro expansion, all three name tokens get the same file, line and column. The old `CompareVariables` therefore treated them as equal, and only one of them survived in the set, so `pws` and `pwt` were never reported. The PR orders the variables by token position with `precedes()`, so each one is now checked on its own. In the shown macro body, `pws` is only read (`pws->b[i]`, `pws->h[i]`, `pws->w[i]`, `pws->d[i]`) and never written through. It can therefore be `const wr_t *`, and the new constVariablePointer warning is a true positive. This is the exact scenario the PR's new test (#15222) targets." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4805:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF expands to a helper that declares locals pwd, pws and pwt (each `wr_t *... = &(env->active_fpu.fpr[..].wr)`). pwt is only read (`pwt->b[i]`, `pwt->h[i]`, etc.), so it really could be `const wr_t *`. Inside the macro expansion all three variables have the same file, line and column. The old CompareVariables treated them as equal, so the std::set kept only one of them and the others were never reported. Using precedes() keeps them apart, which is the bug the PR fixes (#15222). The new warning is a true positive that was previously missed." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4806:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_BINOP_DF(subs_s)` expands to a helper that declares `pwd`, `pws` and `pwt` as `wr_t*` pointers into env. `pws` is only read (`pws->b[i]`, `pws->h[i]`, and so on), so it can be pointer to const. Before the PR, the variable set sorted by file/line/column. All variables from one macro expansion share the same location, so they collapsed into one entry and this warning was lost. Ordering by token position with `precedes()` keeps them separate, so this true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4806:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF expands to a helper function that declares local pointers pwd, pws and pwt, all from the same macro invocation line. Every token from that expansion has the same file, line and column. The old CompareVariables comparator therefore treated these variables as equal in the std::set, and only one of them got checked. With precedes(), each variable is distinct, so pwt is now checked too. In the macro body pwt is only read (pwt->b[i], pwt->h[i], etc.) and never written through, so declaring it as pointer to const is valid. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4807:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF(subs_u) expands to a helper that declares local pointers pwd, pws and pwt, all pointing into env->active_fpu.fpr. pws is only read (pws->b[i], pws->h[i] and so on), so it can be declared as const wr_t *. That makes the warning a true positive. Main missed it because all three variables from the same macro expansion share the same file, line and column. The old comparator treated them as equal, so only one entry was kept in the set. Using precedes() keeps them as distinct entries, which correctly adds this missed warning." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4807:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF expands to a function with locals pwd, pws and pwt. All of them get the same file, line and column from the macro invocation. The old CompareVariables treated these variables as equal, so set entries collapsed and warnings were lost. `precedes()` uses token order and keeps them distinct. In the macro body, pwt is only read (`pwt->b[i]`, `pwt->h[i]`, etc.) and never written through or passed as non-const, so it can be `const wr_t *`. This is a true positive that was previously missed." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4808:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF expands to a function that declares the locals pwd, pws and pwt, all from the same macro line. pwt is only read (pwt->b[i], pwt->h[i], and so on), so it could be declared as a pointer to const; the warning is a true positive. The old comparator ordered variables by file, line and column. All tokens from a macro expansion share the same location, so pwd, pws and pwt counted as equal in the set and only one of them was ever reported. Using precedes() keeps them distinct, so the missed warning now appears. The fix belongs in the macro definition, but the diagnostic is correct." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4809:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_BINOP_DF(func)` expands to a helper with locals `pwd`, `pws` and `pwt`, all pointing into `env`. `pwt` is only read (`pwt->b[i]`, `pwt->h[i]` and so on are passed by value to `msa_*_df`), so it could be `const wr_t *`. The warning is a true positive. Main missed it because all variables from one macro expansion have the same file, line and column. The old `CompareVariables` therefore treated them as equal in the set, and only one of them was kept. Using `precedes()` tells them apart, so `pwt` is now reported. This matches the PR's test case (#15222)." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4810:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "Each MSA_BINOP_DF expansion defines a helper with local pointers pwd, pws and pwt, all declared on the macro line. pws is only read (pws->b[i], pws->h[i] and so on), so it can be declared as pointer to const: a true positive. The old comparator ordered variables by file, line and column. Every token from the macro expansion has the same location, so pwd, pws and pwt counted as equal in the set and only one survived, which hid the pws/pwt warnings. Using precedes() keeps them as separate variables, so the real warning now appears." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4814:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF(mul_q) expands to a helper that sets `wr_t *pwt = &(env->active_fpu.fpr[wt].wr);`. It only reads `pwt->b[i]`, `pwt->h[i]`, etc. by value and only writes through `pwd`, so `pwt` can be pointer to const and the warning is a true positive. Before the PR, the comparator ordered variables by file/line/column only. Variables from the same macro expansion share that location, so the std::set treated them as one and the warning was lost. Using precedes() tells them apart, which adds this correct report." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4815:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_BINOP_DF expands to a helper function that declares the locals pwd, pws and pwt. pws is only read (`pws->b[i]`, `pws->h[i]`, and so on), so it can be `wr_t const *`. Before the PR, the comparator ordered variables by file, line and column. All tokens from one macro expansion share the same location, so pws and pwt were treated as duplicates of another variable and dropped from the set. Their warnings were silently lost. Using `precedes()` keeps them as distinct variables. This is the scenario of the new #15222 test. The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:4815:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_BINOP_DF(mulr_q)` expands to a helper function that declares local pointers `pwd`, `pws` and `pwt` on the same line and column. `pwt` is only read (`pwt->b[i]`, `pwt->h[i]`, and so on); only `pwd` is written through. So `pwt` can be `const wr_t *`, and the warning is a true positive (fixable by editing the macro once). Before the PR, `CompareVariables` compared only file, line and column. All three variables from the macro expansion therefore compared equal, and only one was kept in the set, which hid these warnings. Switching to `precedes()` tells the tokens apart, so the missed true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5013:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF expands to a helper that declares `wr_t *pwd`, `*pws` and `*pwt` inside the macro. `pws` is only read (`pws->b[i]`, `pws->h[i]`, etc. are passed by value) and never written through, so it can be `const wr_t *`. The old comparator ordered variables by file, line and column. Every variable in a macro expansion has the same location, so the std::set treated pwd/pws/pwt as duplicates and kept only one. Using `precedes()` keeps them distinct, so this true positive is no longer lost. This is the case the PR's test (#15222) covers." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5015:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(func)` expands to a helper function. It declares local pointers `pwd`, `pws` and `pwt` to the MSA registers. Because they come from one macro expansion, all their tokens share the location 5015:1. The old comparator ordered variables by file, line and column, so the `std::set` treated these variables as equal and dropped all but one. Using `precedes()` keeps them distinct, so `pws` is now checked too. In the expansion `pws` is only read (`pws->b[i]`, `pws->h[i]`, ...) and never written through, so it can be `const wr_t *`. This is a true positive that was previously missed." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5016:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF expands at line 5016 into a function with locals pwd, pws and pwt, all declared inside the macro. pwt is only read (pwt->b[i], pwt->h[i], etc.), so it can be a pointer to const, and the warning is a true positive. Previously CompareVariables compared only file, line and column. Every variable from the macro expansion has the same location, so the set treated them as duplicates and dropped all but one of these warnings. With precedes() they are kept as distinct, which matches the PR's intent (#15222)." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5017:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF expands to a helper function with local pointers pwd, pws and pwt. pws is only read (pws->b[i], pws->h[i], and so on); only pwd is written. So 'pws can be declared as pointer to const' is a true positive. The old CompareVariables compared file, line and column. All locals expanded from the macro share the same location, so the std::set treated them as equal and silently dropped some of them. With precedes() they are told apart, and the missing true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5017:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF expands to a helper function with local pointers pwd, pws and pwt, all declared inside the macro. pwt is only read (pwt->b[i], pwt->h[i], pwt->w[i], pwt->d[i]) and never written through, so it could be `const wr_t *`. The warning is a true positive; the fix would go once in the macro definition. Main missed it because the old comparator ordered variables by file, line and column. Every token from a macro expansion gets the macro's location, so pws and pwt compared equal and the std::set kept only one of them. Using precedes() orders them by token position, so the second variable is no longer dropped. This adds a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5018:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF(dpsub_u) expands to a helper that declares `wr_t *pwd`, `wr_t *pws` and `wr_t *pwt` locals. In the visible macro body, `pws` is only read (`pws->b[i]`, `pws->h[i]`, `pws->w[i]`, `pws->d[i]`) and is never written through, so it can be declared as pointer to const. All three variables come from one macro expansion, so their name tokens share the same file, line and column. The old CompareVariables treated them as equal, and the std::set dropped all but one, hiding this warning. Comparing with precedes() keeps them distinct, so this true positive is now reported, matching the PR's test case." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5019:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(binsl)` expands to a helper function. In it, `pwd`, `pws` and `pwt` are local pointers to `env->active_fpu.fpr[...].wr`. `pws` is only read (`pws->b[i]`, `pws->h[i]`, \u2026) and its elements are passed by value to `msa_binsl_df`, so it can be `const wr_t *`. That makes the warning a true positive. Before the PR, the comparator compared variables only by file, line and column. All tokens from a macro expansion share the same location, so the variables in this function counted as equal and were collapsed into one set entry. That hid the warnings for `pws` and `pwt`. With `precedes()` they are now told apart, so this valid warning appears." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5019:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(binsl)` expands to a helper with three locals: `wr_t *pwd`, `*pws` and `*pwt`, each set to `&env->active_fpu.fpr[..].wr`. `pwt` is only read (`pwt->b[i]`, `pwt->h[i]` and so on are passed by value), so it can be a pointer to const. All tokens from a macro expansion share the same file, line and column. The old comparator therefore treated these variables as equal, and the set kept only one of them. Switching to `precedes()` keeps them distinct, so this valid warning is now reported. It is a newly found true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5020:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(binsr)` expands to a helper that declares `pwd`, `pws` and `pwt` as `wr_t*` locals. `pws` is only read (`pws->b[i]`, `pws->h[i]`, and so on), so it can indeed be pointer to const; the warning is a true positive. Main missed it because the old comparator ordered variables by file, line and column. Every token from the macro expansion has the same location, so the set kept only one of the three variables. Using `precedes()` keeps them distinct, which is exactly the bug (#15222) this PR fixes." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5020:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(binsr)` expands to a helper that declares `wr_t *pwd`, `*pws` and `*pwt` locals on one line. `pwt` is only read (`pwt->b[i]`, `pwt->h[i]`, etc. passed by value), so declaring it `const wr_t *pwt` in the macro is valid. Before the PR, `CompareVariables` ordered variables by file, line and column. Every variable from the same macro expansion has the same position, so the set treated them as one and dropped `pws`/`pwt`. Ordering by token (`precedes`) fixes that, which is exactly what the PR's new test (#15222) covers. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5021:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(madd_q)` expands to a helper that declares local pointers `pwd`, `pws` and `pwt` (as `wr_t *... = &(env->active_fpu.fpr[..].wr)`). `pws` is only read: its elements `pws->b[i]`, `pws->h[i]`, etc. are passed by value to `msa_*_df`. So it really can be `const wr_t *`, and the warning is a true positive. Tokens from a macro expansion all get the same file, line and column. The old comparator therefore treated these variables as equal and dropped all but one from the set. `precedes()` tells them apart, so the missing true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5021:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF` expands into a helper that declares local pointers `pwd`, `pws` and `pwt`. All three get the same file, line and column from the macro invocation. The old comparator in the set treated them as equal, so only one variable per expansion was checked and the warnings for `pws`/`pwt` were lost. Using `precedes()` now orders them by token position, so each is checked separately. `pwt` is only read (`pwt->b[i]`, `pwt->h[i]`, etc.) and never written through, so it can be `const wr_t *`. This is a valid new true positive, though users must fix it in the macro." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5022:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(msub_q)` expands to a helper with locals `pwd`, `pws` and `pwt`. Inside a macro expansion all of these share the same file, line and column. The old comparator therefore treated them as the same element in the set, so only one of them (likely `pwd`, which is written) was checked. Ordering by token position with `precedes()` keeps every variable distinct. In the shown macro body `pws` is only read (`pws->b[i]`, `pws->h[i]`, and so on) and never written through, so it can be `const wr_t *`. This is a newly found true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5023:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF(maddr_q)` expands to a helper function with locals `pwd`, `pws` and `pwt`. All three pointers are initialised from `&env->active_fpu.fpr[...].wr`. `pws` is only read: its elements (`pws->b[i]`, `pws->h[i]`, ...) are passed by value to `msa_*_df`, and only `pwd` is written. So `pws` can indeed be `const wr_t *`, and the warning is a true positive. Before the PR, `CompareVariables` ordered variables by file, line and column. Every variable from the macro expansion has the same location, so the set merged them and `pws` was lost. Using `precedes()` keeps them as separate entries, so this correct warning is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5023:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF expands to a helper function that declares local pointers pwd, pws and pwt. pwt is only read (pwt->b[i], pwt->h[i], etc.), so it really can be a pointer to const. Before the PR, CompareVariables ordered variables only by file, line and column. All variables from one macro expansion share the same location, so the set merged them and dropped pws/pwt. Using precedes() tells them apart, so this true positive is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5024:1: style: Variable 'pws' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`MSA_TEROP_DF` expands to a helper function with locals `pwd`, `pws` and `pwt`, all pointing into `env->active_fpu.fpr[...]`. Only `pwd` is written; `pws` is only read (`pws->b[i]` etc.) and passed by value to `msa_*_df`, so it can be declared `const wr_t *`. The warning is a true positive. Because all these variables come from one macro expansion, they share the same file, line and column. The old comparator therefore treated them as equal in the ordered set and dropped all but one. With `precedes()` they are now distinct, so the missing true positive is reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unicorn-engine/unicorn-engine_2.1.4.orig.tar.gz", "your unicorn-engine-unicorn-8028ec4/qemu/target/mips/msa_helper.c:5024:1: style: Variable 'pwt' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "MSA_TEROP_DF expands to a helper function with locals `pwd`, `pws` and `pwt`, all declared inside the macro. `pws` and `pwt` are only read (`pws->b[i]`, `pwt->h[i]`, ...), so `pwt` can be `const wr_t *`. The warning is a true positive. Before the PR, the set comparator ordered variables by file, line and column. Every variable from the macro expansion has the same location, so they compared equal and only the first, `pwd` (which is written), was kept. That hid warnings for `pws` and `pwt`. With `precedes()`, the set orders by token position, so each variable is checked and this missed true positive is now reported." } } ], "started": "2026-11-16 11:26:32 UTC", "runner": "server" }