This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw
ClosedPublic

Authored by malcolm.parsons on Nov 27 2017, 9:43 AM.

Diff Detail

Event Timeline

How about also matching on call to functions with no-return attribute?
i.e.

[[noreturn]] my_die();
void do_stuff();

void fn(int x) {
  if(!x)
    my_die();
  else // <- since `my_die()` will never return, `else` is not really needed.
    do_stuff();
}

How about also matching on call to functions with no-return attribute?

Great idea!

But I'll keep this patch for just the throw bugfix.

aaron.ballman accepted this revision.Nov 28 2017, 6:04 AM

LGTM with a minor formatting nit.

test/clang-tidy/readability-else-after-return.cpp
7

Indentation is incorrect here.

This revision is now accepted and ready to land.Nov 28 2017, 6:04 AM
This revision was automatically updated to reflect the committed changes.