diff options
author | Chris Lattner <sabre@nondot.org> | 2010-08-17 23:58:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-08-17 23:58:10 +0000 |
commit | 5c12c7bde7e39758fb127ac7089ac88097408e8e (patch) | |
tree | 3206b8edb2becc6f95924cf8ecec3f9e8b598fdc | |
parent | cced08e13c9fba9381e39a27c70abe6978adee37 (diff) |
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
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 6 | ||||
-rw-r--r-- | test/CodeGenCXX/expr.cpp | 4 |
2 files changed, 9 insertions, 1 deletions
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()); diff --git a/test/CodeGenCXX/expr.cpp b/test/CodeGenCXX/expr.cpp index d92cfb46a4..26bda055b3 100644 --- a/test/CodeGenCXX/expr.cpp +++ b/test/CodeGenCXX/expr.cpp @@ -14,3 +14,7 @@ void test1() { // PR5514 int a; void test2() { ++a+=10; } + +// PR7892 +int test3(const char*); +int test3g = test3(__PRETTY_FUNCTION__); |