diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-06 11:30:55 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-06 11:30:55 -0800 |
commit | e8e4da6a470cbb8d5b88144363bd76a1d4805a00 (patch) | |
tree | 762599305a6b24262fcb1a831de0d1e599abdbfa | |
parent | 7b1e013089b699ee25191ff9017d3964686d3463 (diff) |
do not warn on invalid argument numbers or types in varargs calls
-rw-r--r-- | lib/Target/JSBackend/CallHandlers.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h index cfe4e25ec2..e1e8cbb46f 100644 --- a/lib/Target/JSBackend/CallHandlers.h +++ b/lib/Target/JSBackend/CallHandlers.h @@ -45,22 +45,24 @@ DEF_CALL_HANDLER(__default__, { NeedCasts = F->isDeclaration(); // if ffi call, need casts FT = F->getFunctionType(); if (EmscriptenAssertions) { - unsigned TypeNumArgs = FT->getNumParams(); - unsigned ActualNumArgs = getNumArgOperands(CI); - if (TypeNumArgs != ActualNumArgs) { - errs().changeColor(raw_ostream::YELLOW); - errs() << "warning:"; - errs().resetColor(); - errs() << " unexpected number of arguments " << utostr(ActualNumArgs) << " in call to '" << F->getName() << "', should be " << utostr(TypeNumArgs) << "\n"; - } - for (unsigned i = 0; i < std::min(TypeNumArgs, ActualNumArgs); i++) { - Type *TypeType = FT->getParamType(i); - Type *ActualType = CI->getOperand(i)->getType(); - if (getFunctionSignatureLetter(TypeType) != getFunctionSignatureLetter(ActualType)) { + if (!FT->isVarArg()) { + unsigned TypeNumArgs = FT->getNumParams(); + unsigned ActualNumArgs = getNumArgOperands(CI); + if (TypeNumArgs != ActualNumArgs) { errs().changeColor(raw_ostream::YELLOW); errs() << "warning:"; errs().resetColor(); - errs() << " unexpected argument type " << *ActualType << " at index " << utostr(i) << " in call to '" << F->getName() << "', should be " << *TypeType << "\n"; + errs() << " unexpected number of arguments " << utostr(ActualNumArgs) << " in call to '" << F->getName() << "', should be " << utostr(TypeNumArgs) << "\n"; + } + for (unsigned i = 0; i < std::min(TypeNumArgs, ActualNumArgs); i++) { + Type *TypeType = FT->getParamType(i); + Type *ActualType = CI->getOperand(i)->getType(); + if (getFunctionSignatureLetter(TypeType) != getFunctionSignatureLetter(ActualType)) { + errs().changeColor(raw_ostream::YELLOW); + errs() << "warning:"; + errs().resetColor(); + errs() << " unexpected argument type " << *ActualType << " at index " << utostr(i) << " in call to '" << F->getName() << "', should be " << *TypeType << "\n"; + } } } Type *TypeType = FT->getReturnType(); |