forked from OSchip/llvm-project
[clang-tidy] Fix an assert failure in 'readability-braces-around-statements' check.
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
This commit is contained in:
parent
2260a3a046
commit
60c9316d62
|
@ -180,7 +180,10 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S,
|
|||
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())
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// 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'
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue