This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix an assert failure in 'readability-braces-around-statements' check.
ClosedPublic

Authored by hokein on Feb 10 2016, 4:53 AM.

Details

Summary

The check will trigger a assert failure("CondEndLoc.isValid") when
checking the IfStmt whose condition expression is not parsed.

In this case, we should ignore that.

Diff Detail

Event Timeline

hokein updated this revision to Diff 47442.Feb 10 2016, 4:53 AM
hokein updated this revision to Diff 47444.
hokein retitled this revision from to [clang-tidy] Fix an assert failure in 'readability-braces-around-statements' check..
hokein updated this object.

Minor update.

hokein set the repository for this revision to rL LLVM.
hokein added a subscriber: cfe-commits.
alexfh accepted this revision.Feb 10 2016, 7:34 AM
alexfh edited edge metadata.

Looks good with one possible improvement. Thank you!

clang-tidy/readability/BracesAroundStatementsCheck.cpp
181

Maybe just replace the assertion with

if (!CondEndLoc.isValid())
  return SourceLocation();

?

This revision is now accepted and ready to land.Feb 10 2016, 7:34 AM
hokein updated this revision to Diff 47609.Feb 11 2016, 1:54 AM
hokein edited edge metadata.

Address review comment.

hokein marked an inline comment as done.Feb 11 2016, 1:55 AM
This revision was automatically updated to reflect the committed changes.