From f266c81b2d692068d49e682f50447ef700f10fc6 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sun, 21 Dec 2014 22:00:40 +0100 Subject: [PATCH] Don't call isIntegerConstantExpr if isValueDependent ...some paths trough clang::Expr::isIntegerConstantExpr (esp. if non-CPlusPlus11) assert the assumption that the given expr is not value-dependent, so it appears to be a prereq Change-Id: Ibc5fe472ea3f91b31c8cb7f06c4b7c7f4d6831a3 --- compilerplugins/clang/literaltoboolconversion.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx index b84500a595b3..07a7e5084fa0 100644 --- a/compilerplugins/clang/literaltoboolconversion.cxx +++ b/compilerplugins/clang/literaltoboolconversion.cxx @@ -47,7 +47,8 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( return true; } APSInt res; - if (sub->isIntegerConstantExpr(res, compiler.getASTContext()) + if (!sub->isValueDependent() + && sub->isIntegerConstantExpr(res, compiler.getASTContext()) && res.getLimitedValue() <= 1) { SourceLocation loc { sub->getLocStart() }; @@ -132,7 +133,9 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( expr->getLocStart()) << expr->getCastKindName() << expr->getSubExpr()->getType() << expr->getType() << expr->getSourceRange(); - } else if (sub->isIntegerConstantExpr(res, compiler.getASTContext())) { + } else if (!sub->isValueDependent() + && sub->isIntegerConstantExpr(res, compiler.getASTContext())) + { report( DiagnosticsEngine::Warning, ("implicit conversion (%0) of integer constant expression of type"