| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s |
| 2 |
|
| 3 |
// PR12871 |
| 4 |
class PlotPoint { |
| 5 |
bool valid; |
| 6 |
}; |
| 7 |
|
| 8 |
PlotPoint limitedFit () { |
| 9 |
PlotPoint fit0; |
| 10 |
fit0 = limitedFit (); |
| 11 |
return fit0; |
| 12 |
} |
| 13 |
|
| 14 |
namespace boost {namespace filesystem3 { |
| 15 |
class path { |
| 16 |
public: |
| 17 |
path(){} |
| 18 |
}; |
| 19 |
|
| 20 |
}} |
| 21 |
namespace boost |
| 22 |
{ |
| 23 |
namespace filesystem |
| 24 |
{ |
| 25 |
using filesystem3::path; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
void radar11487541() { |
| 30 |
namespace fs = boost::filesystem; |
| 31 |
fs::path p; |
| 32 |
} |
| 33 |
|
| 34 |
// PR12873 |
| 35 |
void testFloatInitializer() { |
| 36 |
const float ysize={0.015}, xsize={0.01}; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
// PR12874 |
| 41 |
template<class T> struct addr_impl_ref { |
| 42 |
T & v_; |
| 43 |
inline addr_impl_ref( T & v ): v_( v ) { |
| 44 |
} |
| 45 |
inline operator T& () const {return v_;} |
| 46 |
}; |
| 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))); |
| 50 |
} |
| 51 |
}; |
| 52 |
template<class T> T * addressof( T & v ) { |
| 53 |
return addressof_impl<T>::f( addr_impl_ref<T>( v ), 0 ); |
| 54 |
} |
| 55 |
void testRadar11487525_1(){ |
| 56 |
bool s[25]; |
| 57 |
addressof(s); |
| 58 |
} |
| 59 |
|
| 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; |
| 65 |
} |
| 66 |
|
| 67 |
// Don't crash on "assuming" a ComoundVal. |
| 68 |
class JSONWireProtocolInputStream { |
| 69 |
public: |
| 70 |
virtual ~JSONWireProtocolInputStream(); |
| 71 |
}; |
| 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; |
| 80 |
}; |
| 81 |
class SocketWireProtocolStream : public JSONWireProtocolInputStream { |
| 82 |
}; |
| 83 |
void test() { |
| 84 |
SocketWireProtocolStream stream{}; |
| 85 |
JSONWireProtocolReader reader{stream}; |
| 86 |
} |
| 87 |
|
| 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}} |
| 93 |
} |
| 94 |
} |