diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-12 04:47:20 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-12 04:47:20 +0000 |
commit | edee94b615059ad178b06a489312eca6e049609a (patch) | |
tree | 63549d89376bdb8a8a36dfcb233c2bf72f3764a7 /lib/AST/ItaniumMangle.cpp | |
parent | 708554498595e047cc53e366c91cc063fcc1c5bc (diff) |
Implement the Itanium C++ ABI's mangling rule for
non-instantiation-dependent sizeof and alignof expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134963 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ItaniumMangle.cpp')
-rw-r--r-- | lib/AST/ItaniumMangle.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 7f1ea3aaca..958b4a26a0 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -2169,6 +2169,9 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { // <expr-primary> ::= L <type> <value number> E # integer literal // ::= L <type <value float> E # floating literal // ::= L <mangled-name> E # external name + QualType ImplicitlyConvertedToType; + +recurse: switch (E->getStmtClass()) { case Expr::NoStmtClass: #define ABSTRACT_STMT(Type) @@ -2363,6 +2366,23 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { case Expr::UnaryExprOrTypeTraitExprClass: { const UnaryExprOrTypeTraitExpr *SAE = cast<UnaryExprOrTypeTraitExpr>(E); + + if (!SAE->isInstantiationDependent()) { + // Itanium C++ ABI: + // If the operand of a sizeof or alignof operator is not + // instantiation-dependent it is encoded as an integer literal + // reflecting the result of the operator. + // + // If the result of the operator is implicitly converted to a known + // integer type, that type is used for the literal; otherwise, the type + // of std::size_t or std::ptrdiff_t is used. + QualType T = (ImplicitlyConvertedToType.isNull() || + !ImplicitlyConvertedToType->isIntegerType())? SAE->getType() + : ImplicitlyConvertedToType; + mangleIntegerLiteral(T, SAE->EvaluateAsInt(Context.getASTContext())); + break; + } + switch(SAE->getKind()) { case UETT_SizeOf: Out << 's'; @@ -2466,8 +2486,9 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { } case Expr::ImplicitCastExprClass: { - mangleExpression(cast<ImplicitCastExpr>(E)->getSubExpr(), Arity); - break; + ImplicitlyConvertedToType = E->getType(); + E = cast<ImplicitCastExpr>(E)->getSubExpr(); + goto recurse; } case Expr::ObjCBridgedCastExprClass: { |