r194716 - [analyzer] Treat MSVC's _wassert as noreturn.
Jordan Rose
jordan_rose at apple.com
Thu Nov 14 09:55:00 PST 2013
Author: jrose
Date: Thu Nov 14 11:55:00 2013
New Revision: 194716
URL: http://llvm.org/viewvc/llvm-project?rev=194716&view=rev
Log:
[analyzer] Treat MSVC's _wassert as noreturn.
This makes sure the analyzer actually honors assert() in an MSVC project.
Patch by Anders Montonen!
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/test/Analysis/NoReturn.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp?rev=194716&r1=194715&r2=194716&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp Thu Nov 14 11:55:00 2013
@@ -64,6 +64,9 @@ void NoReturnFunctionChecker::checkPostC
.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)
Modified: cfe/trunk/test/Analysis/NoReturn.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NoReturn.m?rev=194716&r1=194715&r2=194716&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NoReturn.m (original)
+++ cfe/trunk/test/Analysis/NoReturn.m Thu Nov 14 11:55:00 2013
@@ -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
+}
More information about the cfe-commits
mailing list