Unify Diagnostics interface

Use the same kind of interface for reporting preprocessor errors as
for reporting regular compiler errors, and make global errors like
having too many uniforms also go through Diagnostics. Also don't
create std::string objects unnecessarily.

Includes cleanups of some dead code related to reporting errors.

BUG=angleproject:1670
TEST=angle_unittests

Change-Id: I3ee794d32ddeec1826bdf1b76b558f35259f82c0
Reviewed-on: https://chromium-review.googlesource.com/421527
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ValidateOutputs.cpp b/src/compiler/translator/ValidateOutputs.cpp
index 33e2e0c..2e0303c 100644
--- a/src/compiler/translator/ValidateOutputs.cpp
+++ b/src/compiler/translator/ValidateOutputs.cpp
@@ -14,12 +14,9 @@
 
 namespace
 {
-void error(int *errorCount, TInfoSinkBase &sink, const TIntermSymbol &symbol, const char *reason)
+void error(const TIntermSymbol &symbol, const char *reason, TDiagnostics *diagnostics)
 {
-    sink.prefix(EPrefixError);
-    sink.location(symbol.getLine());
-    sink << "'" << symbol.getSymbol() << "' : " << reason << "\n";
-    (*errorCount)++;
+    diagnostics->error(symbol.getLine(), reason, symbol.getSymbol().c_str());
 }
 
 }  // namespace
@@ -55,10 +52,10 @@
     }
 }
 
-int ValidateOutputs::validateAndCountErrors(TInfoSinkBase &sink) const
+void ValidateOutputs::validate(TDiagnostics *diagnostics) const
 {
+    ASSERT(diagnostics);
     OutputVector validOutputs(mMaxDrawBuffers);
-    int errorCount = 0;
 
     for (const auto &symbol : mOutputs)
     {
@@ -78,7 +75,7 @@
                     std::stringstream strstr;
                     strstr << "conflicting output locations with previously defined output '"
                            << validOutputs[offsetLocation]->getSymbol() << "'";
-                    error(&errorCount, sink, *symbol, strstr.str().c_str());
+                    error(*symbol, strstr.str().c_str(), diagnostics);
                 }
                 else
                 {
@@ -90,9 +87,10 @@
         {
             if (elementCount > 0)
             {
-                error(&errorCount, sink, *symbol,
+                error(*symbol,
                       elementCount > 1 ? "output array locations would exceed MAX_DRAW_BUFFERS"
-                                       : "output location must be < MAX_DRAW_BUFFERS");
+                                       : "output location must be < MAX_DRAW_BUFFERS",
+                      diagnostics);
             }
         }
     }
@@ -103,11 +101,11 @@
     {
         for (const auto &symbol : mUnspecifiedLocationOutputs)
         {
-            error(&errorCount, sink, *symbol,
-                  "must explicitly specify all locations when using multiple fragment outputs");
+            error(*symbol,
+                  "must explicitly specify all locations when using multiple fragment outputs",
+                  diagnostics);
         }
     }
-    return errorCount;
 }
 
 }  // namespace sh