Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/include/dmd/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ enum class MessageStyle : unsigned char
{
digitalmars, // file(line,column): message
gnu, // file:line:column: message
sarif // JSON SARIF output, see https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html
sarif, // JSON SARIF output, see https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html
diagreport // diagnostics reporting messagestyle
};

// The state of array bounds checking
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ auto sourceFiles()
glue/s2ir.d glue/tocsym.d glue/toctype.d glue/tocvdebug.d glue/todt.d glue/toir.d glue/toobj.d
"),
driver: fileArray(env["D"], "dinifile.d dmdparams.d lib/package.d lib/elf.d lib/mach.d lib/mscoff.d
link.d mars.d main.d sarif.d lib/scanelf.d lib/scanmach.d lib/scanmscoff.d timetrace.d vsoptions.d
link.d mars.d main.d sarif.d diagreport/glue.d lib/scanelf.d lib/scanmach.d lib/scanmscoff.d timetrace.d vsoptions.d
"),
frontend: fileArray(env["D"], "
access.d aggregate.d aliasthis.d argtypes_x86.d argtypes_sysv_x64.d argtypes_aarch64.d arrayop.d
Expand All @@ -1592,6 +1592,7 @@ auto sourceFiles()
visitor/strict.d visitor/transitive.d
cparse.d
dfa/entry.d dfa/utils.d dfa/fast/structure.d dfa/fast/analysis.d dfa/fast/report.d dfa/fast/expression.d dfa/fast/statement.d
diagreport/defs.d diagreport/geometry.d diagreport/renderer.d
"),
backendHeaders: fileArray(env["C"], "
cc.d cdef.d cgcv.d code.d dt.d el.d global.d
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dmd/cli.d
Original file line number Diff line number Diff line change
Expand Up @@ -935,14 +935,15 @@ dmd -cov -unittest myprog.d
Option("vcolumns",
"print character (column) numbers in diagnostics"
),
Option("verror-style=[digitalmars|gnu|sarif]",
Option("verror-style=[digitalmars|gnu|sarif|diagreport]",
"set the style for file/line number annotations on compiler messages",
`Set the style for file/line number annotations on compiler messages,
where:
$(DL
$(DT digitalmars)$(DD 'file(line[,column]): message'. This is the default.)
$(DT gnu)$(DD 'file:line[:column]: message', conforming to the GNU standard used by gcc and clang.)
$(DT sarif)$(DD 'Generates JSON output conforming to the SARIF (Static Analysis Results Interchange Format) standard, useful for integration with tools like GitHub and other SARIF readers.')
$(DT diagreport)$(DD 'Generates diagnostic report of errors, warnings, deprecations and tips.')
)`,
),
Option("verror-supplements=<num>",
Expand Down
59 changes: 59 additions & 0 deletions compiler/src/dmd/diagreport/defs.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
Defines the vertical state of a diagnostic on a given line for drawing purposes.
This enumeration captures the vertical state machine logic for a single diagnostic span.
*/
module dmd.diagreport.defs;

enum LineClassification
{
/// The line is not part of the diagnostic span.
Inactive,
/// The line is the start of the span and continues below. Implies the previous line was Inactive.
SpanStart,
/// The line is between the start and end. Implies the previous line and next line are Active.
SpanContinue,
/// The line is the end of the span and no other active diagnostics follow it. Implies the next line is Inactive.
SpanEnd,
/// The span starts and ends on the same line (a one-line diagnostic).
SpanStartEnd
}

struct Diagnostic
{
/// The line number where the diagnostic span begins (inclusive).
int start;
/// The line number where the diagnostic span ends (inclusive).
int end;

Message startMessage;
Message endMessage;

size_t id;

size_t offset()
{
return originalOffset;
}

package:
size_t originalOffset;
int column;
}

struct Message
{
int startColumn, endColumn;
bool isMultiline;

size_t id;
}

struct Help
{
Diagnostic[] diagnostics;

Message startMessage;
Message endMessage;

size_t id;
}
Loading
Loading