This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Sequence init statements, declarations, and conditions correctly in if, switch, and while
ClosedPublic

Authored by mboehme on Jul 27 2018, 7:35 AM.

Diff Detail

Event Timeline

mboehme created this revision.Jul 27 2018, 7:35 AM
Eugene.Zelenko added a project: Restricted Project.
aaron.ballman added inline comments.Jul 28 2018, 10:03 AM
clang-tidy/utils/ExprSequence.cpp
150

Should we also handle switch statements at the same time?

alexfh accepted this revision.Jul 31 2018, 5:01 AM

LG modulo outstanding comments.

This revision is now accepted and ready to land.Jul 31 2018, 5:01 AM
mboehme updated this revision to Diff 158314.Jul 31 2018, 10:00 AM

Add support for switch statement.

While I'm here, also add support for the init statement in an if statement.

mboehme marked an inline comment as done.Jul 31 2018, 10:03 AM
mboehme added inline comments.
clang-tidy/utils/ExprSequence.cpp
150

Good point.

While I was doing this, I noticed that we were also not sequencing init statements in if statements correctly, so I've added code for that as well.

The description of the change is now too narrow, so I'll change that in a moment.

mboehme retitled this revision from [clang-tidy] Sequence declaration in while statement before the condition to [clang-tidy] Sequence init statements, declarations, and conditions correctly in if, switch, and while.Jul 31 2018, 10:04 AM
mboehme marked an inline comment as done.Aug 3 2018, 7:12 AM

Any further comments? This is marked ready to land, but I've made some non-trivial changes since then, so I didn't just want to land this.

alexfh accepted this revision.Aug 3 2018, 8:52 AM

Still LG

test/clang-tidy/bugprone-use-after-move.cpp
1141

nit: clang-format this, please.

mboehme updated this revision to Diff 159093.Aug 3 2018, 2:26 PM

Apply clang-format.

mboehme marked an inline comment as done.Aug 3 2018, 2:27 PM
This revision was automatically updated to reflect the committed changes.