From 03fadabe47e8441c7d29db0314e79eddadeff969 Mon Sep 17 00:00:00 2001 From: Matthias Gehre Date: Thu, 14 Jul 2016 20:00:48 +0000 Subject: cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode Summary: When the expression is value dependent, isIntegerConstantExpr() crashes in C++03 mode with ../tools/clang/lib/AST/ExprConstant.cpp:9330: (anonymous namespace)::ICEDiag CheckICE(const clang::Expr *, const clang::ASTContext &): Assertion `!E->isValueDependent() && "Should not see value dependent exprs!"' failed. In C++11 mode, that assert does not trigger. This commit works around this in the check. We don't check value-dependent indices and instead check their specialization. Reviewers: alexfh, aaron.ballman Subscribers: nemanjai, cfe-commits Differential Revision: http://reviews.llvm.org/D22190 llvm-svn: 275461 --- .../clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp') diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp index 67e921bc3e8..a57ec49a199 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp @@ -65,6 +65,10 @@ void ProBoundsConstantArrayIndexCheck::check( const MatchFinder::MatchResult &Result) { const auto *Matched = Result.Nodes.getNodeAs("expr"); const auto *IndexExpr = Result.Nodes.getNodeAs("index"); + + if (IndexExpr->isValueDependent()) + return; // We check in the specialization. + llvm::APSInt Index; if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr, /*isEvaluated=*/true)) { -- cgit v1.2.3