]> granicus.if.org Git - clang/commitdiff
fix PR7892, a crash on valid in c++ codegen of __PRETTY_FUNCTION__
authorChris Lattner <sabre@nondot.org>
Tue, 17 Aug 2010 23:58:10 +0000 (23:58 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Aug 2010 23:58:10 +0000 (23:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111330 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/expr.cpp

index e2ccf55f93752fb5a845bedb7db0f4e177d8efa3..e9788709963002236a13dfda69084389b6d0f48f 100644 (file)
@@ -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());
index d92cfb46a45447d73cde0d6da8da7b1b130f1eed..26bda055b3d768939edeaa7118a057c0dd4a5516 100644 (file)
@@ -14,3 +14,7 @@ void test1() {
 // PR5514
 int a;
 void test2() { ++a+=10; }
+
+// PR7892
+int test3(const char*);
+int test3g = test3(__PRETTY_FUNCTION__);