[clang-tools-extra] [clang-tidy] Fix `altera-id-dependent-backward-branch` false positives (PR #200660)
Daniil Dudkin via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 5 13:10:48 PDT 2026
================
@@ -64,6 +95,31 @@ void error() {
accumulator++;
}
+ struct {
+ int FieldFromVar;
+ int FieldFromField;
+ } InferredField;
+ InferredField.FieldFromVar = ThreadID * 2;
+ while (j < InferredField.FieldFromVar) {
+ // CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'FieldFromVar' and may cause performance degradation [altera-id-dependent-backward-branch]
+ // CHECK-NOTES: :[[@LINE-6]]:5: note: inferred assignment of ID-dependent member from ID-dependent variable ThreadID
+ accumulator++;
+ }
+
+ InferredField.FieldFromField = Example.IDDepField;
+ while (j < InferredField.FieldFromField) {
+ // CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'FieldFromField' and may cause performance degradation [altera-id-dependent-backward-branch]
+ // CHECK-NOTES: :[[@LINE-12]]:5: note: inferred assignment of ID-dependent member from ID-dependent member IDDepField
----------------
unterumarmung wrote:
I guess you're right. But the issue is preexisting. Do you think we should fix it here or on the separate PR? Both are fine by me. The latter one can be a good candidate for a "good first issue"
https://github.com/llvm/llvm-project/pull/200660
More information about the cfe-commits
mailing list