[cfe-commits] r94811 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-exprs.cpp
Douglas Gregor
dgregor at apple.com
Fri Jan 29 08:37:10 PST 2010
Author: dgregor
Date: Fri Jan 29 10:37:09 2010
New Revision: 94811
URL: http://llvm.org/viewvc/llvm-project?rev=94811&view=rev
Log:
Name mangling for cast expressions, from Matthias Schiffer! Fixes PR5876.
Added:
cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp (with props)
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=94811&r1=94810&r2=94811&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Fri Jan 29 10:37:09 2010
@@ -1098,6 +1098,24 @@
break;
}
+ case Expr::ImplicitCastExprClass: {
+ mangleExpression(cast<ImplicitCastExpr>(E)->getSubExpr());
+ break;
+ }
+
+ case Expr::CStyleCastExprClass:
+ case Expr::CXXStaticCastExprClass:
+ case Expr::CXXDynamicCastExprClass:
+ case Expr::CXXReinterpretCastExprClass:
+ case Expr::CXXConstCastExprClass:
+ case Expr::CXXFunctionalCastExprClass: {
+ const ExplicitCastExpr *ECE = cast<ExplicitCastExpr>(E);
+ Out << "cv";
+ mangleType(ECE->getType());
+ mangleExpression(ECE->getSubExpr());
+ break;
+ }
+
case Expr::CXXOperatorCallExprClass: {
const CXXOperatorCallExpr *CE = cast<CXXOperatorCallExpr>(E);
unsigned NumArgs = CE->getNumArgs();
Added: cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp?rev=94811&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp Fri Jan 29 10:37:09 2010
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+template < bool condition, typename T = void >
+struct enable_if { typedef T type; };
+
+template< typename T >
+struct enable_if< false, T > {};
+
+// PR5876
+namespace Casts {
+ template< unsigned O >
+ void implicit(typename enable_if< O <= 4 >::type* = 0) {
+ }
+
+ template< unsigned O >
+ void cstyle(typename enable_if< O <= (unsigned)4 >::type* = 0) {
+ }
+
+ template< unsigned O >
+ void functional(typename enable_if< O <= unsigned(4) >::type* = 0) {
+ }
+
+ template< unsigned O >
+ void static_(typename enable_if< O <= static_cast<unsigned>(4) >::type* = 0) {
+ }
+
+ // FIXME: Test const_cast, reinterpret_cast, dynamic_cast, which are
+ // a bit harder to use in template arguments.
+ template <unsigned N> struct T {};
+
+ template <int N> T<N> f() { return T<N>(); }
+
+ // CHECK: define void @_ZN5Casts8implicitILj4EEEvPN9enable_ifIXleT_Li4EEvE4typeE
+ template void implicit<4>(void*);
+ // CHECK: define void @_ZN5Casts6cstyleILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+ template void cstyle<4>(void*);
+ // CHECK: define void @_ZN5Casts10functionalILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+ template void functional<4>(void*);
+ // CHECK: define void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+ template void static_<4>(void*);
+
+ // CHECK: define i64 @_ZN5Casts1fILi6EEENS_1TIXT_EEEv
+ template T<6> f<6>();
+}
Propchange: cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list