aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/ExprTypeConvert.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-09 00:16:00 +0000
committerChris Lattner <sabre@nondot.org>2002-10-09 00:16:00 +0000
commitcd484a47ea5c2dfeccd392b0a9ad59a09889f098 (patch)
treeefe912fa7ba3096bb68486f94da05f10385f341e /lib/Transforms/ExprTypeConvert.cpp
parentb58d0d54a1a32b5121f94c47a735c674320cf294 (diff)
- Rename MTy to FTy (no methods exist anymore)
- Fix bug: LevelRaise/2002-10-08-VarArgCallInfLoop.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/ExprTypeConvert.cpp')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index f03253fac8..995df98b6b 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -782,8 +782,12 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
if (OpNum == 0) {
const PointerType *PTy = dyn_cast<PointerType>(Ty);
if (PTy == 0) return false; // Can't convert to a non-pointer type...
- const FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType());
- if (MTy == 0) return false; // Can't convert to a non ptr to function...
+ const FunctionType *FTy = dyn_cast<FunctionType>(PTy->getElementType());
+ if (FTy == 0) return false; // Can't convert to a non ptr to function...
+
+ // Do not allow converting to a call where all of the operands are ...'s
+ if (FTy->getNumParams() == 0 && FTy->isVarArg())
+ return false; // Do not permit this conversion!
// Perform sanity checks to make sure that new function type has the
// correct number of arguments...
@@ -793,12 +797,12 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// Cannot convert to a type that requires more fixed arguments than
// the call provides...
//
- if (NumArgs < MTy->getParamTypes().size()) return false;
+ if (NumArgs < FTy->getNumParams()) return false;
// Unless this is a vararg function type, we cannot provide more arguments
// than are desired...
//
- if (!MTy->isVarArg() && NumArgs > MTy->getParamTypes().size())
+ if (!FTy->isVarArg() && NumArgs > FTy->getNumParams())
return false;
// Okay, at this point, we know that the call and the function type match
@@ -808,7 +812,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// reason for this is that we prefer to have resolved functions but casted
// arguments if possible.
//
- const FunctionType::ParamTypes &PTs = MTy->getParamTypes();
+ const FunctionType::ParamTypes &PTs = FTy->getParamTypes();
for (unsigned i = 0, NA = PTs.size(); i < NA; ++i)
if (!PTs[i]->isLosslesslyConvertableTo(I->getOperand(i+1)->getType()))
return false; // Operands must have compatible types!
@@ -817,14 +821,14 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// converted. We succeed if we can change the return type if
// neccesary...
//
- return ValueConvertableToType(I, MTy->getReturnType(), CTMap);
+ return ValueConvertableToType(I, FTy->getReturnType(), CTMap);
}
const PointerType *MPtr = cast<PointerType>(I->getOperand(0)->getType());
- const FunctionType *MTy = cast<FunctionType>(MPtr->getElementType());
- if (!MTy->isVarArg()) return false;
+ const FunctionType *FTy = cast<FunctionType>(MPtr->getElementType());
+ if (!FTy->isVarArg()) return false;
- if ((OpNum-1) < MTy->getParamTypes().size())
+ if ((OpNum-1) < FTy->getParamTypes().size())
return false; // It's not in the varargs section...
// If we get this far, we know the value is in the varargs section of the