summaryrefslogtreecommitdiffstats
path: root/test/Analysis
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-06 20:02:26 +0000
committerdim <dim@FreeBSD.org>2016-01-06 20:02:26 +0000
commitfc74ff5a0792641885551a63d9ddf8cbfdf76e3c (patch)
tree955a1295c3fd4378a49478ad5835ca21b769417e /test/Analysis
parent3176e97f130184ece0e1a21352c8124cc83ff24a (diff)
downloadFreeBSD-src-fc74ff5a0792641885551a63d9ddf8cbfdf76e3c.zip
FreeBSD-src-fc74ff5a0792641885551a63d9ddf8cbfdf76e3c.tar.gz
Vendor import of clang trunk r256945:
https://llvm.org/svn/llvm-project/cfe/trunk@256945
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/Inputs/qt-simulator.h16
-rw-r--r--test/Analysis/Inputs/system-header-simulator-cxx.h19
-rw-r--r--test/Analysis/inlining/stl.cpp5
-rw-r--r--test/Analysis/null-deref-ps.c18
-rw-r--r--test/Analysis/nullptr.cpp19
-rw-r--r--test/Analysis/qt_malloc.cpp15
6 files changed, 92 insertions, 0 deletions
diff --git a/test/Analysis/Inputs/qt-simulator.h b/test/Analysis/Inputs/qt-simulator.h
new file mode 100644
index 0000000..d1d6c03
--- /dev/null
+++ b/test/Analysis/Inputs/qt-simulator.h
@@ -0,0 +1,16 @@
+#pragma clang system_header
+
+struct QObject {
+};
+
+struct QEvent {
+ enum Type { None };
+ QEvent(Type) {}
+};
+
+struct QCoreApplication : public QObject {
+ static void postEvent(QObject *receiver, QEvent *event);
+ static QCoreApplication *instance();
+};
+
+struct QApplication : public QCoreApplication {};
diff --git a/test/Analysis/Inputs/system-header-simulator-cxx.h b/test/Analysis/Inputs/system-header-simulator-cxx.h
index 3586921..f9049c3 100644
--- a/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ b/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -198,6 +198,25 @@ namespace std {
storage.assignExternal(new _CharT[4]);
}
};
+
+template<class _Engine, class _UIntType>
+class __independent_bits_engine {
+public:
+ // constructors and seeding functions
+ __independent_bits_engine(_Engine& __e, size_t __w);
+};
+
+template<class _Engine, class _UIntType>
+__independent_bits_engine<_Engine, _UIntType>
+ ::__independent_bits_engine(_Engine& __e, size_t __w)
+{
+ // Fake error trigger.
+ // No warning is expected as we are suppressing warning coming
+ // out of std::basic_string.
+ int z = 0;
+ z = 5/z;
+}
+
}
void* operator new(std::size_t, const std::nothrow_t&) throw();
diff --git a/test/Analysis/inlining/stl.cpp b/test/Analysis/inlining/stl.cpp
index 711c30f..2a8520f 100644
--- a/test/Analysis/inlining/stl.cpp
+++ b/test/Analysis/inlining/stl.cpp
@@ -47,3 +47,8 @@ void testBasicStringSuppression_assign(std::basic_string<char32_t> &v,
const std::basic_string<char32_t> &v2) {
v = v2;
}
+
+class MyEngine;
+void testSupprerssion_independent_bits_engine(MyEngine& e) {
+ std::__independent_bits_engine<MyEngine, unsigned int> x(e, 64); // no-warning
+}
diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c
index 240e8ed..79b3b3a 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -311,3 +311,21 @@ int foo10595327(int b) {
return *p; // no-warning
return 0;
}
+
+#define AS_ATTRIBUTE volatile __attribute__((address_space(256)))
+#define _get_base() ((void * AS_ATTRIBUTE *)0)
+void* test_address_space_array(unsigned long slot) {
+ return _get_base()[slot]; // no-warning
+}
+void test_address_space_condition(int AS_ATTRIBUTE *cpu_data) {
+ if (cpu_data == 0) {
+ *cpu_data = 3; // no-warning
+ }
+}
+struct X { int member; };
+int test_address_space_member() {
+ struct X AS_ATTRIBUTE *data = (struct X AS_ATTRIBUTE *)0UL;
+ int ret;
+ ret = data->member; // no-warning
+ return ret;
+}
diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp
index 17320f3..acc525e 100644
--- a/test/Analysis/nullptr.cpp
+++ b/test/Analysis/nullptr.cpp
@@ -126,3 +126,22 @@ decltype(nullptr) returnsNullPtrType();
void fromReturnType() {
((X *)returnsNullPtrType())->f(); // expected-warning{{Called C++ object pointer is null}}
}
+
+#define AS_ATTRIBUTE __attribute__((address_space(256)))
+class AS1 {
+public:
+ int x;
+ ~AS1() {
+ int AS_ATTRIBUTE *x = 0;
+ *x = 3; // no-warning
+ }
+};
+void test_address_space_field_access() {
+ AS1 AS_ATTRIBUTE *pa = 0;
+ pa->x = 0; // no-warning
+}
+void test_address_space_bind() {
+ AS1 AS_ATTRIBUTE *pa = 0;
+ AS1 AS_ATTRIBUTE &r = *pa;
+ r.x = 0; // no-warning
+}
diff --git a/test/Analysis/qt_malloc.cpp b/test/Analysis/qt_malloc.cpp
new file mode 100644
index 0000000..d29835f
--- /dev/null
+++ b/test/Analysis/qt_malloc.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus -analyzer-store=region -verify %s
+// expected-no-diagnostics
+#include "Inputs/qt-simulator.h"
+
+void send(QObject *obj)
+{
+ QEvent *e1 = new QEvent(QEvent::None);
+ static_cast<QApplication *>(QCoreApplication::instance())->postEvent(obj, e1);
+ QEvent *e2 = new QEvent(QEvent::None);
+ QCoreApplication::instance()->postEvent(obj, e2);
+ QEvent *e3 = new QEvent(QEvent::None);
+ QCoreApplication::postEvent(obj, e3);
+ QEvent *e4 = new QEvent(QEvent::None);
+ QApplication::postEvent(obj, e4);
+}
OpenPOWER on IntegriCloud