summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2015-12-30 00:08:59 +0000
committerDevin Coughlin <dcoughlin@apple.com>2015-12-30 00:08:59 +0000
commit3369867aa7a7ec4016cad188c66c51ea2264dae4 (patch)
treeef9f8cf3c8697d8dea83225a22f9d6329dbf0108
parentcda3bc206244de2b04ea3d20874d13ba53c47259 (diff)
downloadbcm5719-llvm-3369867aa7a7ec4016cad188c66c51ea2264dae4.tar.gz
bcm5719-llvm-3369867aa7a7ec4016cad188c66c51ea2264dae4.zip
[analyzer] Handle another Android assert function.
Android's assert can call both the __assert and __assert2 functions under the cover, but the NoReturnFunctionChecker does not handle the latter. This commit fixes that. A patch by Yury Gribov! Differential Revision: http://reviews.llvm.org/D15810 llvm-svn: 256605
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp1
-rw-r--r--clang/test/Analysis/NoReturn.m12
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
index 8d0a060fc45..c1deadef420 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
@@ -66,6 +66,7 @@ void NoReturnFunctionChecker::checkPostCall(const CallEvent &CE,
.Case("assfail", true)
.Case("db_error", true)
.Case("__assert", true)
+ .Case("__assert2", 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)
diff --git a/clang/test/Analysis/NoReturn.m b/clang/test/Analysis/NoReturn.m
index 9b7011e7931..5ed92dfe5d4 100644
--- a/clang/test/Analysis/NoReturn.m
+++ b/clang/test/Analysis/NoReturn.m
@@ -131,3 +131,15 @@ void test_wassert() {
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
+#undef assert
+
+// Test that hard-coded Android __assert2 name is recognized as a noreturn
+#define assert(_Expression) ((_Expression) ? (void)0 : __assert2(0, 0, 0, 0));
+extern void __assert2(const char *, int, const char *, const char *);
+extern void _wassert(const char * _Message, const char *_File, unsigned _Line);
+void test___assert2() {
+ assert(0);
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+#undef assert
OpenPOWER on IntegriCloud