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;
|
||||
disableWarnings = false;
|
||||
warningsAsErrors = false;
|
||||
quiet = false;
|
||||
disableLineWrap = false;
|
||||
emitPerfWarnings = true;
|
||||
emitInstrumentation = false;
|
||||
|
||||
3
ispc.h
3
ispc.h
@@ -388,6 +388,9 @@ struct Globals {
|
||||
possible performance pitfalls. */
|
||||
bool emitPerfWarnings;
|
||||
|
||||
/** Indicates whether all printed output should be surpressed. */
|
||||
bool quiet;
|
||||
|
||||
/** Indicates whether calls should be emitted in the program to an
|
||||
externally-defined program instrumentation function. (See the
|
||||
"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
|
||||
printf(" [--pic]\t\t\t\tGenerate position-independent code\n");
|
||||
#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(" [--version]\t\t\t\tPrint ispc version\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"))
|
||||
generatePIC = true;
|
||||
#endif // !ISPC_IS_WINDOWS
|
||||
else if (!strcmp(argv[i], "--quiet"))
|
||||
g->quiet = true;
|
||||
else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
|
||||
lPrintVersion();
|
||||
return 0;
|
||||
|
||||
7
parse.yy
7
parse.yy
@@ -91,7 +91,12 @@ extern int yylex(YYSTYPE *, SourcePos *);
|
||||
|
||||
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 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
|
||||
Error(SourcePos p, const char *fmt, ...) {
|
||||
if (m != NULL) ++m->errorCount;
|
||||
if (g->quiet)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
lPrint("Error", p, fmt, args);
|
||||
if (m != NULL) ++m->errorCount;
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Debug(SourcePos p, const char *fmt, ...) {
|
||||
if (!g->debugPrint)
|
||||
if (!g->debugPrint || g->quiet)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
@@ -287,21 +290,23 @@ Debug(SourcePos p, const char *fmt, ...) {
|
||||
|
||||
void
|
||||
Warning(SourcePos p, const char *fmt, ...) {
|
||||
if (g->disableWarnings)
|
||||
if (g->warningsAsErrors && m != NULL)
|
||||
++m->errorCount;
|
||||
|
||||
if (g->disableWarnings || g->quiet)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
lPrint(g->warningsAsErrors ? "Error" : "Warning", p, fmt, args);
|
||||
if (g->warningsAsErrors && m != NULL)
|
||||
++m->errorCount;
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
va_list args;
|
||||
|
||||
Reference in New Issue
Block a user