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.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D17069
llvm-svn: 260505
if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt())
CondEndLoc = CondVar->getLocEnd();
- assert(CondEndLoc.isValid());
+ if (!CondEndLoc.isValid()) {
+ return SourceLocation();
+ }
+
SourceLocation PastCondEndLoc =
Lexer::getLocForEndOfToken(CondEndLoc, 0, SM, Context->getLangOpts());
if (PastCondEndLoc.isInvalid())
--- /dev/null
+// RUN: %check_clang_tidy %s readability-braces-around-statements %t
+
+int test_failure() {
+ if (std::rand()) {
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: error: use of undeclared identifier 'std'
+ }
+}