summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/MicrosoftMangle.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2012-11-13 22:09:44 +0000
committerNico Weber <nicolasweber@gmx.de>2012-11-13 22:09:44 +0000
commit3ad723ca2eebbef8c480574092888d290a18254e (patch)
treed90b5fdb7db562de89ad44e3279a953c30b35ac7 /clang/lib/AST/MicrosoftMangle.cpp
parentf1aef758a7902c73ef7f2dd568bef8ad47f93006 (diff)
downloadbcm5719-llvm-3ad723ca2eebbef8c480574092888d290a18254e.tar.gz
bcm5719-llvm-3ad723ca2eebbef8c480574092888d290a18254e.zip
[ms] Make mangleIntegerLiteral less aware of exact type of the literal.
Integer literal mangling does not actually depend on exact type of the literal. This will simplify calling mangleIntegerLiteral when literal type is not known, for example, when sizes or offsets are mangled as integer literals. Also, call mangleNumber instead of directly printing mangled values of 0/1, to avoid this knowledge from being in multiple places. Patch from Evgeny Eltsin! llvm-svn: 167878
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r--clang/lib/AST/MicrosoftMangle.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 08dbfafe64c..98da920a8fa 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -96,7 +96,7 @@ private:
void mangleExtraDimensions(QualType T);
void mangleFunctionClass(const FunctionDecl *FD);
void mangleCallingConvention(const FunctionType *T, bool IsInstMethod = false);
- void mangleIntegerLiteral(QualType T, const llvm::APSInt &Number);
+ void mangleIntegerLiteral(const llvm::APSInt &Number, bool IsBoolean);
void mangleExpression(const Expr *E);
void mangleThrowSpecification(const FunctionProtoType *T);
@@ -759,13 +759,13 @@ MicrosoftCXXNameMangler::mangleUnscopedTemplateName(const TemplateDecl *TD) {
}
void
-MicrosoftCXXNameMangler::mangleIntegerLiteral(QualType T,
- const llvm::APSInt &Value) {
+MicrosoftCXXNameMangler::mangleIntegerLiteral(const llvm::APSInt &Value,
+ bool IsBoolean) {
// <integer-literal> ::= $0 <number>
Out << "$0";
// Make sure booleans are encoded as 0/1.
- if (T->isBooleanType())
- Out << (Value.getBoolValue() ? "0" : "A@");
+ if (IsBoolean && Value.getBoolValue())
+ mangleNumber(1);
else
mangleNumber(Value);
}
@@ -775,7 +775,7 @@ MicrosoftCXXNameMangler::mangleExpression(const Expr *E) {
// See if this is a constant expression.
llvm::APSInt Value;
if (E->isIntegerConstantExpr(Value, Context.getASTContext())) {
- mangleIntegerLiteral(E->getType(), Value);
+ mangleIntegerLiteral(Value, E->getType()->isBooleanType());
return;
}
@@ -802,7 +802,8 @@ MicrosoftCXXNameMangler::mangleTemplateArgs(
mangleType(TA.getAsType(), TAL.getSourceRange());
break;
case TemplateArgument::Integral:
- mangleIntegerLiteral(TA.getIntegralType(), TA.getAsIntegral());
+ mangleIntegerLiteral(TA.getAsIntegral(),
+ TA.getIntegralType()->isBooleanType());
break;
case TemplateArgument::Expression:
mangleExpression(TA.getAsExpr());
OpenPOWER on IntegriCloud