Remove extraInfo parameter from compiler diagnostic functions
This makes error messages more consistent. It was not clear what was
supposed to go to the extraInfo parameter, and previously it was
mostly being misused, resulting in poorly formatted error messages.
Sometimes the order of parameters to the diagnostic functions like
error() and warning() was wrong altogether. The diagnostics API is
simpler when there's only the "reason" and "token" parameters that
have clear meaning and that are separated by consistent punctuation
in the output.
Fixes error messages like
"redifinition interface block member"
to be grammatically reasonable like the rest of the error messages. For
other error messages, punctuation is added to make them clearer. Example:
"invalid layout qualifier location requires an argument"
is changed to
"invalid layout qualifier: location requires an argument".
Extra spaces are also removed from the beginning of error messages.
BUG=angleproject:1670
BUG=angleproject:911
TEST=angle_unittests
Change-Id: Id5fb1a1f2892fad2b796aaef47ffb07e9d79759c
Reviewed-on: https://chromium-review.googlesource.com/420789
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/DirectiveHandler.cpp b/src/compiler/translator/DirectiveHandler.cpp
index cd2cf6f..d8c1473 100644
--- a/src/compiler/translator/DirectiveHandler.cpp
+++ b/src/compiler/translator/DirectiveHandler.cpp
@@ -52,7 +52,7 @@
void TDirectiveHandler::handleError(const pp::SourceLocation &loc, const std::string &msg)
{
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", "");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "");
}
void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc,
@@ -72,7 +72,7 @@
// ESSL 3.00.4 section 4.6.1
mDiagnostics.writeInfo(
pp::Diagnostics::PP_ERROR, loc,
- "#pragma STDGL invariant(all) can not be used in fragment shader", name, value);
+ "#pragma STDGL invariant(all) can not be used in fragment shader", name);
}
mPragma.stdgl.invariantAll = true;
}
@@ -125,8 +125,8 @@
if (invalidValue)
{
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "invalid pragma value", value,
- "'on' or 'off' expected");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
+ "invalid pragma value - 'on' or 'off' expected", value);
}
}
}
@@ -140,7 +140,7 @@
TBehavior behaviorVal = getBehavior(behavior);
if (behaviorVal == EBhUndefined)
{
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "behavior", name, "invalid");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "behavior invalid", name);
return;
}
@@ -148,13 +148,13 @@
{
if (behaviorVal == EBhRequire)
{
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name,
- "cannot have 'require' behavior");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
+ "extension cannot have 'require' behavior", name);
}
else if (behaviorVal == EBhEnable)
{
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name,
- "cannot have 'enable' behavior");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
+ "extension cannot have 'enable' behavior", name);
}
else
{
@@ -187,7 +187,7 @@
UNREACHABLE();
break;
}
- mDiagnostics.writeInfo(severity, loc, "extension", name, "is not supported");
+ mDiagnostics.writeInfo(severity, loc, "extension is not supported", name);
}
void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version)
@@ -201,8 +201,7 @@
std::stringstream stream;
stream << version;
std::string str = stream.str();
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "version number", str,
- "not supported");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "version number not supported", str);
}
}