Skip to content

Commit

Permalink
attempt to make error and warning message formatting more consistent
Browse files Browse the repository at this point in the history
- we use ERROR: and WARNING: in util.jl, so might as well use it
  everywhere even though I hate the uppercase

- exception messages (passed to jl_error etc.) should generally
  not use an explicit ERROR: prefix, as that is implied and may
  be added by printing code later

- exception messages should not end with \n (the newline is
  formatting, not part of the message)
  • Loading branch information
JeffBezanson committed Jul 21, 2015
1 parent eb636a0 commit ffe157e
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void jl_init_frontend(void)

if (fl_load_system_image_str((char*)flisp_system_image,
sizeof(flisp_system_image))) {
jl_error("fatal error loading system image\n");
jl_error("fatal error loading system image");
}

fl_applyn(0, symbol_value(symbol("__init_globals")));
Expand Down
6 changes: 3 additions & 3 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void *jl_load_and_lookup(char *f_lib, char *f_name, uv_lib_t **hnd)
*hnd = handle = get_library(f_lib);
void *ptr = jl_dlsym_e(handle, f_name);
if (!ptr)
jl_errorf("symbol could not be found %s: %s\n", f_name, uv_dlerror(handle));
jl_errorf("symbol \"%s\" could not be found: %s", f_name, uv_dlerror(handle));
return ptr;
}

Expand Down Expand Up @@ -588,7 +588,7 @@ static Value *emit_cglobal(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
else if (sym.fptr != NULL) {
res = literal_static_pointer_val(sym.fptr, lrt);
if (imaging_mode)
jl_printf(JL_STDERR,"warning: literal address used in cglobal for %s; code cannot be statically compiled\n", sym.f_name);
jl_printf(JL_STDERR,"WARNING: literal address used in cglobal for %s; code cannot be statically compiled\n", sym.f_name);
}
else {
if (imaging_mode) {
Expand Down Expand Up @@ -1327,7 +1327,7 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
Type *funcptype = PointerType::get(functype,0);
llvmf = literal_static_pointer_val(fptr, funcptype);
if (imaging_mode)
jl_printf(JL_STDERR,"warning: literal address used in ccall for %s; code cannot be statically compiled\n", f_name);
jl_printf(JL_STDERR,"WARNING: literal address used in ccall for %s; code cannot be statically compiled\n", f_name);
}
else {
assert(f_name != NULL);
Expand Down
8 changes: 4 additions & 4 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ void *jl_get_llvmf(jl_function_t *f, jl_tupletype_t *tt, bool getwrapper)
return NULL;
}
jl_printf(JL_STDERR,
"Warning: Returned code may not match what actually runs.\n");
"WARNING: Returned code may not match what actually runs.\n");
}
if (sf->linfo->specFunctionObject != NULL) {
// found in the system image: force a recompile
Expand Down Expand Up @@ -1094,7 +1094,7 @@ const jl_value_t *jl_dump_function_asm(void *f)
jl_dump_asm_internal(fptr, symsize, slide, object, fstream);
}
else {
jl_printf(JL_STDERR, "Warning: Unable to find function pointer\n");
jl_printf(JL_STDERR, "WARNING: Unable to find function pointer\n");
}
fstream.flush();

Expand Down Expand Up @@ -3391,7 +3391,7 @@ static Value *emit_expr(jl_value_t *expr, jl_codectx_t *ctx, bool isboxed, bool
}
else if (head == simdloop_sym) {
if (!llvm::annotateSimdLoop(builder.GetInsertBlock()))
jl_printf(JL_STDERR, "Warning: could not attach metadata for @simd loop.\n");
jl_printf(JL_STDERR, "WARNING: could not attach metadata for @simd loop.\n");
return NULL;
}
else if (head == meta_sym) {
Expand Down Expand Up @@ -5514,7 +5514,7 @@ extern "C" void jl_init_codegen(void)
#endif
std::string TheCPU = strcmp(jl_options.cpu_target,"native") ? jl_options.cpu_target : sys::getHostCPUName();
if (TheCPU.empty() || TheCPU == "generic") {
jl_printf(JL_STDERR, "warning: unable to determine host cpu name.\n");
jl_printf(JL_STDERR, "WARNING: unable to determine host cpu name.\n");
#ifdef _CPU_ARM_
MAttrs.append(1, "+vfp2"); // the processors that don't have VFP are old and (hopefully) rare. this affects the platform calling convention.
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void jl_dump_asm_internal(uintptr_t Fptr, size_t Fsize, size_t slide,
OwningPtr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI));
#endif
if (!DisAsm) {
jl_printf(JL_STDERR, "error: no disassembler for target %s\n",
jl_printf(JL_STDERR, "ERROR: no disassembler for target %s\n",
TripleName.c_str());
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static uv_lib_t *jl_load_dynamic_library_(const char *modname, unsigned flags, i
uv_dlclose(handle);
free(handle);
if (throw_err)
jl_errorf("could not load library '%s'\n%s", modname, path);
jl_errorf("could not load library \"%s\"\n%s", modname, path);
return NULL;

done:
Expand Down Expand Up @@ -216,7 +216,7 @@ void *jl_dlsym(jl_uv_libhandle handle, const char *symbol)
void *ptr;
int error = uv_dlsym((uv_lib_t *) handle, symbol, &ptr);
if (error) {
jl_errorf("could not load symbol '%s'\n%s", symbol, uv_dlerror((uv_lib_t *) handle));
jl_errorf("could not load symbol \"%s\"\n%s", symbol, uv_dlerror((uv_lib_t *) handle));
}
return ptr;
}
Expand Down
26 changes: 13 additions & 13 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,22 @@ static int jl_load_sysimg_so()
const char *cpu_target = (const char*)jl_dlsym(jl_sysimg_handle, "jl_sysimg_cpu_target");
if (strcmp(cpu_target,jl_options.cpu_target) != 0)
jl_error("Julia and the system image were compiled for different architectures.\n"
"Please delete or regenerate sys.{so,dll,dylib}.\n");
"Please delete or regenerate sys.{so,dll,dylib}.");
#ifdef HAVE_CPUID
uint32_t info[4];
jl_cpuid((int32_t*)info, 1);
if (strcmp(cpu_target, "native") == 0) {
if (!RUNNING_ON_VALGRIND) {
uint64_t saved_cpuid = *(uint64_t*)jl_dlsym(jl_sysimg_handle, "jl_sysimg_cpu_cpuid");
if (saved_cpuid != (((uint64_t)info[2])|(((uint64_t)info[3])<<32)))
jl_error("Target architecture mismatch. Please delete or regenerate sys.{so,dll,dylib}.\n");
jl_error("Target architecture mismatch. Please delete or regenerate sys.{so,dll,dylib}.");
}
}
else if (strcmp(cpu_target,"core2") == 0) {
int HasSSSE3 = (info[2] & 1<<9);
if (!HasSSSE3)
jl_error("The current host does not support SSSE3, but the system image was compiled for Core2.\n"
"Please delete or regenerate sys.{so,dll,dylib}.\n");
"Please delete or regenerate sys.{so,dll,dylib}.");
}
#endif

Expand Down Expand Up @@ -1481,7 +1481,7 @@ void jl_deserialize_lambdas_from_mod(ios_t *s)
int jl_deserialize_verify_mod_list(ios_t *s)
{
if (!jl_main_module->uuid) {
jl_printf(JL_STDERR, "error: Main module uuid state is invalid for module deserialization.\n");
jl_printf(JL_STDERR, "ERROR: Main module uuid state is invalid for module deserialization.\n");
return 0;
}
while (1) {
Expand All @@ -1508,15 +1508,15 @@ int jl_deserialize_verify_mod_list(ios_t *s)
m = (jl_module_t*)jl_get_global(jl_main_module, sym);
}
if (!m) {
jl_printf(JL_STDERR, "error: requiring \"%s\" did not define a corresponding module\n", name);
jl_printf(JL_STDERR, "ERROR: requiring \"%s\" did not define a corresponding module\n", name);
return 0;
}
if (!jl_is_module(m)) {
ios_close(s);
jl_errorf("invalid module path (%s does not name a module)", name);
}
if (m->uuid != uuid) {
jl_printf(JL_STDERR, "warning: Module %s uuid did not match cache file\n", name);
jl_printf(JL_STDERR, "WARNING: Module %s uuid did not match cache file\n", name);
return 0;
}
}
Expand Down Expand Up @@ -1564,9 +1564,9 @@ static void jl_reinit_item(ios_t *f, jl_value_t *v, int how) {
jl_errorf("invalid redefinition of constant %s", mod->name->name); // this also throws
}
if (jl_generating_output() && jl_options.incremental) {
jl_errorf("error: cannot replace module %s during incremental compile", mod->name->name);
jl_errorf("cannot replace module %s during incremental compile", mod->name->name);
}
jl_printf(JL_STDERR, "Warning: replacing module %s\n", mod->name->name);
jl_printf(JL_STDERR, "WARNING: replacing module %s\n", mod->name->name);
}
b->value = v;
jl_gc_wb_binding(b, v);
Expand All @@ -1577,7 +1577,7 @@ static void jl_reinit_item(ios_t *f, jl_value_t *v, int how) {
}
}
JL_CATCH {
jl_printf(JL_STDERR, "Warning: error reinitializing value ");
jl_printf(JL_STDERR, "WARNING: error while reinitializing value ");
jl_static_show(JL_STDERR, v);
jl_printf(JL_STDERR, ":\n");
jl_static_show(JL_STDERR, jl_exception_in_transit);
Expand Down Expand Up @@ -1657,7 +1657,7 @@ DLLEXPORT void jl_save_system_image(const char *fname)
{
ios_t f;
if (ios_file(&f, fname, 1, 1, 1, 1) == NULL) {
jl_errorf("Cannot open system image file \"%s\" for writing.\n", fname);
jl_errorf("cannot open system image file \"%s\" for writing", fname);
}
JL_SIGATOMIC_BEGIN();
jl_save_system_image_to_stream(&f);
Expand Down Expand Up @@ -1771,14 +1771,14 @@ DLLEXPORT void jl_restore_system_image(const char *fname)
int err = jl_load_sysimg_so();
if (err != 0) {
if (jl_sysimg_handle == 0)
jl_errorf("System image file \"%s\" not found\n", fname);
jl_errorf("Library \"%s\" does not contain a valid system image\n", fname);
jl_errorf("system image file \"%s\" not found", fname);
jl_errorf("library \"%s\" does not contain a valid system image", fname);
}
}
else {
ios_t f;
if (ios_file(&f, fname, 1, 0, 0, 0) == NULL)
jl_errorf("System image file \"%s\" not found\n", fname);
jl_errorf("system image file \"%s\" not found", fname);
JL_SIGATOMIC_BEGIN();
jl_restore_system_image_from_stream(&f);
ios_close(&f);
Expand Down
4 changes: 2 additions & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ static void check_ambiguous(jl_methlist_t *ml, jl_tupletype_t *type,
}
n = fname->name;
s = JL_STDERR;
jl_printf(s, "Warning: New definition \n %s", n);
jl_printf(s, "WARNING: New definition \n %s", n);
jl_static_show_func_sig(s, (jl_value_t*)type);
print_func_loc(s, linfo);
jl_printf(s, "\nis ambiguous with: \n %s", n);
Expand Down Expand Up @@ -1173,7 +1173,7 @@ jl_methlist_t *jl_method_list_insert(jl_methlist_t **pml, jl_tupletype_t *type,
(l->func->linfo->module != method->linfo->module)) {
jl_module_t *newmod = method->linfo->module;
JL_STREAM *s = JL_STDERR;
jl_printf(s, "Warning: Method definition %s", method->linfo->name->name);
jl_printf(s, "WARNING: Method definition %s", method->linfo->name->name);
jl_static_show_func_sig(s, (jl_value_t*)type);
jl_printf(s, " in module %s", l->func->linfo->module->name->name);
print_func_loc(s, l->func->linfo);
Expand Down
Loading

0 comments on commit ffe157e

Please sign in to comment.