diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-14 19:39:12 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-14 19:39:12 -0700 |
commit | 5efd13acf148d17fe64f268b3684545b6888303f (patch) | |
tree | 0c8d5e586bea21ade2e98d2bfb3d7c73a60f6c4b | |
parent | 5c723d474e475707fe994e18d4e59269ce1c1981 (diff) |
prettyWarning utility
-rw-r--r-- | lib/Target/JSBackend/CallHandlers.h | 15 | ||||
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp | 8 |
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h index 266b0596a6..ab4bc2e950 100644 --- a/lib/Target/JSBackend/CallHandlers.h +++ b/lib/Target/JSBackend/CallHandlers.h @@ -49,29 +49,20 @@ DEF_CALL_HANDLER(__default__, { 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"; + prettyWarning() << "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"; + prettyWarning() << "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"; + prettyWarning() << "unexpected return type " << *ActualType << " in call to '" << F->getName() << "', should be " << *TypeType << "\n"; } } } else { diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 44b2f41955..0e0e199c49 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -55,6 +55,14 @@ using namespace llvm; #define assert(x) { if (!(x)) report_fatal_error(#x); } #endif +raw_ostream &prettyWarning() { + errs().changeColor(raw_ostream::YELLOW); + errs() << "warning:"; + errs().resetColor(); + errs() << " "; + return errs(); +} + static cl::opt<bool> PreciseF32("emscripten-precise-f32", cl::desc("Enables Math.fround usage to implement precise float32 semantics and performance (see emscripten PRECISE_F32 option)"), |