From: Mikko Rasa Date: Mon, 8 Mar 2021 20:14:41 +0000 (+0200) Subject: Sort diagnostics according to their provoking location X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=50a79aee4c53c4198bae38c7ff447133a043aacc;p=libs%2Fgl.git Sort diagnostics according to their provoking location --- diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index e46e5401..9c1238c0 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -293,6 +293,8 @@ bool Compiler::validate(Stage &stage) ReferenceValidator().apply(stage); ExpressionValidator().apply(stage); + stable_sort(stage.diagnostics, &diagnostic_line_order); + for(vector::const_iterator i=stage.diagnostics.begin(); i!=stage.diagnostics.end(); ++i) if(i->severity==Diagnostic::ERR) return false; @@ -300,6 +302,21 @@ bool Compiler::validate(Stage &stage) return true; } +bool Compiler::diagnostic_line_order(const Diagnostic &diag1, const Diagnostic &diag2) +{ + if(diag1.provoking_source!=diag2.provoking_source) + { + // Sort builtins first and imported modules according to import order. + if(diag1.provoking_source<=BUILTIN_SOURCE) + return diag1.provoking_sourcediag2.provoking_source; + } + return diag1.provoking_line