Add --quiet option to supress all diagnostic output
This commit is contained in:
1
ispc.cpp
1
ispc.cpp
@@ -510,6 +510,7 @@ Globals::Globals() {
|
|||||||
debugPrint = false;
|
debugPrint = false;
|
||||||
disableWarnings = false;
|
disableWarnings = false;
|
||||||
warningsAsErrors = false;
|
warningsAsErrors = false;
|
||||||
|
quiet = false;
|
||||||
disableLineWrap = false;
|
disableLineWrap = false;
|
||||||
emitPerfWarnings = true;
|
emitPerfWarnings = true;
|
||||||
emitInstrumentation = false;
|
emitInstrumentation = false;
|
||||||
|
|||||||
3
ispc.h
3
ispc.h
@@ -388,6 +388,9 @@ struct Globals {
|
|||||||
possible performance pitfalls. */
|
possible performance pitfalls. */
|
||||||
bool emitPerfWarnings;
|
bool emitPerfWarnings;
|
||||||
|
|
||||||
|
/** Indicates whether all printed output should be surpressed. */
|
||||||
|
bool quiet;
|
||||||
|
|
||||||
/** Indicates whether calls should be emitted in the program to an
|
/** Indicates whether calls should be emitted in the program to an
|
||||||
externally-defined program instrumentation function. (See the
|
externally-defined program instrumentation function. (See the
|
||||||
"Instrumenting your ispc programs" section in the user's
|
"Instrumenting your ispc programs" section in the user's
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@@ -129,6 +129,7 @@ usage(int ret) {
|
|||||||
#ifndef ISPC_IS_WINDOWS
|
#ifndef ISPC_IS_WINDOWS
|
||||||
printf(" [--pic]\t\t\t\tGenerate position-independent code\n");
|
printf(" [--pic]\t\t\t\tGenerate position-independent code\n");
|
||||||
#endif // !ISPC_IS_WINDOWS
|
#endif // !ISPC_IS_WINDOWS
|
||||||
|
printf(" [--quiet]\t\t\t\tSuppress all output\n");
|
||||||
printf(" [--target=<isa>]\t\t\tSelect target ISA. <isa>={%s}\n", Target::SupportedTargetISAs());
|
printf(" [--target=<isa>]\t\t\tSelect target ISA. <isa>={%s}\n", Target::SupportedTargetISAs());
|
||||||
printf(" [--version]\t\t\t\tPrint ispc version\n");
|
printf(" [--version]\t\t\t\tPrint ispc version\n");
|
||||||
printf(" [--werror]\t\t\t\tTreat warnings as errors\n");
|
printf(" [--werror]\t\t\t\tTreat warnings as errors\n");
|
||||||
@@ -383,6 +384,8 @@ int main(int Argc, char *Argv[]) {
|
|||||||
else if (!strcmp(argv[i], "--pic"))
|
else if (!strcmp(argv[i], "--pic"))
|
||||||
generatePIC = true;
|
generatePIC = true;
|
||||||
#endif // !ISPC_IS_WINDOWS
|
#endif // !ISPC_IS_WINDOWS
|
||||||
|
else if (!strcmp(argv[i], "--quiet"))
|
||||||
|
g->quiet = true;
|
||||||
else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
|
else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
|
||||||
lPrintVersion();
|
lPrintVersion();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
7
parse.yy
7
parse.yy
@@ -91,7 +91,12 @@ extern int yylex(YYSTYPE *, SourcePos *);
|
|||||||
|
|
||||||
extern char *yytext;
|
extern char *yytext;
|
||||||
|
|
||||||
void yyerror(const char *s) { fprintf(stderr, "Parse error: %s\n", s); }
|
void yyerror(const char *s) {
|
||||||
|
if (!g->quiet) {
|
||||||
|
++m->errorCount;
|
||||||
|
fprintf(stderr, "Parse error: %s\n", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void lAddDeclaration(DeclSpecs *ds, Declarator *decl);
|
static void lAddDeclaration(DeclSpecs *ds, Declarator *decl);
|
||||||
static void lAddFunctionParams(Declarator *decl);
|
static void lAddFunctionParams(Declarator *decl);
|
||||||
|
|||||||
17
util.cpp
17
util.cpp
@@ -265,17 +265,20 @@ lPrint(const char *type, SourcePos p, const char *fmt, va_list args) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Error(SourcePos p, const char *fmt, ...) {
|
Error(SourcePos p, const char *fmt, ...) {
|
||||||
|
if (m != NULL) ++m->errorCount;
|
||||||
|
if (g->quiet)
|
||||||
|
return;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
lPrint("Error", p, fmt, args);
|
lPrint("Error", p, fmt, args);
|
||||||
if (m != NULL) ++m->errorCount;
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Debug(SourcePos p, const char *fmt, ...) {
|
Debug(SourcePos p, const char *fmt, ...) {
|
||||||
if (!g->debugPrint)
|
if (!g->debugPrint || g->quiet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -287,21 +290,23 @@ Debug(SourcePos p, const char *fmt, ...) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Warning(SourcePos p, const char *fmt, ...) {
|
Warning(SourcePos p, const char *fmt, ...) {
|
||||||
if (g->disableWarnings)
|
if (g->warningsAsErrors && m != NULL)
|
||||||
|
++m->errorCount;
|
||||||
|
|
||||||
|
if (g->disableWarnings || g->quiet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
lPrint(g->warningsAsErrors ? "Error" : "Warning", p, fmt, args);
|
lPrint(g->warningsAsErrors ? "Error" : "Warning", p, fmt, args);
|
||||||
if (g->warningsAsErrors && m != NULL)
|
|
||||||
++m->errorCount;
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PerformanceWarning(SourcePos p, const char *fmt, ...) {
|
PerformanceWarning(SourcePos p, const char *fmt, ...) {
|
||||||
if (!g->emitPerfWarnings || strcmp(p.name, "stdlib.ispc") == 0)
|
if (!g->emitPerfWarnings || strcmp(p.name, "stdlib.ispc") == 0 ||
|
||||||
|
g->quiet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|||||||
Reference in New Issue
Block a user