[cfe-commits] r111330 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/expr.cpp

Chris Lattner sabre at nondot.org
Tue Aug 17 16:58:10 PDT 2010


Author: lattner
Date: Tue Aug 17 18:58:10 2010
New Revision: 111330

URL: http://llvm.org/viewvc/llvm-project?rev=111330&view=rev
Log:
fix PR7892, a crash on valid in c++ codegen of __PRETTY_FUNCTION__

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenCXX/expr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=111330&r1=111329&r2=111330&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Aug 17 18:58:10 2010
@@ -1287,8 +1287,12 @@
     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());

Modified: cfe/trunk/test/CodeGenCXX/expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/expr.cpp?rev=111330&r1=111329&r2=111330&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/expr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/expr.cpp Tue Aug 17 18:58:10 2010
@@ -14,3 +14,7 @@
 // PR5514
 int a;
 void test2() { ++a+=10; }
+
+// PR7892
+int test3(const char*);
+int test3g = test3(__PRETTY_FUNCTION__);





More information about the cfe-commits mailing list