aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/JSBackend/CallHandlers.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/JSBackend/CallHandlers.h')
-rw-r--r--lib/Target/JSBackend/CallHandlers.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h
index 9ad89ee169..eefe491d16 100644
--- a/lib/Target/JSBackend/CallHandlers.h
+++ b/lib/Target/JSBackend/CallHandlers.h
@@ -53,7 +53,24 @@ DEF_CALL_HANDLER(__default__, {
errs().resetColor();
errs() << " unexpected number of arguments " << utostr(ActualNumArgs) << " in call to '" << F->getName() << "', should be " << utostr(TypeNumArgs) << "\n";
}
- // TODO: also check types of arguments, but must take into account JS types, not LLVM types
+ 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();
+ Type *ActualType = CI->getType();
+ if (getFunctionSignatureLetter(TypeType) != getFunctionSignatureLetter(ActualType)) {
+ errs().changeColor(raw_ostream::YELLOW);
+ errs() << "warning:";
+ errs().resetColor();
+ errs() << " unexpected return type " << *ActualType << " in call to '" << F->getName() << "', should be " << *TypeType << "\n";
+ }
}
} else {
if (isAbsolute(CV)) return "abort(); /* segfault, call an absolute addr */";