From 6973a27866b176b1cf4e3e3ebcf0196e101b85dd Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 14 Nov 2013 17:55:00 +0000 Subject: [PATCH] [analyzer] Treat MSVC's _wassert as noreturn. This makes sure the analyzer actually honors assert() in an MSVC project. Patch by Anders Montonen! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194716 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp | 3 +++ test/Analysis/NoReturn.m | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp b/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp index d7a880c660..0e1064ef53 100644 --- a/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp @@ -64,6 +64,9 @@ void NoReturnFunctionChecker::checkPostCall(const CallEvent &CE, .Case("assfail", true) .Case("db_error", true) .Case("__assert", true) + // For the purpose of static analysis, we do not care that + // this MSVC function will return if the user decides to continue. + .Case("_wassert", true) .Case("__assert_rtn", true) .Case("__assert_fail", true) .Case("dtrace_assfail", true) diff --git a/test/Analysis/NoReturn.m b/test/Analysis/NoReturn.m index a58efdd029..c74d54eae5 100644 --- a/test/Analysis/NoReturn.m +++ b/test/Analysis/NoReturn.m @@ -123,3 +123,11 @@ void PR11959(int *p) { *p = 0xDEADBEEF; // no-warning } +// Test that hard-coded Microsoft _wassert name is recognized as a noreturn +#define assert(_Expression) (void)( (!!(_Expression)) || (_wassert(#_Expression, __FILE__, __LINE__), 0) ) +extern void _wassert(const char * _Message, const char *_File, unsigned _Line); +void test_wassert() { + assert(0); + int *p = 0; + *p = 0xDEADBEEF; // no-warning +} -- 2.40.0