summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2012-04-18 22:24:33 +0000
committerDan Gohman <gohman@apple.com>2012-04-18 22:24:33 +0000
commit22fbe8d709bfeb27f8268d9767c9a0b1a7d8cc2e (patch)
tree0252ede8d71f133b88554f288d6838c211abe350
parentbb963dfb7ebeab75764e962734c88aca44422dbf (diff)
downloadbcm5719-llvm-22fbe8d709bfeb27f8268d9767c9a0b1a7d8cc2e.tar.gz
bcm5719-llvm-22fbe8d709bfeb27f8268d9767c9a0b1a7d8cc2e.zip
Don't crash on code where the user put __attribute__((constructor)) on
a function with arguments. This fixes rdar://11265785. llvm-svn: 155073
-rw-r--r--llvm/lib/Transforms/Scalar/ObjCARC.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/ObjCARC.cpp b/llvm/lib/Transforms/Scalar/ObjCARC.cpp
index 7e3e69b78d3..29234da644f 100644
--- a/llvm/lib/Transforms/Scalar/ObjCARC.cpp
+++ b/llvm/lib/Transforms/Scalar/ObjCARC.cpp
@@ -1033,7 +1033,11 @@ bool ObjCARCAPElim::runOnModule(Module &M) {
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;
OpenPOWER on IntegriCloud