From 1c8af74744a8f7a917fb129246e79616da283df1 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 8 Apr 2014 18:13:24 +0000 Subject: Add support for MSVC's __FUNCSIG__ It is very similar to GCC's __PRETTY_FUNCTION__, except it prints the calling convention. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D3311 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205780 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 1bdd094873..badde1b7c9 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1953,33 +1953,27 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { case PredefinedExpr::Function: case PredefinedExpr::LFunction: case PredefinedExpr::FuncDName: + case PredefinedExpr::FuncSig: case PredefinedExpr::PrettyFunction: { PredefinedExpr::IdentType IdentType = E->getIdentType(); - std::string GlobalVarName; + std::string GVName; + // FIXME: We should use the string literal mangling for the Microsoft C++ + // ABI so that strings get merged. switch (IdentType) { default: llvm_unreachable("Invalid type"); - case PredefinedExpr::Func: - GlobalVarName = "__func__."; - break; - case PredefinedExpr::Function: - GlobalVarName = "__FUNCTION__."; - break; - case PredefinedExpr::FuncDName: - GlobalVarName = "__FUNCDNAME__."; - break; - case PredefinedExpr::LFunction: - GlobalVarName = "L__FUNCTION__."; - break; - case PredefinedExpr::PrettyFunction: - GlobalVarName = "__PRETTY_FUNCTION__."; - break; + case PredefinedExpr::Func: GVName = "__func__."; break; + case PredefinedExpr::Function: GVName = "__FUNCTION__."; break; + case PredefinedExpr::FuncDName: GVName = "__FUNCDNAME__."; break; + case PredefinedExpr::FuncSig: GVName = "__FUNCSIG__."; break; + case PredefinedExpr::LFunction: GVName = "L__FUNCTION__."; break; + case PredefinedExpr::PrettyFunction: GVName = "__PRETTY_FUNCTION__."; break; } StringRef FnName = CurFn->getName(); if (FnName.startswith("\01")) FnName = FnName.substr(1); - GlobalVarName += FnName; + GVName += FnName; // If this is outside of a function use the top level decl. const Decl *CurDecl = CurCodeDecl; @@ -2010,15 +2004,13 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { getContext().getTypeSizeInChars(ElemType).getQuantity(), FunctionName, RawChars); C = GetAddrOfConstantWideString(RawChars, - GlobalVarName.c_str(), + GVName.c_str(), getContext(), E->getType(), E->getLocation(), CGM); } else { - C = CGM.GetAddrOfConstantCString(FunctionName, - GlobalVarName.c_str(), - 1); + C = CGM.GetAddrOfConstantCString(FunctionName, GVName.c_str(), 1); } return MakeAddrLValue(C, E->getType()); } -- cgit v1.2.3