From 5c12c7bde7e39758fb127ac7089ac88097408e8e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Aug 2010 23:58:10 +0000 Subject: fix PR7892, a crash on valid in c++ codegen of __PRETTY_FUNCTION__ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111330 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index e2ccf55f93..e978870996 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1287,8 +1287,12 @@ LValue CodeGenFunction::EmitPredefinedFunctionName(unsigned Type) { FnName = FnName.substr(1); GlobalVarName += FnName; + const Decl *CurDecl = CurCodeDecl; + if (CurDecl == 0) + CurDecl = getContext().getTranslationUnitDecl(); + std::string FunctionName = - PredefinedExpr::ComputeName((PredefinedExpr::IdentType)Type, CurCodeDecl); + PredefinedExpr::ComputeName((PredefinedExpr::IdentType)Type, CurDecl); llvm::Constant *C = CGM.GetAddrOfConstantCString(FunctionName, GlobalVarName.c_str()); -- cgit v1.2.3