aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/ArithmeticHandler.cc8
-rw-r--r--lib/CodeGen/CodeGen.cc7
-rw-r--r--lib/CodeGen/ConstantGen.cc4
-rw-r--r--lib/CodeGen/FunctionGen.cc7
4 files changed, 10 insertions, 16 deletions
diff --git a/lib/CodeGen/ArithmeticHandler.cc b/lib/CodeGen/ArithmeticHandler.cc
index 255da57..480c963 100644
--- a/lib/CodeGen/ArithmeticHandler.cc
+++ b/lib/CodeGen/ArithmeticHandler.cc
@@ -29,7 +29,7 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line)
if (LVal->getType()->isIntegerTy(64)) LVal = Builder.CreateSIToFP(LVal, Type::getDoubleTy(Context));
if (RVal->getType()->isIntegerTy(64)) RVal = Builder.CreateSIToFP(RVal, Type::getDoubleTy(Context));
if (!LVal->getType()->isDoubleTy() || !RVal->getType()->isDoubleTy()) {
- cps::sourceDiagnostic(Line, "error: '/' requires numeric operands (line %d).\n", Line);
+ cps::sourceError(Line, "'/' requires numeric operands");
HadError = true;
return nullptr;
}
@@ -40,7 +40,7 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line)
if (Op == tok_div || Op == tok_mod) {
if (!LIsInt || !RIsInt) {
- cps::sourceDiagnostic(Line, "error: DIV and MOD operators require INTEGER operands (line %d).\n", Line);
+ cps::sourceError(Line, "DIV and MOD operators require INTEGER operands");
HadError = true;
return nullptr;
}
@@ -97,7 +97,7 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line)
R = widenSmallInt(Builder, Context, R);
}
if (L->getType() != R->getType()) {
- cps::sourceDiagnostic(Line, "error: Mismatched operand types for binary operator (line %d).\n", Line);
+ cps::sourceError(Line, "Mismatched operand types for binary operator");
HadError = true;
return nullptr;
}
@@ -115,7 +115,7 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line)
}
}
- cps::sourceDiagnostic(Line, "error: Unsupported operand types for binary operator (line %d).\n", Line);
+ cps::sourceError(Line, "Unsupported operand types for binary operator");
HadError = true;
return nullptr;
}
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc
index fb86120..e184b19 100644
--- a/lib/CodeGen/CodeGen.cc
+++ b/lib/CodeGen/CodeGen.cc
@@ -28,10 +28,7 @@ bool CodeGen::isBuiltinName(const std::string &Name) {
void CodeGen::reportError(const char *Fmt, ...) {
va_list Args;
va_start(Args, Fmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, Fmt, Args);
- if (DiagnosticLine) fprintf(stderr, "%s", lineSuffix(DiagnosticLine).c_str());
- fprintf(stderr, "\n");
+ cps::vsourceDiagnostic(cps::Severity::Error, DiagnosticLine, Fmt, Args);
va_end(Args);
HadError = true;
}
@@ -154,7 +151,7 @@ bool CodeGen::isVisible(size_t Owner) const {
void CodeGen::selectUnit(size_t Unit) {
CurrentUnit = Unit;
- DiagnosticSource = Units->size() > 1 ? (*Units)[Unit].Path : "";
+ DiagnosticSource = (*Units)[Unit].Path;
FuncGen->setCurrentUnit(Unit, (*Units)[Unit].Path);
RuntimeChecker->setLibraryMode((*Units)[Unit].IsLibrary);
FuncGen->setCallHook([this](const FuncSig &Sig) {
diff --git a/lib/CodeGen/ConstantGen.cc b/lib/CodeGen/ConstantGen.cc
index 1ac2a28..ca96834 100644
--- a/lib/CodeGen/ConstantGen.cc
+++ b/lib/CodeGen/ConstantGen.cc
@@ -22,8 +22,8 @@ void CodeGen::warnMemberShadow(const std::string &Name, int Line) const {
const TypeInfo *Class = resolveType(CurrentClass);
const RecordPayload *Record = Class ? Class->asRecord() : nullptr;
if (Record && Record->findField(Name)) {
- cps::sourceDiagnostic(Line, "warning: Declaration of %s shadows a field of class %s at line %d\n",
- Name.c_str(), CurrentClass.c_str(), Line);
+ cps::sourceWarning(Line, "Declaration of %s shadows a field of class %s",
+ Name.c_str(), CurrentClass.c_str());
}
}
diff --git a/lib/CodeGen/FunctionGen.cc b/lib/CodeGen/FunctionGen.cc
index c01b042..628f3ba 100644
--- a/lib/CodeGen/FunctionGen.cc
+++ b/lib/CodeGen/FunctionGen.cc
@@ -30,10 +30,7 @@ bool FunctionGen::isReservedRuntimeName(const std::string &Name) {
void FunctionGen::reportError(const char *Fmt, ...) {
va_list Args;
va_start(Args, Fmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, Fmt, Args);
- if (DiagnosticLine) fprintf(stderr, "%s", lineSuffix(DiagnosticLine).c_str());
- fprintf(stderr, "\n");
+ cps::vsourceDiagnostic(cps::Severity::Error, DiagnosticLine, Fmt, Args);
va_end(Args);
HadError = true;
}
@@ -449,7 +446,7 @@ static Value *GenerateCall(llvm::Module &Module,
bool &HadError, int DiagnosticLine) {
Function *CalleeF = Module.getFunction(CalleeName);
if (!CalleeF) {
- sourceDiagnostic(DiagnosticLine, "error: Call to undefined function %s\n", CalleeName.c_str());
+ sourceError(DiagnosticLine, "Call to undefined function %s", CalleeName.c_str());
HadError = true;
return nullptr;
}