This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix if-constexpr false-positive in readability-misleading-indentation
ClosedPublic

Authored by PiotrZSL on Mar 25 2023, 2:55 PM.

Details

Summary

When depend on template parameter,
compiler can use NullStmt instead of CompoundStmt.
This causes issues as we losing information about
end location of that Stmt. To avoid this issue
check now ignores ifStmt with NullStmt on true-branch.

Fixes: https://github.com/llvm/llvm-project/issues/61435

Diff Detail

Event Timeline

PiotrZSL created this revision.Mar 25 2023, 2:55 PM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL requested review of this revision.Mar 25 2023, 2:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2023, 2:55 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
carlosgalvezp requested changes to this revision.Mar 28 2023, 1:17 PM
carlosgalvezp added inline comments.
clang-tools-extra/test/clang-tidy/checkers/readability/misleading-indentation.cpp
1 ↗(On Diff #508346)

We should keep the default value of c++11-or-later, otherwise we are losing coverage on older versions.

199 ↗(On Diff #508346)

I believe the most common way of solving this is creating another test file where you test the c++17-or-later support. Alternatively you'd need to wrap this code in a #if block, plus create another RUN line with a different check-suffix

This revision now requires changes to proceed.Mar 28 2023, 1:17 PM
PiotrZSL marked 2 inline comments as done.Mar 28 2023, 1:48 PM
PiotrZSL updated this revision to Diff 509136.Mar 28 2023, 2:19 PM

Move tests to new file.

carlosgalvezp accepted this revision.Mar 28 2023, 11:02 PM

Looks great, thanks for fixing!

This revision is now accepted and ready to land.Mar 28 2023, 11:02 PM