This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] altera-id-dependent-backward-branch: fix assignment notes
Needs ReviewPublic

Authored by yeputons-gh on Mar 5 2023, 10:06 AM.

Details

Reviewers
njames93
Summary

Previously a note was always issued on a variable declaration itself. Now it points to the actual assignment of get_local_id to the variable, like with fields. Do the same for note messages about inferred id-dependencies. They previously pointed to the declaration of the original id-dependent variable, not the assignment from it.

There are six cases of assignment inferrence in the code, all are tested: a variable initialized from a variable/field, a variable assigned from a variable/field, a field assigned from a variable/field.

Depends on D145305

Diff Detail

Event Timeline

yeputons-gh created this revision.Mar 5 2023, 10:06 AM
Herald added a project: Restricted Project. · View Herald Transcript
yeputons-gh requested review of this revision.Mar 5 2023, 10:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2023, 10:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Test inferred assignments and fix notes for them as well.

yeputons-gh retitled this revision from [clang-tidy] altera-id-dependent-backward-branch: fix direct assignment notes to [clang-tidy] altera-id-dependent-backward-branch: fix assignment notes.Mar 5 2023, 10:24 AM
yeputons-gh edited the summary of this revision. (Show Details)
yeputons-gh added inline comments.Mar 5 2023, 10:27 AM
clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
126

This line was already correct prior to this patch.

clang-tools-extra/test/clang-tidy/checkers/altera/id-dependent-backward-branch.cpp
42

It previously pointed at int ThreadIDAssigned = 0, not ThreadIDAssigned = get_local_id(0) * 2.

61–63

This became ThreadIDVarFromVar, see above.

180–210

I mirror all id-dependent tests with non-id-dependent to make sure https://github.com/llvm/llvm-project/issues/52790 does not creep back.