[cfe-commits] r158763 - in /cfe/trunk: lib/AST/ExprCXX.cpp test/CodeGenCXX/dynamic-cast-always-null.cpp
Sean Hunt
scshunt at csclub.uwaterloo.ca
Tue Jun 19 16:44:56 PDT 2012
Author: coppro
Date: Tue Jun 19 18:44:55 2012
New Revision: 158763
URL: http://llvm.org/viewvc/llvm-project?rev=158763&view=rev
Log:
Do not crash when we dynamic cast a final type to void*.
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/test/CodeGenCXX/dynamic-cast-always-null.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=158763&r1=158762&r2=158763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Jun 19 18:44:55 2012
@@ -553,6 +553,9 @@
DestType = DestType->castAs<PointerType>()->getPointeeType();
}
+ if (DestType->isVoidType())
+ return false;
+
const CXXRecordDecl *SrcRD =
cast<CXXRecordDecl>(SrcType->castAs<RecordType>()->getDecl());
Modified: cfe/trunk/test/CodeGenCXX/dynamic-cast-always-null.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dynamic-cast-always-null.cpp?rev=158763&r1=158762&r2=158763&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dynamic-cast-always-null.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dynamic-cast-always-null.cpp Tue Jun 19 18:44:55 2012
@@ -17,3 +17,8 @@
// CHECK: ret %struct.C* undef
return dynamic_cast<C&>(b);
}
+
+void dont_crash() {
+ (void) dynamic_cast<void*>((A*)0);
+ (void) dynamic_cast<void*>((B*)0);
+}
More information about the cfe-commits
mailing list