diff options
author | Nico Weber <nicolasweber@gmx.de> | 2012-10-03 06:46:47 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2012-10-03 06:46:47 +0000 |
commit | 2225556de7186e9b22cd4da4e7d1f5c26daae8da (patch) | |
tree | ff870c82bb5114f3a08f293511387ccde726d5be /lib/AST/MicrosoftMangle.cpp | |
parent | 88a374ad85eec5a47bd172aa7b765d24fdf01690 (diff) |
Move expression mangling in the microsoft mangler to its own function.
This matches what's done in ItaniumMangle and makes it a bit easier
to implement mangling for more expressions. Also use the slightly nicer
"not yet implemented" error message from there.
No functionality change (except for the different error message).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | lib/AST/MicrosoftMangle.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 26b411952c..19ceca5fb2 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -96,6 +96,7 @@ private: void mangleFunctionClass(const FunctionDecl *FD); void mangleCallingConvention(const FunctionType *T, bool IsInstMethod = false); void mangleIntegerLiteral(QualType T, const llvm::APSInt &Number); + void mangleExpression(const Expr *E); void mangleThrowSpecification(const FunctionProtoType *T); void mangleTemplateArgs( @@ -785,6 +786,23 @@ MicrosoftCXXNameMangler::mangleIntegerLiteral(QualType T, } void +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); + return; + } + + // As bad as this diagnostic is, it's better than crashing. + DiagnosticsEngine &Diags = Context.getDiags(); + unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, + "cannot yet mangle expression type %0"); + Diags.Report(E->getExprLoc(), DiagID) + << E->getStmtClassName() << E->getSourceRange(); +} + +void MicrosoftCXXNameMangler::mangleTemplateArgs( const SmallVectorImpl<TemplateArgumentLoc> &TemplateArgs) { // <template-args> ::= {<type> | <integer-literal>}+ @ @@ -801,16 +819,9 @@ MicrosoftCXXNameMangler::mangleTemplateArgs( case TemplateArgument::Integral: mangleIntegerLiteral(TA.getIntegralType(), TA.getAsIntegral()); break; - case TemplateArgument::Expression: { - // See if this is a constant expression. - Expr *TAE = TA.getAsExpr(); - llvm::APSInt Value; - if (TAE->isIntegerConstantExpr(Value, Context.getASTContext())) { - mangleIntegerLiteral(TAE->getType(), Value); - break; - } - /* fallthrough */ - } + case TemplateArgument::Expression: + mangleExpression(TA.getAsExpr()); + break; case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: case TemplateArgument::Declaration: |