This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Disable match on `if constexpr` statements in template instantiation for `readability-misleading-indentation` check.
ClosedPublic

Authored by Abpostelnicu on Jan 7 2020, 6:36 AM.

Details

Summary

Fixes fixes readability-misleading-identation for if constexpr. This is very similar to D71980. The bug tracking this issue is 44490.

Diff Detail

Event Timeline

Abpostelnicu created this revision.Jan 7 2020, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2020, 6:36 AM

Updated the test case to better reflect the changes.

I could never seem to get the tests to handle differently in templated and non templated code. Maybe i was just being stupid. Think the root cause is that the check detects if the if column appears on a different column to either the else or the closing brace if its on the same line as the else.

Updated test with match without compound statement.

JonasToth added inline comments.
clang-tools-extra/test/clang-tidy/checkers/readability-misleading-indentation.cpp
172

please add an case that does not get instantiated, with both bad and good indentation.

Added more tesst for templa functions that are not instantiated.

Abpostelnicu marked an inline comment as done.Jan 8 2020, 4:49 AM
JonasToth accepted this revision.Jan 8 2020, 6:08 AM

LGTM! Thank you for fixing this issue. Can you please update the bug report as well?

This revision is now accepted and ready to land.Jan 8 2020, 6:08 AM
Abpostelnicu edited the summary of this revision. (Show Details)Jan 8 2020, 6:22 AM
Abpostelnicu added a project: Restricted Project.Jan 8 2020, 6:41 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Jan 8 2020, 7:39 AM

This broke tests on Windows: http://45.33.8.238/win/5297/step_8.txt (probably due to windows using -fdelayed-template-parsing by default).

I think the best approach here is to remove the tests that don’t have template instantiation.

thakis added a comment.Jan 8 2020, 9:16 AM

I think the best approach here is to remove the tests that don’t have template instantiation.

In any case, if it takes a while to come to some decision, please revert in the meantime so that trunk doesn't stay red for a long time.

Will push shortly an update.

Any luck? The bot's been broken for close to 4h now.

Adding a -fno-delayed-template-parsing to the RUN-line should suffice.