From 9dfe400dc23a73847807a103c0020cf5c38a9820 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 15 Mar 2014 06:47:45 +0000 Subject: -Wunreachable-code: treat 'const bool' locals as control values. llvm-svn: 204001 --- clang/lib/Analysis/ReachableCode.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/Analysis/ReachableCode.cpp') diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp index d297d03775d..71d41bb2839 100644 --- a/clang/lib/Analysis/ReachableCode.cpp +++ b/clang/lib/Analysis/ReachableCode.cpp @@ -236,7 +236,12 @@ static bool isConfigurationValue(const Stmt *S, // We could generalize this to local variables, but it isn't // clear if those truly represent configuration values that // gate unreachable code. - return !VD->hasLocalStorage(); + if (!VD->hasLocalStorage()) + return true; + + // As a heuristic, locals that have been marked 'const' explicitly + // can be treated as configuration values as well. + return VD->getType().isLocalConstQualified(); } return false; } -- cgit v1.2.3