[clang-tools-extra] r260953 - [clang-tidy] Fix an assert failure in `modernize-loop-convert`.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 16 02:36:51 PST 2016
Author: hokein
Date: Tue Feb 16 04:36:51 2016
New Revision: 260953
URL: http://llvm.org/viewvc/llvm-project?rev=260953&view=rev
Log:
[clang-tidy] Fix an assert failure in `modernize-loop-convert`.
Summary:
The test code will trigger following an assert failure:
assert.h assertion failed at LoopConvertUtils.cpp:560 in
bool clang::tidy::modernize::ForLoopIndexUseVisitor::TraverseMemberExpr(clang::MemberExpr*): ExprType->isPointerType() && "Operator-> returned non-pointer type"
Reviewers: alexfh
Differential Revision: http://reviews.llvm.org/D17287
Added:
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=260953&r1=260952&r2=260953&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Tue Feb 16 04:36:51 2016
@@ -557,7 +557,9 @@ bool ForLoopIndexUseVisitor::TraverseMem
if (ExprType.isNull())
ExprType = Obj->getType();
- assert(ExprType->isPointerType() && "Operator-> returned non-pointer type");
+ if (!ExprType->isPointerType())
+ return false;
+
// FIXME: This works around not having the location of the arrow operator.
// Consider adding OperatorLoc to MemberExpr?
SourceLocation ArrowLoc = Lexer::getLocForEndOfToken(
Added: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp?rev=260953&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp Tue Feb 16 04:36:51 2016
@@ -0,0 +1,18 @@
+// RUN: clang-tidy %s -checks=-*,modernize-loop-convert --
+
+// Note: this test expects no assert failure happened in clang-tidy.
+
+class LinguisticItem {
+ LinguisticItem *x0;
+ class x1 {
+ bool operator!= ( const x1 &;
+ operator* ( ;
+ LinguisticItem * &operator-> ( ;
+ operator++ (
+ } begin() const;
+ x1 end() const {
+ LinguisticStream x2;
+ for (x1 x3 = x2.begin x3 != x2.end; ++x3)
+ x3->x0
+ }
+};
More information about the cfe-commits
mailing list