Add error and warning helpers to Diagnostics
This will make it easier to generate errors and warnings with a
consistent format outside of ParseContext, for example in
TIntermBinary::fold() which warns about division by zero.
BUG=angleproject:952
TEST=angle_unittests
Change-Id: I25999d7bdc77efafe77785a0d6f4d63417dfaab9
Reviewed-on: https://chromium-review.googlesource.com/372719
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 1c0a871..5a79d2a 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -141,10 +141,7 @@
const char *token,
const char *extraInfo)
{
- pp::SourceLocation srcLoc;
- srcLoc.file = loc.first_file;
- srcLoc.line = loc.first_line;
- mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, srcLoc, reason, token, extraInfo);
+ mDiagnostics.error(loc, reason, token, extraInfo);
}
void TParseContext::warning(const TSourceLoc &loc,
@@ -152,10 +149,7 @@
const char *token,
const char *extraInfo)
{
- pp::SourceLocation srcLoc;
- srcLoc.file = loc.first_file;
- srcLoc.line = loc.first_line;
- mDiagnostics.writeInfo(pp::Diagnostics::PP_WARNING, srcLoc, reason, token, extraInfo);
+ mDiagnostics.warning(loc, reason, token, extraInfo);
}
void TParseContext::outOfRangeError(bool isError,