This is an archive of the discontinued LLVM Phabricator instance.

[mlir][NFC] Use initializers in if statement.
Needs RevisionPublic

Authored by jacquesguan on Sep 16 2022, 2:23 AM.

Details

Summary

Since we support C++17 now, we could use initializers in if statement to
simplify scope.

Diff Detail

Event Timeline

jacquesguan created this revision.Sep 16 2022, 2:23 AM
jacquesguan requested review of this revision.Sep 16 2022, 2:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 2:23 AM
ftynse accepted this revision.Sep 16 2022, 2:25 AM
This revision is now accepted and ready to land.Sep 16 2022, 2:25 AM
rriddle requested changes to this revision.Sep 16 2022, 2:26 AM

I'm not convinced that this is an improvement, and I've personally already seen quite a few colleagues accidentally write these incorrectly for nullable things. I'd rather keep these as-is.

This revision now requires changes to proceed.Sep 16 2022, 2:26 AM
jpienaar added inline comments.
mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
631

Agreed with River, the previous form I find clearer in cases like this.

Seems like something that should be raised to the community and codify in the style guide instead of solved on a per-review basis.

Seems like something that should be raised to the community and codify in the style guide instead of solved on a per-review basis.

https://discourse.llvm.org/t/code-style-of-initializer-in-if-statement/65357 OK, I created a topic in the community.