[cfe-commits] r157401 - in /cfe/trunk: lib/StaticAnalyzer/Core/SValBuilder.cpp test/Analysis/cxx11-crashes.cpp
Anna Zaks
ganna at apple.com
Thu May 24 10:31:57 PDT 2012
Author: zaks
Date: Thu May 24 12:31:57 2012
New Revision: 157401
URL: http://llvm.org/viewvc/llvm-project?rev=157401&view=rev
Log:
[analyzer] Treat cast of array to reference in the same way as array to
pointer.
Fixes one of the crashes reported in PR12874.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/Analysis/cxx11-crashes.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=157401&r1=157400&r2=157401&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Thu May 24 12:31:57 2012
@@ -325,7 +325,7 @@
// Are we casting from an array to a pointer? If so just pass on
// the decayed value.
- if (castTy->isPointerType())
+ if (castTy->isPointerType() || castTy->isReferenceType())
return val;
// Are we casting from an array to an integer? If so, cast the decayed
Modified: cfe/trunk/test/Analysis/cxx11-crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx11-crashes.cpp?rev=157401&r1=157400&r2=157401&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/cxx11-crashes.cpp (original)
+++ cfe/trunk/test/Analysis/cxx11-crashes.cpp Thu May 24 12:31:57 2012
@@ -36,3 +36,24 @@
void testFloatInitializer() {
const float ysize={0.015}, xsize={0.01};
}
+
+
+// PR12874, radar://11487525
+template<class T> struct addr_impl_ref {
+ T & v_;
+ inline addr_impl_ref( T & v ): v_( v ) {
+ }
+ inline operator T& () const {return v_;}
+};
+template<class T> struct addressof_impl {
+ static inline T * f( T & v, long ) {
+ return reinterpret_cast<T*>(&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
+ }
+};
+template<class T> T * addressof( T & v ) {
+ return addressof_impl<T>::f( addr_impl_ref<T>( v ), 0 );
+}
+void testRadar11487525_1(){
+ bool s[25];
+ addressof(s);
+}
More information about the cfe-commits
mailing list