Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / cxx11-crashes.cpp
blob26f2d04c6cb54ebb5a0ea3d906130d9d30f0dbba
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s
3 // PR12871
4 class PlotPoint {
5 bool valid;
6 };
8 PlotPoint limitedFit () {
9 PlotPoint fit0;
10 fit0 = limitedFit ();
11 return fit0;
14 namespace boost {namespace filesystem3 {
15 class path {
16 public:
17 path(){}
21 namespace boost
23 namespace filesystem
25 using filesystem3::path;
29 void radar11487541() {
30 namespace fs = boost::filesystem;
31 fs::path p;
34 // PR12873
35 void testFloatInitializer() {
36 const float ysize={0.015}, xsize={0.01};
40 // PR12874
41 template<class T> struct addr_impl_ref {
42 T & v_;
43 inline addr_impl_ref( T & v ): v_( v ) {
45 inline operator T& () const {return v_;}
47 template<class T> struct addressof_impl {
48 static inline T * f( T & v, long ) {
49 return reinterpret_cast<T*>(&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
52 template<class T> T * addressof( T & v ) {
53 return addressof_impl<T>::f( addr_impl_ref<T>( v ), 0 );
55 void testRadar11487525_1(){
56 bool s[25];
57 addressof(s);
60 // Don't crash on CK_LValueBitCast.
61 bool begin(double *it) {
62 typedef bool type[25];
63 bool *a = reinterpret_cast<type &>(*( reinterpret_cast<char *>( it )));
64 return *a;
67 // Don't crash on "assuming" a ComoundVal.
68 class JSONWireProtocolInputStream {
69 public:
70 virtual ~JSONWireProtocolInputStream();
72 class JSONWireProtocolReader {
73 public:
74 JSONWireProtocolReader(JSONWireProtocolInputStream& istream)
75 : _istream{istream} {} // On evaluating a bind here,
76 // the dereference checker issues an assume on a CompoundVal.
77 ~JSONWireProtocolReader();
78 private:
79 JSONWireProtocolInputStream& _istream;
81 class SocketWireProtocolStream : public JSONWireProtocolInputStream {
83 void test() {
84 SocketWireProtocolStream stream{};
85 JSONWireProtocolReader reader{stream};
88 // This crashed because the analyzer did not understand AttributedStmts.
89 void fallthrough() {
90 switch (1) {
91 case 1:
92 [[clang::fallthrough]]; // expected-error {{does not directly precede}}