Fix allman brace style (#20885)

This commit is contained in:
Dennis 2025-02-17 15:23:33 +01:00 committed by GitHub
parent ef47ecf0a2
commit 4d4d09ab33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 126 additions and 79 deletions

View file

@ -274,8 +274,10 @@ void disassemble(uint c) @trusted
uint ins = *(cast(uint*)&code[c]); uint ins = *(cast(uint*)&code[c]);
p0[0]='\0'; p0[0]='\0';
if (bObjectcode) { if (bObjectcode)
for (i=siz; i; --i) { {
for (i=siz; i; --i)
{
snprintf( buf.ptr, buf.length, "%02X", code[c+i-1] ); snprintf( buf.ptr, buf.length, "%02X", code[c+i-1] );
printf("%s ", buf.ptr); printf("%s ", buf.ptr);
//strcat( p0.ptr, buf.ptr ); //strcat( p0.ptr, buf.ptr );

View file

@ -53,7 +53,7 @@ alias nlist = dmd.backend.mach.nlist; // avoid conflict with dmd.backend.dlist
* put before nothrow because qsort was not marked nothrow until version 2.086 * put before nothrow because qsort was not marked nothrow until version 2.086
*/ */
extern (C) { extern (C)
@trusted @trusted
private int mach_rel_fp(scope const(void*) e1, scope const(void*) e2) private int mach_rel_fp(scope const(void*) e1, scope const(void*) e2)
{ Relocation* r1 = cast(Relocation*)e1; { Relocation* r1 = cast(Relocation*)e1;
@ -61,7 +61,6 @@ private int mach_rel_fp(scope const(void*) e1, scope const(void*) e2)
return cast(int)(r1.offset - r2.offset); return cast(int)(r1.offset - r2.offset);
} }
}
@trusted @trusted
void mach_relsort(OutBuffer* buf) void mach_relsort(OutBuffer* buf)

View file

@ -2133,7 +2133,7 @@ void MsCoffObj_addrel(segidx_t seg, targ_size_t offset, Symbol* targsym,
* Sort the relocation entry buffer. * Sort the relocation entry buffer.
*/ */
extern (C) { extern (C)
@trusted @trusted
private int mscoff_rel_fp(scope const(void*) e1, scope const(void*) e2) private int mscoff_rel_fp(scope const(void*) e1, scope const(void*) e2)
{ Relocation* r1 = cast(Relocation*)e1; { Relocation* r1 = cast(Relocation*)e1;
@ -2141,7 +2141,6 @@ private int mscoff_rel_fp(scope const(void*) e1, scope const(void*) e2)
return cast(int)(r1.offset - r2.offset); return cast(int)(r1.offset - r2.offset);
} }
}
/******************************* /*******************************
* Refer to address that is in the data segment. * Refer to address that is in the data segment.

View file

@ -651,7 +651,8 @@ char* getEAimpl(ubyte rex, uint c, int do_xmm, uint vlen)
return displacementFixup(c + 2, 2, rmstr[rm]); return displacementFixup(c + 2, 2, rmstr[rm]);
case 3: case 3:
switch (opcode) { switch (opcode)
{
case 0x8c: case 0x8c:
case 0x8e: case 0x8e:
p = wordreg[rm]; p = wordreg[rm];
@ -1886,8 +1887,10 @@ void disassemble(uint c)
p0[0]='\0'; p0[0]='\0';
if (opcode == 0 && c + 1 >= code.length) if (opcode == 0 && c + 1 >= code.length)
return; return;
if (bObjectcode) { if (bObjectcode)
for (i=0; i<siz; i++) { {
for (i=0; i<siz; i++)
{
snprintf( buf.ptr, buf.length, "%02X ", code[c+i] ); snprintf( buf.ptr, buf.length, "%02X ", code[c+i] );
strcat( p0.ptr, buf.ptr ); strcat( p0.ptr, buf.ptr );
} }

View file

@ -42,7 +42,8 @@ struct IdentifierCharLookup
// Awful solution to require these lambdas. // Awful solution to require these lambdas.
// However without them the extern(C++) ABI issues crop up for isInRange, // However without them the extern(C++) ABI issues crop up for isInRange,
// and then it can't access the tables. // and then it can't access the tables.
final switch(table) { final switch(table)
{
case IdentifierTable.UAX31: case IdentifierTable.UAX31:
return IdentifierCharLookup( return IdentifierCharLookup(
(c) => isInRange!UAX31_Start(c), (c) => isInRange!UAX31_Start(c),

View file

@ -1989,13 +1989,15 @@ public:
Declaration decl = ve.var; Declaration decl = ve.var;
// We cannot take the address of an imported symbol at compile time // We cannot take the address of an imported symbol at compile time
if (decl.isImportedSymbol()) { if (decl.isImportedSymbol())
{
error(e.loc, "cannot take address of imported symbol `%s` at compile time", decl.toChars()); error(e.loc, "cannot take address of imported symbol `%s` at compile time", decl.toChars());
result = CTFEExp.cantexp; result = CTFEExp.cantexp;
return; return;
} }
if (decl.isDataseg()) { if (decl.isDataseg())
{
// Normally this is already done by optimize() // Normally this is already done by optimize()
// Do it here in case optimize(WANTvalue) wasn't run before CTFE // Do it here in case optimize(WANTvalue) wasn't run before CTFE
emplaceExp!(SymOffExp)(pue, e.loc, e.e1.isVarExp().var, 0); emplaceExp!(SymOffExp)(pue, e.loc, e.e1.isVarExp().var, 0);

View file

@ -2061,9 +2061,9 @@ string toLowercase(string s) pure @safe
// TODO: maybe unicode lowercase, somehow // TODO: maybe unicode lowercase, somehow
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
{ {
if (!lower.length) { if (!lower.length)
lower.reserve(s.length); lower.reserve(s.length);
}
lower ~= s[lower.length..i]; lower ~= s[lower.length..i];
c += 'a' - 'A'; c += 'a' - 'A';
lower ~= c; lower ~= c;

View file

@ -5343,7 +5343,8 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc)
{ {
s = tident.toDsymbol(sc); s = tident.toDsymbol(sc);
// don't error for `var1.static_symbol` // don't error for `var1.static_symbol`
if (s && s.needThis()) { if (s && s.needThis())
{
error(ds.loc, "cannot alias %s member `%s` of variable `%s`", error(ds.loc, "cannot alias %s member `%s` of variable `%s`",
s.kind(), s.toChars(), mt.ident.toChars()); s.kind(), s.toChars(), mt.ident.toChars());
errorSupplemental(ds.loc, "Use `typeof(%s)` instead to preserve behaviour", errorSupplemental(ds.loc, "Use `typeof(%s)` instead to preserve behaviour",

View file

@ -976,7 +976,8 @@ public:
{ {
EnumKind kind = getEnumKind(type); EnumKind kind = getEnumKind(type);
if (vd.visibility.kind == AST.Visibility.Kind.none || vd.visibility.kind == AST.Visibility.Kind.private_) { if (vd.visibility.kind == AST.Visibility.Kind.none || vd.visibility.kind == AST.Visibility.Kind.private_)
{
ignored("enum `%s` because it is `%s`.", vd.toPrettyChars(), AST.visibilityToChars(vd.visibility.kind)); ignored("enum `%s` because it is `%s`.", vd.toPrettyChars(), AST.visibilityToChars(vd.visibility.kind));
return; return;
} }

View file

@ -6908,7 +6908,8 @@ elem* buildRangeError(ref IRState irs, Loc loc)
* Returns: * Returns:
* elem generated * elem generated
*/ */
elem* buildArraySliceError(ref IRState irs, Loc loc, elem* lower, elem* upper, elem* length) { elem* buildArraySliceError(ref IRState irs, Loc loc, elem* lower, elem* upper, elem* length)
{
final switch (irs.params.checkAction) final switch (irs.params.checkAction)
{ {
case CHECKACTION.C: case CHECKACTION.C:
@ -6935,7 +6936,8 @@ elem* buildArraySliceError(ref IRState irs, Loc loc, elem* lower, elem* upper, e
* Returns: * Returns:
* elem generated * elem generated
*/ */
elem* buildArrayIndexError(ref IRState irs, Loc loc, elem* index, elem* length) { elem* buildArrayIndexError(ref IRState irs, Loc loc, elem* index, elem* length)
{
final switch (irs.params.checkAction) final switch (irs.params.checkAction)
{ {
case CHECKACTION.C: case CHECKACTION.C:
@ -6951,7 +6953,8 @@ elem* buildArrayIndexError(ref IRState irs, Loc loc, elem* index, elem* length)
} }
/// Returns: elem representing a C-string (char*) to the filename /// Returns: elem representing a C-string (char*) to the filename
elem* locToFileElem(const ref IRState irs, Loc loc) { elem* locToFileElem(const ref IRState irs, Loc loc)
{
elem* efile; elem* efile;
if (auto fname = loc.filename) if (auto fname = loc.filename)

View file

@ -101,8 +101,10 @@ private struct PathCache
*/ */
bool exists = true; bool exists = true;
auto st = PathStack(filespec); auto st = PathStack(filespec);
while (st.up) { while (st.up)
if (auto cached = pathStatus.lookup(st.cur)) { {
if (auto cached = pathStatus.lookup(st.cur))
{
exists = cached.value; exists = cached.value;
break; break;
} }
@ -112,7 +114,8 @@ private struct PathCache
* Once a directory is found to not exist, all the directories * Once a directory is found to not exist, all the directories
* to the right of it do not exist * to the right of it do not exist
*/ */
while (st.down) { while (st.down)
{
if (!exists) if (!exists)
pathStatus.insert(st.cur, false); pathStatus.insert(st.cur, false);
else else
@ -218,17 +221,19 @@ nothrow:
const(char)[] n = FileName.combine(p, sdi); const(char)[] n = FileName.combine(p, sdi);
if (!pathCache.pathExists(n)) { if (!pathCache.pathExists(n))
{
FileName.free(n.ptr); FileName.free(n.ptr);
continue; // no need to check for anything else. continue; // no need to check for anything else.
} }
if (FileName.exists(n) == 1) { if (FileName.exists(n) == 1)
return n; return n;
}
FileName.free(n.ptr); FileName.free(n.ptr);
n = FileName.combine(p, sd); n = FileName.combine(p, sd);
if (FileName.exists(n) == 1) { if (FileName.exists(n) == 1)
{
whichPathFoundThis = pathIndex; whichPathFoundThis = pathIndex;
return n; return n;
} }
@ -241,14 +246,16 @@ nothrow:
if (pathCache.isExistingPath(n)) if (pathCache.isExistingPath(n))
{ {
const n2i = FileName.combine(n, package_di); const n2i = FileName.combine(n, package_di);
if (FileName.exists(n2i) == 1) { if (FileName.exists(n2i) == 1)
{
whichPathFoundThis = pathIndex; whichPathFoundThis = pathIndex;
return n2i; return n2i;
} }
FileName.free(n2i.ptr); FileName.free(n2i.ptr);
const n2 = FileName.combine(n, package_d); const n2 = FileName.combine(n, package_d);
if (FileName.exists(n2) == 1) { if (FileName.exists(n2) == 1)
{
whichPathFoundThis = pathIndex; whichPathFoundThis = pathIndex;
return n2; return n2;
} }
@ -272,14 +279,16 @@ nothrow:
const p = entry.path.toDString(); const p = entry.path.toDString();
const(char)[] n = FileName.combine(p, si); const(char)[] n = FileName.combine(p, si);
if (FileName.exists(n) == 1) { if (FileName.exists(n) == 1)
{
whichPathFoundThis = pathIndex; whichPathFoundThis = pathIndex;
return n; return n;
} }
FileName.free(n.ptr); FileName.free(n.ptr);
n = FileName.combine(p, sc); n = FileName.combine(p, sc);
if (FileName.exists(n) == 1) { if (FileName.exists(n) == 1)
{
whichPathFoundThis = pathIndex; whichPathFoundThis = pathIndex;
return n; return n;
} }

View file

@ -41,10 +41,13 @@ import dmd.root.string;
import dmd.target; import dmd.target;
import dmd.visitor; import dmd.visitor;
version(Windows) { version(Windows)
{
extern (C) char* _getcwd(char* buffer, size_t maxlen); extern (C) char* _getcwd(char* buffer, size_t maxlen);
alias getcwd = _getcwd; alias getcwd = _getcwd;
} else { }
else
{
import core.sys.posix.unistd : getcwd; import core.sys.posix.unistd : getcwd;
} }

View file

@ -445,7 +445,8 @@ public:
visitType(p.type); visitType(p.type);
} }
override void visit(StructLiteralExp e) { override void visit(StructLiteralExp e)
{
static if (LOG) static if (LOG)
printf("StructLiteralExp: %s\n", e.toChars); printf("StructLiteralExp: %s\n", e.toChars);

View file

@ -3441,10 +3441,9 @@ class Lexer
int linestart = 0; int linestart = 0;
if (ct == '/') if (ct == '/')
{ {
if (q < qend && *q == ' ') { if (q < qend && *q == ' ')
++q; ++q;
} }
}
else if (q < qend) else if (q < qend)
{ {
if (*q == '\r') if (*q == '\r')

View file

@ -1064,18 +1064,21 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
if (!vsopt.VSInstallDir) if (!vsopt.VSInstallDir)
vsopt.initialize(); vsopt.initialize();
if (auto vcincludedir = vsopt.getVCIncludeDir()) { if (auto vcincludedir = vsopt.getVCIncludeDir())
includePaths.push(vcincludedir); includePaths.push(vcincludedir);
} else { else
return STATUS_FAILED; return STATUS_FAILED;
}
if (auto sdkincludedir = vsopt.getSDKIncludePath()) { if (auto sdkincludedir = vsopt.getSDKIncludePath())
{
includePaths.push(FileName.combine(sdkincludedir, "ucrt")); includePaths.push(FileName.combine(sdkincludedir, "ucrt"));
includePaths.push(FileName.combine(sdkincludedir, "shared")); includePaths.push(FileName.combine(sdkincludedir, "shared"));
includePaths.push(FileName.combine(sdkincludedir, "um")); includePaths.push(FileName.combine(sdkincludedir, "um"));
includePaths.push(FileName.combine(sdkincludedir, "winrt")); includePaths.push(FileName.combine(sdkincludedir, "winrt"));
includePaths.push(FileName.combine(sdkincludedir, "cppwinrt")); includePaths.push(FileName.combine(sdkincludedir, "cppwinrt"));
} else { }
else
{
includePaths = Strings.init; includePaths = Strings.init;
return STATUS_FAILED; return STATUS_FAILED;
} }
@ -1193,13 +1196,15 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
// pipe so we can read the output of the preprocssor // pipe so we can read the output of the preprocssor
int[2] pipefd; // [0] is read, [1] is write int[2] pipefd; // [0] is read, [1] is write
if (pipe(&pipefd[0]) == -1) { if (pipe(&pipefd[0]) == -1)
{
perror("pipe"); // failed to create pipe perror("pipe"); // failed to create pipe
return STATUS_FAILED; return STATUS_FAILED;
} }
pid_t childpid = fork(); pid_t childpid = fork();
if (childpid == -1) { if (childpid == -1)
{
perror("fork failed"); // fork failed perror("fork failed"); // fork failed
return STATUS_FAILED; return STATUS_FAILED;
} }
@ -1223,11 +1228,11 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
OutBuffer buffer; OutBuffer buffer;
ubyte[1024] tmp = void; ubyte[1024] tmp = void;
ptrdiff_t nread; ptrdiff_t nread;
while ((nread = read(pipefd[0], tmp.ptr, tmp.length)) > 0) { while ((nread = read(pipefd[0], tmp.ptr, tmp.length)) > 0)
buffer.write(tmp[0 .. nread]); buffer.write(tmp[0 .. nread]);
}
if (nread == -1) { if (nread == -1)
{
perror("read"); perror("read");
return STATUS_FAILED; return STATUS_FAILED;
} }

View file

@ -334,9 +334,8 @@ const(char)[] parse_conf_arg(Strings* args)
const(char)[] arg = p.toDString; const(char)[] arg = p.toDString;
if (arg.length && arg[0] == '-') if (arg.length && arg[0] == '-')
{ {
if(arg.length >= 6 && arg[1 .. 6] == "conf="){ if(arg.length >= 6 && arg[1 .. 6] == "conf=")
conf = arg[6 .. $]; conf = arg[6 .. $];
}
else if (arg[1 .. $] == "run") else if (arg[1 .. $] == "run")
break; break;
} }

View file

@ -3863,7 +3863,8 @@ extern (C++) struct ParameterList
foreach (_, p1; cast() this) foreach (_, p1; cast() this)
{ {
auto p2 = other[idx++]; auto p2 = other[idx++];
if (!p2 || p1 != p2) { if (!p2 || p1 != p2)
{
diff = true; diff = true;
break; break;
} }

View file

@ -341,8 +341,8 @@ unittest
* The null-terminator is inside the bounds of the array. * The null-terminator is inside the bounds of the array.
* If cp could not be resolved, null is returned. * If cp could not be resolved, null is returned.
*/ */
private char[] lookupInEnvironment(scope const(char)* cp) nothrow { private char[] lookupInEnvironment(scope const(char)* cp) nothrow
{
import core.stdc.stdlib: getenv; import core.stdc.stdlib: getenv;
import core.stdc.string: strlen; import core.stdc.string: strlen;
import dmd.root.rmem: mem; import dmd.root.rmem: mem;

View file

@ -377,9 +377,9 @@ auto splitLines(const char[] text)
public const(char)[] front() public const(char)[] front()
{ {
advance(); advance();
if (index > eolIndex || index >= text.length) { if (index > eolIndex || index >= text.length)
return ""; return "";
}
return text[index .. eolIndex]; return text[index .. eolIndex];
} }

View file

@ -356,7 +356,8 @@ longdouble_soft strtold_dm(const(char) *p, char **endp)
pow >>= 1; pow >>= 1;
u++; u++;
} }
static if(0) { static if(0)
{
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
printf("%04x ",ldval.value[i]); printf("%04x ",ldval.value[i]);
printf("\n"); printf("\n");
@ -419,8 +420,8 @@ void main()
/************************* Bigint ************************************/ /************************* Bigint ************************************/
static if (0) { static if (0)
{
/* This program computes powers of 10 exactly. /* This program computes powers of 10 exactly.
* Used to generate postab[]. * Used to generate postab[].
*/ */

View file

@ -63,7 +63,8 @@ string intToString(int value) nothrow {
} }
/// Represents a SARIF result containing a rule ID, message, and location. /// Represents a SARIF result containing a rule ID, message, and location.
struct SarifResult { struct SarifResult
{
string ruleId; /// Rule identifier. string ruleId; /// Rule identifier.
string message; /// Error or warning message. string message; /// Error or warning message.
string uri; /// URI of the affected file. string uri; /// URI of the affected file.
@ -74,7 +75,8 @@ struct SarifResult {
/// ///
/// Returns: /// Returns:
/// - A JSON string representing the SARIF result, including the rule ID, message, and location. /// - A JSON string representing the SARIF result, including the rule ID, message, and location.
string toJson() nothrow { string toJson() nothrow
{
OutBuffer buffer; OutBuffer buffer;
buffer.writestring(`{"ruleId": "`); buffer.writestring(`{"ruleId": "`);
buffer.writestring(ruleId); buffer.writestring(ruleId);
@ -115,7 +117,8 @@ void addSarifDiagnostic(const SourceLoc loc, const(char)* format, va_list ap, Er
} }
/// Represents a SARIF report containing tool information, invocation, and results. /// Represents a SARIF report containing tool information, invocation, and results.
struct SarifReport { struct SarifReport
{
ToolInformation tool; /// Information about the analysis tool. ToolInformation tool; /// Information about the analysis tool.
Invocation invocation; /// Execution information. Invocation invocation; /// Execution information.
SarifResult[] results; /// List of SARIF results (errors, warnings, etc.). SarifResult[] results; /// List of SARIF results (errors, warnings, etc.).
@ -124,16 +127,19 @@ struct SarifReport {
/// ///
/// Returns: /// Returns:
/// - A JSON string representing the SARIF report, including the tool information, invocation, and results. /// - A JSON string representing the SARIF report, including the tool information, invocation, and results.
string toJson() nothrow { string toJson() nothrow
{
OutBuffer buffer; OutBuffer buffer;
buffer.writestring(`{"tool": `); buffer.writestring(`{"tool": `);
buffer.writestring(tool.toJson()); buffer.writestring(tool.toJson());
buffer.writestring(`, "invocation": `); buffer.writestring(`, "invocation": `);
buffer.writestring(invocation.toJson()); buffer.writestring(invocation.toJson());
buffer.writestring(`, "results": [`); buffer.writestring(`, "results": [`);
if (results.length > 0) { if (results.length > 0)
{
buffer.writestring(results[0].toJson()); buffer.writestring(results[0].toJson());
foreach (result; results[1 .. $]) { foreach (result; results[1 .. $])
{
buffer.writestring(`, `); buffer.writestring(`, `);
buffer.writestring(result.toJson()); buffer.writestring(result.toJson());
} }
@ -144,14 +150,16 @@ struct SarifReport {
} }
/// Represents invocation information for the analysis process. /// Represents invocation information for the analysis process.
struct Invocation { struct Invocation
{
bool executionSuccessful; /// Whether the execution was successful. bool executionSuccessful; /// Whether the execution was successful.
/// Converts the invocation information to a JSON string. /// Converts the invocation information to a JSON string.
/// ///
/// Returns: /// Returns:
/// - A JSON representation of the invocation status. /// - A JSON representation of the invocation status.
string toJson() nothrow { string toJson() nothrow
{
OutBuffer buffer; OutBuffer buffer;
buffer.writestring(`{"executionSuccessful": `); buffer.writestring(`{"executionSuccessful": `);
buffer.writestring(executionSuccessful ? "true" : "false"); buffer.writestring(executionSuccessful ? "true" : "false");
@ -170,7 +178,8 @@ Params:
Returns: Returns:
A formatted error message string. A formatted error message string.
*/ */
string formatErrorMessage(const(char)* format, va_list ap) nothrow { string formatErrorMessage(const(char)* format, va_list ap) nothrow
{
char[2048] buffer; char[2048] buffer;
import core.stdc.stdio : vsnprintf; import core.stdc.stdio : vsnprintf;
vsnprintf(buffer.ptr, buffer.length, format, ap); vsnprintf(buffer.ptr, buffer.length, format, ap);
@ -188,7 +197,8 @@ Returns:
*/ */
string errorKindToString(ErrorKind kind) nothrow string errorKindToString(ErrorKind kind) nothrow
{ {
final switch (kind) { final switch (kind)
{
case ErrorKind.error: return "error"; // Serious problem case ErrorKind.error: return "error"; // Serious problem
case ErrorKind.warning: return "warning"; // Problem found case ErrorKind.warning: return "warning"; // Problem found
case ErrorKind.deprecation: return "note"; // Minor problem, opportunity for improvement case ErrorKind.deprecation: return "note"; // Minor problem, opportunity for improvement
@ -220,15 +230,15 @@ void generateSarifReport(bool executionSuccessful) nothrow
// Extract and clean the version string // Extract and clean the version string
string toolVersion = global.versionString(); string toolVersion = global.versionString();
// Remove 'v' prefix if it exists // Remove 'v' prefix if it exists
if (toolVersion.length > 0 && toolVersion[0] == 'v') { if (toolVersion.length > 0 && toolVersion[0] == 'v')
toolVersion = toolVersion[1 .. $]; toolVersion = toolVersion[1 .. $];
}
// Find the first non-numeric character after the version number // Find the first non-numeric character after the version number
size_t length = toolVersion.length; size_t length = toolVersion.length;
const(char)* nonNumeric = strchr(toolVersion.ptr, '-'); const(char)* nonNumeric = strchr(toolVersion.ptr, '-');
if (nonNumeric) { if (nonNumeric)
length = cast(size_t)(nonNumeric - toolVersion.ptr); length = cast(size_t)(nonNumeric - toolVersion.ptr);
}
string cleanedVersion = toolVersion[0 .. length]; string cleanedVersion = toolVersion[0 .. length];
// Build SARIF report // Build SARIF report
@ -276,7 +286,8 @@ void generateSarifReport(bool executionSuccessful) nothrow
ob.writestringln(`"results": [`); ob.writestringln(`"results": [`);
ob.level += 1; ob.level += 1;
foreach (idx, diag; diagnostics) { foreach (idx, diag; diagnostics)
{
ob.writestringln("{"); ob.writestringln("{");
ob.level += 1; ob.level += 1;
@ -332,12 +343,11 @@ void generateSarifReport(bool executionSuccessful) nothrow
// Closing brace for each diagnostic item // Closing brace for each diagnostic item
ob.level -= 1; ob.level -= 1;
if (idx < diagnostics.length - 1) { if (idx < diagnostics.length - 1)
ob.writestringln("},"); ob.writestringln("},");
} else { else
ob.writestringln("}"); ob.writestringln("}");
} }
}
// Close the run and SARIF JSON // Close the run and SARIF JSON
ob.level -= 1; ob.level -= 1;

View file

@ -351,7 +351,8 @@ bool discardValue(Expression e)
bool seenSideEffect = false; bool seenSideEffect = false;
foreach(expr; [tmp.e1, tmp.e2]) foreach(expr; [tmp.e1, tmp.e2])
{ {
if (hasSideEffect(expr)) { if (hasSideEffect(expr))
{
errorSupplemental(expr.loc, "note that `%s` may have a side effect", expr.toErrMsg()); errorSupplemental(expr.loc, "note that `%s` may have a side effect", expr.toErrMsg());
seenSideEffect |= true; seenSideEffect |= true;
} }

View file

@ -436,8 +436,10 @@ enum FirstCKeyword = TOK.inline;
// Assert that all token enum members have consecutive values and // Assert that all token enum members have consecutive values and
// that none of them overlap // that none of them overlap
static assert(() { static assert(() {
foreach (idx, enumName; __traits(allMembers, TOK)) { foreach (idx, enumName; __traits(allMembers, TOK))
static if (idx != __traits(getMember, TOK, enumName)) { {
static if (idx != __traits(getMember, TOK, enumName))
{
pragma(msg, "Error: Expected TOK.", enumName, " to be ", idx, " but is ", __traits(getMember, TOK, enumName)); pragma(msg, "Error: Expected TOK.", enumName, " to be ", idx, " but is ", __traits(getMember, TOK, enumName));
static assert(0); static assert(0);
} }
@ -925,13 +927,18 @@ nothrow:
return 0; return 0;
} }
extern(D) void appendInterpolatedPart(const ref OutBuffer buf) { extern(D) void appendInterpolatedPart(const ref OutBuffer buf)
{
appendInterpolatedPart(cast(const(char)*)buf[].ptr, buf.length); appendInterpolatedPart(cast(const(char)*)buf[].ptr, buf.length);
} }
extern(D) void appendInterpolatedPart(const(char)[] str) {
extern(D) void appendInterpolatedPart(const(char)[] str)
{
appendInterpolatedPart(str.ptr, str.length); appendInterpolatedPart(str.ptr, str.length);
} }
extern(D) void appendInterpolatedPart(const(char)* ptr, size_t length) {
extern(D) void appendInterpolatedPart(const(char)* ptr, size_t length)
{
assert(value == TOK.interpolated); assert(value == TOK.interpolated);
if (interpolatedSet is null) if (interpolatedSet is null)
interpolatedSet = new InterpolatedSet; interpolatedSet = new InterpolatedSet;