From b289b6a6dc5173a6c363c61b65fe9c840680a1fe Mon Sep 17 00:00:00 2001 From: Dennis Date: Sun, 26 Jan 2025 14:06:14 +0100 Subject: [PATCH] Refactor use of Loc/SourceLoc (#20785) --- compiler/src/dmd/doc.d | 14 +++---- compiler/src/dmd/errors.d | 8 +--- compiler/src/dmd/expressionsem.d | 2 +- compiler/src/dmd/frontend.d | 26 ++++++------- compiler/src/dmd/iasmdmd.d | 8 +++- compiler/src/dmd/json.d | 19 +++++----- compiler/src/dmd/location.d | 38 ++++++++++++++++--- compiler/src/dmd/parse.d | 2 +- compiler/src/dmd/s2ir.d | 3 +- compiler/src/dmd/tocsym.d | 3 +- compiler/test/dub_package/retrieve_scope.d | 2 +- compiler/test/unit/frontend.d | 6 +-- .../interfaces/check_implementations_20861.d | 8 ++-- .../test/unit/lexer/diagnostic_reporter.d | 2 +- compiler/test/unit/lexer/lexer_dmdlib.d | 2 +- .../unit/objc/protocols/diagnostic_messages.d | 4 +- .../unit/objc/protocols/optional_methods.d | 12 +++--- .../test/unit/parser/diagnostic_reporter.d | 6 +-- compiler/test/unit/support.d | 16 ++++---- 19 files changed, 101 insertions(+), 80 deletions(-) diff --git a/compiler/src/dmd/doc.d b/compiler/src/dmd/doc.d index eba8dddaf988..58f581253969 100644 --- a/compiler/src/dmd/doc.d +++ b/compiler/src/dmd/doc.d @@ -433,10 +433,7 @@ void gendocfile(Module m, const char[] ddoctext, const char* datetime, ErrorSink OutBuffer buf; if (m.filetype == FileType.ddoc) { - const ploc = m.md ? &m.md.loc : &m.loc; - Loc loc = *ploc; - if (!loc.filename) - loc.filename = srcfilename.ptr; + Loc loc = m.md ? m.md.loc : m.loc; size_t commentlen = m.comment ? strlen(cast(char*)m.comment) : 0; Dsymbols a; @@ -3603,7 +3600,7 @@ struct MarkdownLinkReferences auto id = Identifier.lookup(ids[0].ptr, ids[0].length); if (id) { - auto loc = Loc(); + auto loc = Loc.initial; Dsymbol pscopesym; auto symbol = _scope.search(loc, id, pscopesym, SearchOpt.ignoreErrors); for (size_t i = 1; symbol && i < ids.length; ++i) @@ -4096,9 +4093,8 @@ size_t endRowAndTable(ref OutBuffer buf, size_t iStart, size_t iEnd, ref Markdow */ void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, size_t offset) { - const incrementLoc = loc.linnum == 0 ? 1 : 0; - loc.linnum = loc.linnum + incrementLoc; - loc.charnum = 0; + loc.nextLine(); + //printf("highlightText()\n"); bool leadingBlank = true; size_t iParagraphStart = offset; @@ -4202,7 +4198,7 @@ void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, size_t of lineQuoted = false; tableRowDetected = false; iLineStart = i + 1; - loc.linnum = loc.linnum + incrementLoc; + loc.nextLine(); // update the paragraph start if we just entered a macro if (previousMacroLevel < macroLevel && iParagraphStart < iLineStart) diff --git a/compiler/src/dmd/errors.d b/compiler/src/dmd/errors.d index 16cba8b3ec21..f9dd1367452b 100644 --- a/compiler/src/dmd/errors.d +++ b/compiler/src/dmd/errors.d @@ -397,7 +397,7 @@ else * see verrorReport for arguments * Returns: true if error handling is done, false to continue printing to stderr */ -alias DiagnosticHandler = bool delegate(const ref Loc location, Color headerColor, const(char)* header, const(char)* messageFormat, va_list args, const(char)* prefix1, const(char)* prefix2); +alias DiagnosticHandler = bool delegate(const ref SourceLoc location, Color headerColor, const(char)* header, const(char)* messageFormat, va_list args, const(char)* prefix1, const(char)* prefix2); /** * The diagnostic handler. @@ -671,11 +671,7 @@ private void verrorPrint(const(char)* format, va_list ap, ref ErrorInfo info) if (diagnosticHandler !is null) { - Loc diagLoc; - diagLoc.linnum = info.loc.line; - diagLoc.charnum = info.loc.charnum; - diagLoc.filename = (info.loc.filename ~ '\0').ptr; - if (diagnosticHandler(diagLoc, info.headerColor, header, format, ap, info.p1, info.p2)) + if (diagnosticHandler(info.loc, info.headerColor, header, format, ap, info.p1, info.p2)) return; } diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index fcb47a539844..1cf7840d7ad5 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -2346,7 +2346,7 @@ private bool checkNogc(FuncDeclaration f, ref Loc loc, Scope* sc) if (isRootTraitsCompilesScope(sc) ? !sc.func.isNogcBypassingInference() : !sc.func.setGCCall(f)) return false; - if (loc.linnum == 0) // e.g. implicitly generated dtor + if (loc == Loc.initial) // e.g. implicitly generated dtor loc = sc.func.loc; // Lowered non-@nogc'd hooks will print their own error message inside of nogc.d (NOGCVisitor.visit(CallExp e)), diff --git a/compiler/src/dmd/frontend.d b/compiler/src/dmd/frontend.d index 7943e1829865..6ae70bba2063 100644 --- a/compiler/src/dmd/frontend.d +++ b/compiler/src/dmd/frontend.d @@ -487,7 +487,7 @@ nothrow: diagnosticHandler = prevHandler; } - bool diagHandler(const ref Loc loc, Color headerColor, const(char)* header, + bool diagHandler(const ref SourceLoc loc, Color headerColor, const(char)* header, const(char)* format, va_list ap, const(char)* p1, const(char)* p2) { import core.stdc.string; @@ -529,7 +529,7 @@ nothrow: Returns: false if the message should also be printed to stderr, true otherwise */ - abstract bool error(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); + abstract bool error(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); /** Reports additional details about an error message. @@ -543,7 +543,7 @@ nothrow: Returns: false if the message should also be printed to stderr, true otherwise */ - abstract bool errorSupplemental(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); + abstract bool errorSupplemental(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); /** Reports a warning message. @@ -557,7 +557,7 @@ nothrow: Returns: false if the message should also be printed to stderr, true otherwise */ - abstract bool warning(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); + abstract bool warning(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); /** Reports additional details about a warning message. @@ -571,7 +571,7 @@ nothrow: Returns: false if the message should also be printed to stderr, true otherwise */ - abstract bool warningSupplemental(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); + abstract bool warningSupplemental(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); /** Reports a deprecation message. @@ -585,7 +585,7 @@ nothrow: Returns: false if the message should also be printed to stderr, true otherwise */ - abstract bool deprecation(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); + abstract bool deprecation(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); /** Reports additional details about a deprecation message. @@ -599,7 +599,7 @@ nothrow: Returns: false if the message should also be printed to stderr, true otherwise */ - abstract bool deprecationSupplemental(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); + abstract bool deprecationSupplemental(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2); } /** @@ -644,29 +644,29 @@ nothrow: return deprecationCount_; } - override bool error(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) + override bool error(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) { errorCount_++; return false; } - override bool errorSupplemental(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) + override bool errorSupplemental(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) { return false; } - override bool warning(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) + override bool warning(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) { warningCount_++; return false; } - override bool warningSupplemental(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) + override bool warningSupplemental(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) { return false; } - override bool deprecation(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) + override bool deprecation(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) { if (useDeprecated == DiagnosticReporting.error) errorCount_++; @@ -675,7 +675,7 @@ nothrow: return false; } - override bool deprecationSupplemental(const ref Loc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) + override bool deprecationSupplemental(const ref SourceLoc loc, const(char)* format, va_list args, const(char)* p1, const(char)* p2) { return false; } diff --git a/compiler/src/dmd/iasmdmd.d b/compiler/src/dmd/iasmdmd.d index 3d5c2590f89a..123c8ac48a2d 100644 --- a/compiler/src/dmd/iasmdmd.d +++ b/compiler/src/dmd/iasmdmd.d @@ -1436,7 +1436,8 @@ code *asm_emit(Loc loc, if (driverParams.symdebug) { - cdb.genlinnum(Srcpos.create(loc.filename, loc.linnum, loc.charnum)); + SourceLoc sl = SourceLoc(loc); + cdb.genlinnum(Srcpos.create(sl.filename.ptr, sl.linnum, sl.charnum)); } cdb.append(pc); @@ -3682,7 +3683,10 @@ code *asm_db_parse(OP *pop) CodeBuilder cdb; cdb.ctor(); if (driverParams.symdebug) - cdb.genlinnum(Srcpos.create(asmstate.loc.filename, asmstate.loc.linnum, asmstate.loc.charnum)); + { + SourceLoc sl = SourceLoc(asmstate.loc); + cdb.genlinnum(Srcpos.create(sl.filename.ptr, sl.linnum, sl.charnum)); + } cdb.genasm(bytes.peekSlice()); code *c = cdb.finish(); diff --git a/compiler/src/dmd/json.d b/compiler/src/dmd/json.d index 37f8cfdbeac9..25b081249e51 100644 --- a/compiler/src/dmd/json.d +++ b/compiler/src/dmd/json.d @@ -351,19 +351,18 @@ public: { if (loc.isValid()) { - if (auto filename = loc.filename.toDString) + SourceLoc sl = SourceLoc(loc); + if (sl.filename.length > 0 && sl.filename != this.filename) { - if (filename != this.filename) - { - this.filename = filename; - property("file", filename); - } + this.filename = sl.filename; + property("file", sl.filename); } - if (loc.linnum) + + if (sl.linnum) { - property(linename, loc.linnum); - if (loc.charnum) - property(charname, loc.charnum); + property(linename, sl.linnum); + if (sl.charnum) + property(charname, sl.charnum); } } } diff --git a/compiler/src/dmd/location.d b/compiler/src/dmd/location.d index 078706859101..75cd068a1de7 100644 --- a/compiler/src/dmd/location.d +++ b/compiler/src/dmd/location.d @@ -96,6 +96,16 @@ nothrow: return _linnum = num; } + /// Advance this location to the first column of the next line + void nextLine() + { + if (this._linnum) + { + this._linnum++; + this.charnum = 0; + } + } + /*** * Returns: filename for this location, null if none */ @@ -126,9 +136,7 @@ nothrow: bool showColumns = Loc.showColumns, MessageStyle messageStyle = Loc.messageStyle) const nothrow { - OutBuffer buf; - writeSourceLoc(buf, SourceLoc(this), showColumns, messageStyle); - return buf.extractChars(); + return SourceLoc(this).toChars(showColumns, messageStyle); } /** @@ -140,9 +148,11 @@ nothrow: */ extern (C++) bool equals(ref const(Loc) loc) const { - return (!showColumns || charnum == loc.charnum) && - linnum == loc.linnum && - FileName.equals(filename, loc.filename); + SourceLoc lhs = SourceLoc(this); + SourceLoc rhs = SourceLoc(loc); + return (!showColumns || lhs.column == rhs.column) && + lhs.line == rhs.line && + FileName.equals(lhs.filename, rhs.filename); } /** @@ -198,6 +208,8 @@ void writeSourceLoc(ref OutBuffer buf, bool showColumns, MessageStyle messageStyle) nothrow { + if (loc.filename.length == 0) + return; buf.writestring(loc.filename); if (loc.line == 0) return; @@ -258,4 +270,18 @@ struct SourceLoc this.line = loc.linnum; this.column = loc.charnum; } + + extern (C++) const(char)* toChars( + bool showColumns = Loc.showColumns, + MessageStyle messageStyle = Loc.messageStyle) const nothrow + { + OutBuffer buf; + writeSourceLoc(buf, this, showColumns, messageStyle); + return buf.extractChars(); + } + + bool opEquals(SourceLoc other) const nothrow + { + return this.filename == other.filename && this.line == other.line && this.column == other.column; + } } diff --git a/compiler/src/dmd/parse.d b/compiler/src/dmd/parse.d index 2e29762d010c..f17ee1c757c0 100644 --- a/compiler/src/dmd/parse.d +++ b/compiler/src/dmd/parse.d @@ -5379,7 +5379,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer */ private void checkDanglingElse(Loc elseloc) { - if (token.value != TOK.else_ && token.value != TOK.catch_ && token.value != TOK.finally_ && lookingForElse.linnum != 0) + if (token.value != TOK.else_ && token.value != TOK.catch_ && token.value != TOK.finally_ && lookingForElse.isValid) { eSink.warning(elseloc, "else is dangling, add { } after condition at %s", lookingForElse.toChars()); } diff --git a/compiler/src/dmd/s2ir.d b/compiler/src/dmd/s2ir.d index 65c8e9442b70..faa393c4bd53 100644 --- a/compiler/src/dmd/s2ir.d +++ b/compiler/src/dmd/s2ir.d @@ -1715,7 +1715,8 @@ private void block_setLoc(block *b, const ref Loc loc) nothrow private void srcpos_setLoc(ref Srcpos s, const ref Loc loc) nothrow { - s.set(loc.filename, loc.linnum, loc.charnum); + SourceLoc sl = SourceLoc(loc); + s.set(sl.filename.ptr, sl.line, sl.column); } private bool isAssertFalse(const Expression e) nothrow diff --git a/compiler/src/dmd/tocsym.d b/compiler/src/dmd/tocsym.d index 04865f362832..0df12d4a8074 100644 --- a/compiler/src/dmd/tocsym.d +++ b/compiler/src/dmd/tocsym.d @@ -882,5 +882,6 @@ Symbol *toSymbol(Type t) */ Srcpos toSrcpos(Loc loc) { - return Srcpos.create(loc.filename, loc.linnum, loc.charnum); + SourceLoc sl = SourceLoc(loc); + return Srcpos.create(sl.filename.ptr, sl.line, sl.column); } diff --git a/compiler/test/dub_package/retrieve_scope.d b/compiler/test/dub_package/retrieve_scope.d index 05dd643e06be..8eb1decd42c8 100755 --- a/compiler/test/dub_package/retrieve_scope.d +++ b/compiler/test/dub_package/retrieve_scope.d @@ -67,7 +67,7 @@ int main() global.path.push((dmdParentDir ~ "/druntime/import" ~ '\0').ptr); // comment for error output in parsing & semantic - diagnosticHandler = (const ref Loc location, + diagnosticHandler = (const ref SourceLoc location, Color headerColor, const(char)* header, const(char)* messageFormat, diff --git a/compiler/test/unit/frontend.d b/compiler/test/unit/frontend.d index c970e5aa8f30..c5837ee33948 100644 --- a/compiler/test/unit/frontend.d +++ b/compiler/test/unit/frontend.d @@ -115,7 +115,7 @@ unittest string[] diagnosticMessages; - nothrow bool diagnosticHandler(const ref Loc loc, Color headerColor, const(char)* header, + nothrow bool diagnosticHandler(const ref SourceLoc loc, Color headerColor, const(char)* header, const(char)* format, va_list ap, const(char)* p1, const(char)* p2) { OutBuffer tmp; @@ -251,7 +251,7 @@ unittest string[] diagnosticMessages; - nothrow bool diagnosticHandler(const ref Loc loc, Color headerColor, const(char)* header, + nothrow bool diagnosticHandler(const ref SourceLoc loc, Color headerColor, const(char)* header, const(char)* format, va_list ap, const(char)* p1, const(char)* p2) { OutBuffer tmp; @@ -368,7 +368,7 @@ unittest string[] diagnosticMessages; - nothrow bool diagnosticHandler(const ref Loc loc, Color headerColor, const(char)* header, + nothrow bool diagnosticHandler(const ref SourceLoc loc, Color headerColor, const(char)* header, const(char)* format, va_list ap, const(char)* p1, const(char)* p2) { OutBuffer tmp; diff --git a/compiler/test/unit/interfaces/check_implementations_20861.d b/compiler/test/unit/interfaces/check_implementations_20861.d index 269fab36a955..2292938512c7 100644 --- a/compiler/test/unit/interfaces/check_implementations_20861.d +++ b/compiler/test/unit/interfaces/check_implementations_20861.d @@ -45,7 +45,7 @@ import support : afterEach, beforeEach, compiles, stripDelimited, Diagnostic; }.stripDelimited; enum message = "Error: class test.Bar interface function void foo() is not implemented"; - const expected = Diagnostic(Loc(filename, 6, 1), message); + const expected = Diagnostic(SourceLoc(filename, 6, 1), message); const diagnostics = compiles(code, filename); assert(diagnostics == [expected], "\n" ~ diagnostics.toString); @@ -67,7 +67,7 @@ import support : afterEach, beforeEach, compiles, stripDelimited, Diagnostic; }.stripDelimited; enum message = "Error: class test.Bar interface function void foo() is not implemented"; - const expected = Diagnostic(Loc(filename, 6, 1), message); + const expected = Diagnostic(SourceLoc(filename, 6, 1), message); const diagnostics = compiles(code, filename); assert(diagnostics == [expected], "\n" ~ diagnostics.toString); @@ -94,7 +94,7 @@ import support : afterEach, beforeEach, compiles, stripDelimited, Diagnostic; }.stripDelimited; enum message = "Error: class test.Bar interface function void foo() is not implemented"; - const expected = Diagnostic(Loc(filename, 11, 1), message); + const expected = Diagnostic(SourceLoc(filename, 11, 1), message); const diagnostics = compiles(code, filename); assert(diagnostics == [expected], "\n" ~ diagnostics.toString); @@ -123,7 +123,7 @@ import support : afterEach, beforeEach, compiles, stripDelimited, Diagnostic; }.stripDelimited; enum message = "Error: class test.B interface function void foo() is not implemented"; - const expected = Diagnostic(Loc(filename, 11, 1), message); + const expected = Diagnostic(SourceLoc(filename, 11, 1), message); const diagnostics = compiles(code, filename); assert(diagnostics == [expected], "\n" ~ diagnostics.toString); diff --git a/compiler/test/unit/lexer/diagnostic_reporter.d b/compiler/test/unit/lexer/diagnostic_reporter.d index 00ac59af6e15..df4fed8bd764 100644 --- a/compiler/test/unit/lexer/diagnostic_reporter.d +++ b/compiler/test/unit/lexer/diagnostic_reporter.d @@ -23,7 +23,7 @@ unittest { int errorCount; - override bool error(const ref Loc, const(char)*, va_list, const(char)*, const(char)*) + override bool error(const ref SourceLoc, const(char)*, va_list, const(char)*, const(char)*) { errorCount++; return true; diff --git a/compiler/test/unit/lexer/lexer_dmdlib.d b/compiler/test/unit/lexer/lexer_dmdlib.d index ea7ebb4ab824..41dd490e12ba 100644 --- a/compiler/test/unit/lexer/lexer_dmdlib.d +++ b/compiler/test/unit/lexer/lexer_dmdlib.d @@ -245,7 +245,7 @@ unittest import dmd.errors; const(char)[][2][] diagnosticMessages; - nothrow bool diagnosticHandler(const ref Loc loc, Color headerColor, const(char)* header, + nothrow bool diagnosticHandler(const ref SourceLoc loc, Color headerColor, const(char)* header, const(char)* format, va_list ap, const(char)* p1, const(char)* p2) { OutBuffer tmp; diff --git a/compiler/test/unit/objc/protocols/diagnostic_messages.d b/compiler/test/unit/objc/protocols/diagnostic_messages.d index ce673c93118c..691b25f6953d 100644 --- a/compiler/test/unit/objc/protocols/diagnostic_messages.d +++ b/compiler/test/unit/objc/protocols/diagnostic_messages.d @@ -41,7 +41,7 @@ unittest }.stripDelimited; enum message = "Error: class test.Bar interface function extern (Objective-C) static void foo() is not implemented"; - auto expected = Diagnostic(Loc(filename, 8, 1), message); + auto expected = Diagnostic(SourceLoc(filename, 8, 1), message); const diagnostics = compiles(code, filename); assert(diagnostics == [expected], "\n" ~ diagnostics.toString); @@ -65,7 +65,7 @@ unittest }.stripDelimited; enum message = "Error: function test.Foo.foo function body only allowed in final functions in interface Foo"; - auto expected = Diagnostic(Loc(filename, 4, 17), message); + auto expected = Diagnostic(SourceLoc(filename, 4, 17), message); const diagnostics = compiles(code, filename); assert(diagnostics == [expected], "\n" ~ diagnostics.toString); diff --git a/compiler/test/unit/objc/protocols/optional_methods.d b/compiler/test/unit/objc/protocols/optional_methods.d index 4a87f85cac6f..3a55bbcf7e17 100644 --- a/compiler/test/unit/objc/protocols/optional_methods.d +++ b/compiler/test/unit/objc/protocols/optional_methods.d @@ -129,7 +129,7 @@ unittest } }.stripDelimited; - Loc loc = Loc(filename, 5, 20); + SourceLoc loc = SourceLoc(filename, 5, 20); enum message = "Error: function test.Foo.foo only functions with Objective-C linkage can be declared as optional"; enum supplemental = "function is declared with D linkage"; auto expected = [Diagnostic(loc, message), Diagnostic(loc, supplemental)]; @@ -154,7 +154,7 @@ unittest } }.stripDelimited; - Loc loc = Loc(filename, 6, 30); + SourceLoc loc = SourceLoc(filename, 6, 30); enum message = "Error: function test.Foo.foo can only declare a function as optional once"; auto expected = Diagnostic(loc, message); @@ -184,15 +184,13 @@ unittest } }.stripDelimited; - Loc loc = Loc(filename, 6, 20); - auto expected = [ Diagnostic( - Loc(filename, 6, 20), + SourceLoc(filename, 6, 20), "Error: function test.Foo.foo!().foo template cannot be optional" ), Diagnostic( - Loc(filename, 12, 10), + SourceLoc(filename, 12, 10), "Error: template instance test.Foo.foo!() error instantiating" ) ]; @@ -223,7 +221,7 @@ unittest } }.stripDelimited; - Loc loc = Loc(filename, 6, 20); + SourceLoc loc = SourceLoc(filename, 6, 20); enum message = "Error: function test.Foo.foo only functions declared inside interfaces can be optional"; enum supplemental = "function is declared inside class"; auto expected = [Diagnostic(loc, message), Diagnostic(loc, supplemental)]; diff --git a/compiler/test/unit/parser/diagnostic_reporter.d b/compiler/test/unit/parser/diagnostic_reporter.d index 719811fa315f..77681a10e50f 100644 --- a/compiler/test/unit/parser/diagnostic_reporter.d +++ b/compiler/test/unit/parser/diagnostic_reporter.d @@ -29,7 +29,7 @@ unittest { int errorCount; - override bool error(const ref Loc, const(char)*, va_list, const(char)*, const(char)*) + override bool error(const ref SourceLoc, const(char)*, va_list, const(char)*, const(char)*) { errorCount++; return true; @@ -52,7 +52,7 @@ unittest { int supplementalCount; - override bool errorSupplemental(const ref Loc, const(char)*, va_list, const(char)*, const(char)*) + override bool errorSupplemental(const ref SourceLoc, const(char)*, va_list, const(char)*, const(char)*) { supplementalCount++; return true; @@ -79,7 +79,7 @@ unittest { int warningCount; - override bool warning(const ref Loc, const(char)*, va_list, const(char)*, const(char)*) + override bool warning(const ref SourceLoc, const(char)*, va_list, const(char)*, const(char)*) { warningCount++; return true; diff --git a/compiler/test/unit/support.d b/compiler/test/unit/support.d index e5e6d5187d4e..65e7e8e47167 100644 --- a/compiler/test/unit/support.d +++ b/compiler/test/unit/support.d @@ -115,19 +115,19 @@ class NoopDiagnosticReporter : DiagnosticReporter override int errorCount() { return 0; } override int warningCount() { return 0; } override int deprecationCount() { return 0; } - override bool error(const ref Loc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } - override bool errorSupplemental(const ref Loc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } - override bool warning(const ref Loc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } - override bool warningSupplemental(const ref Loc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } - override bool deprecation(const ref Loc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } - override bool deprecationSupplemental(const ref Loc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } + override bool error(const ref SourceLoc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } + override bool errorSupplemental(const ref SourceLoc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } + override bool warning(const ref SourceLoc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } + override bool warningSupplemental(const ref SourceLoc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } + override bool deprecation(const ref SourceLoc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } + override bool deprecationSupplemental(const ref SourceLoc loc, const(char)* format, va_list, const(char)* p1, const(char)* p2) { return true; } } /// A single diagnostic. const struct Diagnostic { /// The location of the diagnostic. - Loc location; + SourceLoc location; /// The diagnostic message. string message; @@ -157,7 +157,7 @@ struct DiagnosticCollector /// Handles a diagnostic. bool handleDiagnostic ( - const ref Loc location, + const ref SourceLoc location, Color headerColor, const(char)* header, const(char)* messageFormat,