This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] clang-format/clang-tidy AsmParser (NFC)
ClosedPublic

Authored by aheejin on Dec 5 2018, 7:43 PM.

Details

Summary
  • LLVM clang-format style doesn't allow one-line ifs.
  • LLVM clang-tidy style says method names should start with a lowercase letter. But currently WebAssemblyAsmParser's parent class MCTargetAsmParser is mixing lowercase and uppercase method names itself so overridden methods cannot be renamed now.
  • Changed else ifs after returns to ifs.
  • Added some newlines for readability.

Diff Detail

Event Timeline

aheejin created this revision.Dec 5 2018, 7:43 PM
aheejin updated this revision to Diff 176922.Dec 5 2018, 7:59 PM
  • Add some newlines
aheejin edited the summary of this revision. (Show Details)Dec 5 2018, 8:00 PM
aheejin updated this revision to Diff 176926.Dec 5 2018, 10:05 PM
  • clang-tidy
aheejin retitled this revision from [WebAssembly] clang-format AsmParser (NFC) to [WebAssembly] clang-format/clang-tidy AsmParser (NFC).Dec 5 2018, 10:09 PM
aheejin edited the summary of this revision. (Show Details)
aheejin updated this revision to Diff 176927.Dec 5 2018, 10:11 PM
  • remove stray newline
aheejin edited the summary of this revision. (Show Details)Dec 5 2018, 10:12 PM
sbc100 accepted this revision.Dec 6 2018, 8:27 AM
sbc100 added inline comments.
lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
440

Adding a newline here before a closing brace seems strange.

This revision is now accepted and ready to land.Dec 6 2018, 8:27 AM
aardappel accepted this revision.Dec 6 2018, 10:51 AM
aheejin marked an inline comment as done.Dec 6 2018, 1:47 PM
aheejin added inline comments.
lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
440

Then in case code is structured like

if (...) {
  ...
else if (...) {
  ...
} else if (...) {
  ...
}
...

And body of each if and else if is long enough so I'd like to add newlines, where should I add them?

sbc100 added inline comments.Dec 6 2018, 3:09 PM
lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
440

For me that block structure it enough to break it up visually.

To my eye adding newlines at the top of bottom of a block looks strange so I would leave it as is.

In this particular case since we return at the end of each block you could remove the else's completely and make it into a sequence of "if (xxx) { return .. }", but I'm not sure that would help with read-ability in this case.

aheejin updated this revision to Diff 177083.Dec 6 2018, 4:36 PM
aheejin marked an inline comment as done.
  • Changed else if to if after returns
aheejin marked an inline comment as done.Dec 6 2018, 4:37 PM
aheejin added inline comments.
lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
440

That sounds good. I changed them into ifs and added newlines after. LLVM coding standards say don't use else after a return anyway.

aheejin edited the summary of this revision. (Show Details)Dec 6 2018, 4:38 PM
aheejin marked an inline comment as done.Dec 6 2018, 4:51 PM
sbc100 accepted this revision.Dec 6 2018, 5:17 PM
This revision was automatically updated to reflect the committed changes.