From 015da3534aaa687c47c520a5bc442c15b15b3d01 Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Fri, 21 Apr 2017 01:05:26 +0000 Subject: [analyzer] Fix assert in ExprEngine::processSwitch This diff replaces getTypeSize(CondE->getType())) with getIntWidth(CondE->getType())) in ExprEngine::processSwitch. These calls are not equivalent for bool, see ASTContext.cpp Add a test case. Test plan: make check-clang-analysis make check-clang Differential revision: https://reviews.llvm.org/D32328 llvm-svn: 300936 --- clang/test/Analysis/enum.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'clang/test/Analysis/enum.cpp') diff --git a/clang/test/Analysis/enum.cpp b/clang/test/Analysis/enum.cpp index e26b8f00d98..b561e65ac86 100644 --- a/clang/test/Analysis/enum.cpp +++ b/clang/test/Analysis/enum.cpp @@ -24,3 +24,16 @@ void testCasting(int i) { clang_analyzer_eval(j == 0); // expected-warning{{FALSE}} } } + +enum class EnumBool : bool { + F = false, + T = true +}; + +bool testNoCrashOnSwitchEnumBool(EnumBool E) { + switch (E) { + case EnumBool::F: + return false; + } + return true; +} -- cgit v1.2.3