diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-06-11 23:20:52 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-06-11 23:20:52 +0000 |
commit | 570d03c6831a8e19447dc863aa94ffff020077eb (patch) | |
tree | b513219a733e1b553a92ad5cbc8928b3864d3966 /test/Analysis/casts.cpp | |
parent | dd895f056bff47d2d1a924b49e7b40d48749fcc0 (diff) |
[analyzer] Treat LValueBitCasts like regular pointer bit casts.
These casts only appear in very well-defined circumstances, in which the
target of a reinterpret_cast or a function formal parameter is an lvalue
reference. According to the C++ standard, the following are equivalent:
reinterpret_cast<T&>( x)
*reinterpret_cast<T*>(&x)
[expr.reinterpret.cast]p11
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/casts.cpp')
-rw-r--r-- | test/Analysis/casts.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/Analysis/casts.cpp b/test/Analysis/casts.cpp new file mode 100644 index 0000000000..046ffb53c8 --- /dev/null +++ b/test/Analysis/casts.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s + +void fill_r (int * const &x); + +char testPointer () { + int x[8]; + int *xp = x; + fill_r(xp); + + return x[0]; // no-warning +} + +char testArray () { + int x[8]; + fill_r(x); + + return x[0]; // no-warning +} + +char testReferenceCast () { + int x[8]; + int *xp = x; + fill_r(reinterpret_cast<int * const &>(xp)); + + return x[0]; // no-warning +} + + +void fill (int *x); +char testReferenceCastRValue () { + int x[8]; + int *xp = x; + fill(reinterpret_cast<int * const &>(xp)); + + return x[0]; // no-warning +} |