diff options
author | Dan Gohman <gohman@apple.com> | 2012-04-18 22:24:33 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2012-04-18 22:24:33 +0000 |
commit | 3b5b2a22ca8f5eddcaf322bdff4d0ad5ba342676 (patch) | |
tree | d77f433b116b8e0eee3b427bccf0db151c39e6f9 /lib | |
parent | bdcfb7663a2a62fd52a14dbeaa076423c719ec2d (diff) | |
download | external_llvm-3b5b2a22ca8f5eddcaf322bdff4d0ad5ba342676.zip external_llvm-3b5b2a22ca8f5eddcaf322bdff4d0ad5ba342676.tar.gz external_llvm-3b5b2a22ca8f5eddcaf322bdff4d0ad5ba342676.tar.bz2 |
Don't crash on code where the user put __attribute__((constructor)) on
a function with arguments. This fixes rdar://11265785.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/ObjCARC.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp index 7e3e69b..29234da 100644 --- a/lib/Transforms/Scalar/ObjCARC.cpp +++ b/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; |