This revision was automatically updated to reflect the committed changes.
Closed by commit rL260505: [clang-tidy] Fix an assert failure in
'readability-braces-around-statements'… (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D17069?vs=47609&id=47610#toc
Repository:
rL LLVM
http://reviews.llvm.org/D17069
Files:
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
Index:
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===================================================================
---
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -180,7 +180,10 @@
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())
Index:
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
===================================================================
---
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
+++
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
@@ -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'
+ }
+}
Index: clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -180,7 +180,10 @@
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())
Index: clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
@@ -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'
+ }
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits