[llvm-commits] [llvm] r155073 - /llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp

Dan Gohman gohman at apple.com
Wed Apr 18 15:24:33 PDT 2012


Author: djg
Date: Wed Apr 18 17:24:33 2012
New Revision: 155073

URL: http://llvm.org/viewvc/llvm-project?rev=155073&view=rev
Log:
Don't crash on code where the user put __attribute__((constructor)) on
a function with arguments. This fixes rdar://11265785.

Modified:
    llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=155073&r1=155072&r2=155073&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Wed Apr 18 17:24:33 2012
@@ -1033,7 +1033,11 @@
     Value *Op = *OI;
     // llvm.global_ctors is an array of pairs where the second members
     // are constructor functions.
-    Function *F = cast<Function>(cast<ConstantStruct>(Op)->getOperand(1));
+    Function *F = dyn_cast<Function>(cast<ConstantStruct>(Op)->getOperand(1));
+    // If the user used a constructor function with the wrong signature and
+    // it got bitcasted or whatever, look the other way.
+    if (!F)
+      continue;
     // Only look at function definitions.
     if (F->isDeclaration())
       continue;





More information about the llvm-commits mailing list