[cfe-commits] r69658 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGen/blocks.c

Chris Lattner sabre at nondot.org
Mon Apr 20 21:41:23 PDT 2009


Author: lattner
Date: Mon Apr 20 23:41:23 2009
New Revision: 69658

URL: http://llvm.org/viewvc/llvm-project?rev=69658&view=rev
Log:
use of predefined identifiers like __func__ at global scope warn in sema,
but crashed codegen.  Fix this to report the name of the llvm function.
This fixes rdar://6808051

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGen/blocks.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=69658&r1=69657&r2=69658&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Apr 20 23:41:23 2009
@@ -753,7 +753,7 @@
   }
 
   std::string FunctionName;
-  if(const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl)) {
+  if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl)) {
     FunctionName = CGM.getMangledName(FD);
   } else {
     // Just get the mangled name; skipping the asm prefix if it

Modified: cfe/trunk/test/CodeGen/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks.c?rev=69658&r1=69657&r2=69658&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/blocks.c (original)
+++ cfe/trunk/test/CodeGen/blocks.c Mon Apr 20 23:41:23 2009
@@ -17,4 +17,10 @@
   return ^(struct s0 a1){ return a1; }(a0);
 }
 
+// This should not crash: rdar://6808051
+void *P = ^{
+  void *Q = __func__;
+};
+
+
 // RUN: true





More information about the cfe-commits mailing list