Skip to content
Merged
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
2 changes: 1 addition & 1 deletion posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ check-clean-git:
fi

style:
@echo "To be done"
$(QUIET)$(MAKE) -C src -f posix.mak style

.DELETE_ON_ERROR: # GNU Make directive (delete output files on error)
118 changes: 118 additions & 0 deletions src/.dscanner.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
; Configure which static analysis checks are enabled
[analysis.config.StaticAnalysisConfig]
; Check variable, class, struct, interface, union, and function names against
; the Phobos style guide
style_check="disabled"
; Check for array literals that cause unnecessary allocation
enum_array_literal_check="enabled"
; Check for poor exception handling practices
exception_check="enabled"
; Check for use of the deprecated 'delete' keyword
delete_check="enabled"
; Check for use of the deprecated floating point operators
float_operator_check="enabled"
; Check number literals for readability
number_style_check="disabled"
; Checks that opEquals, opCmp, toHash, and toString are either const, immutable
; , or inout.
object_const_check="enabled"
; Checks for .. expressions where the left side is larger than the right.
backwards_range_check="enabled"
; Checks for if statements whose 'then' block is the same as the 'else' block
if_else_same_check="enabled"
; Checks for some problems with constructors
constructor_check="enabled"
; Checks for unused variables and function parameters
unused_variable_check="disabled"
; Checks for unused labels
unused_label_check="disabled"
; Checks for duplicate attributes
duplicate_attribute="enabled"
; Checks that opEquals and toHash are both defined or neither are defined
opequals_tohash_check="disabled"
; Checks for subtraction from .length properties
length_subtraction_check="disabled"
; Checks for methods or properties whose names conflict with built-in propertie
; s
builtin_property_names_check="enabled"
; Checks for confusing code in inline asm statements
asm_style_check="enabled"
; Checks for confusing logical operator precedence
logical_precedence_check="disabled"
; Checks for undocumented public declarations
undocumented_declaration_check="disabled"
; Checks for poor placement of function attributes
function_attribute_check="enabled"
; Checks for use of the comma operator
comma_expression_check="enabled"
; Checks for local imports that are too broad
local_import_check="disabled"
; Checks for variables that could be declared immutable
could_be_immutable_check="disabled"
; Checks for redundant expressions in if statements
redundant_if_check="enabled"
; Checks for redundant parenthesis
redundant_parens_check="disabled"
; Checks for mismatched argument and parameter names
mismatched_args_check="disabled"
; Checks for labels with the same name as variables
label_var_same_name_check="disabled"
; Checks for lines longer than 120 characters
long_line_check="disabled"
; Checks for assignment to auto-ref function parameters
auto_ref_assignment_check="disabled"
; Checks for incorrect infinite range definitions
incorrect_infinite_range_check="enabled"
; Checks for asserts that are always true
useless_assert_check="enabled"
; Check for uses of the old-style alias syntax
alias_syntax_check="disabled"
; Checks for else if that should be else static if
static_if_else_check="enabled"
; Check for unclear lambda syntax
lambda_return_check="enabled"
; Check for auto function without return statement
auto_function_check="enabled"
; Check for sortedness of imports
imports_sortedness="disabled"
; Check for explicitly annotated unittests
explicitly_annotated_unittests="disabled"
; Check for properly documented public functions (Returns, Params)
properly_documented_public_functions="disabled"
; Check for useless usage of the final attribute
final_attribute_check="disabled"
; Check for virtual calls in the class constructors
vcall_in_ctor="enabled"
; Check for useless user defined initializers
useless_initializer="disabled"
; Check allman brace style
allman_braces_check="disabled"
; Check for redundant attributes
redundant_attributes_check="disabled"
; Check for public declarations without a documented unittest
has_public_example="disabled"
; Check for asserts without an explanatory message
assert_without_msg="disabled"
; Check indent of if constraints
if_constraints_indent="enabled"
; Check for @trusted applied to a bigger scope than a single function
trust_too_much="enabled"
; Check for redundant storage classes on variable declarations")
redundant_storage_classes="enabled"

; Configure which modules are checked with a specific checker
; Please help to extend these checks onto more Phobos modules
; Process:
; - Pick your favorite check
; - Remove a module from the blacklist
; - Run DScanner
; - Fix the warnings
; - Submit a PR to DMD
; - GOTO: Remove a module
;
; Some checks are currently disabled.
[analysis.config.ModuleFilters]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a very simplistic blacklist. For Phobos, we generated the entire blacklist for important checks.
See: dlang/phobos#5501

redundant_storage_classes="-dmd.id,-dmd.toir,-dmd.tokens"
trust_too_much="-dmd.root.longdouble"
builtin_property_names_check="-dmd.backend.obj,-dmd.backend.code,-dmd.backend.cc"
object_const_check="-dmd.dtemplate,-dmd.backend.outbuf"
13 changes: 5 additions & 8 deletions src/dmd/arrayop.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,11 @@ extern (C++) bool isArrayOpValid(Expression e)
BinExp be = cast(BinExp)e;
return be.e1.op == TOK.slice && isArrayOpValid(be.e2);
}
if (e.op == TOK.call)
{
return false; // TODO: Decide if [] is required after arrayop calls.
}
else
{
return false;
}
// if (e.op == TOK.call)
// {
// TODO: Decide if [] is required after arrayop calls.
// }
return false;
}
return true;
}
Expand Down
132 changes: 66 additions & 66 deletions src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ struct ASTBase

extern (C++) final class Module : Package
{
extern (C++) static __gshared AggregateDeclaration moduleinfo;
extern (C++) __gshared AggregateDeclaration moduleinfo;

File* srcfile;
const(char)* arg;
Expand Down Expand Up @@ -1520,7 +1520,7 @@ struct ASTBase

super(loc, id);

static __gshared const(char)* msg = "only object.d can define this reserved class name";
__gshared const(char)* msg = "only object.d can define this reserved class name";

if (baseclasses)
{
Expand Down Expand Up @@ -2549,67 +2549,67 @@ struct ASTBase
MOD mod;
char* deco;

extern (C++) static __gshared Type tvoid;
extern (C++) static __gshared Type tint8;
extern (C++) static __gshared Type tuns8;
extern (C++) static __gshared Type tint16;
extern (C++) static __gshared Type tuns16;
extern (C++) static __gshared Type tint32;
extern (C++) static __gshared Type tuns32;
extern (C++) static __gshared Type tint64;
extern (C++) static __gshared Type tuns64;
extern (C++) static __gshared Type tint128;
extern (C++) static __gshared Type tuns128;
extern (C++) static __gshared Type tfloat32;
extern (C++) static __gshared Type tfloat64;
extern (C++) static __gshared Type tfloat80;
extern (C++) static __gshared Type timaginary32;
extern (C++) static __gshared Type timaginary64;
extern (C++) static __gshared Type timaginary80;
extern (C++) static __gshared Type tcomplex32;
extern (C++) static __gshared Type tcomplex64;
extern (C++) static __gshared Type tcomplex80;
extern (C++) static __gshared Type tbool;
extern (C++) static __gshared Type tchar;
extern (C++) static __gshared Type twchar;
extern (C++) static __gshared Type tdchar;

extern (C++) static __gshared Type[TMAX] basic;

extern (C++) static __gshared Type tshiftcnt;
extern (C++) static __gshared Type tvoidptr; // void*
extern (C++) static __gshared Type tstring; // immutable(char)[]
extern (C++) static __gshared Type twstring; // immutable(wchar)[]
extern (C++) static __gshared Type tdstring; // immutable(dchar)[]
extern (C++) static __gshared Type tvalist; // va_list alias
extern (C++) static __gshared Type terror; // for error recovery
extern (C++) static __gshared Type tnull; // for null type

extern (C++) static __gshared Type tsize_t; // matches size_t alias
extern (C++) static __gshared Type tptrdiff_t; // matches ptrdiff_t alias
extern (C++) static __gshared Type thash_t; // matches hash_t alias



extern (C++) static __gshared ClassDeclaration dtypeinfo;
extern (C++) static __gshared ClassDeclaration typeinfoclass;
extern (C++) static __gshared ClassDeclaration typeinfointerface;
extern (C++) static __gshared ClassDeclaration typeinfostruct;
extern (C++) static __gshared ClassDeclaration typeinfopointer;
extern (C++) static __gshared ClassDeclaration typeinfoarray;
extern (C++) static __gshared ClassDeclaration typeinfostaticarray;
extern (C++) static __gshared ClassDeclaration typeinfoassociativearray;
extern (C++) static __gshared ClassDeclaration typeinfovector;
extern (C++) static __gshared ClassDeclaration typeinfoenum;
extern (C++) static __gshared ClassDeclaration typeinfofunction;
extern (C++) static __gshared ClassDeclaration typeinfodelegate;
extern (C++) static __gshared ClassDeclaration typeinfotypelist;
extern (C++) static __gshared ClassDeclaration typeinfoconst;
extern (C++) static __gshared ClassDeclaration typeinfoinvariant;
extern (C++) static __gshared ClassDeclaration typeinfoshared;
extern (C++) static __gshared ClassDeclaration typeinfowild;
extern (C++) static __gshared StringTable stringtable;
extern (C++) static __gshared ubyte[TMAX] sizeTy = ()
extern (C++) __gshared Type tvoid;
extern (C++) __gshared Type tint8;
extern (C++) __gshared Type tuns8;
extern (C++) __gshared Type tint16;
extern (C++) __gshared Type tuns16;
extern (C++) __gshared Type tint32;
extern (C++) __gshared Type tuns32;
extern (C++) __gshared Type tint64;
extern (C++) __gshared Type tuns64;
extern (C++) __gshared Type tint128;
extern (C++) __gshared Type tuns128;
extern (C++) __gshared Type tfloat32;
extern (C++) __gshared Type tfloat64;
extern (C++) __gshared Type tfloat80;
extern (C++) __gshared Type timaginary32;
extern (C++) __gshared Type timaginary64;
extern (C++) __gshared Type timaginary80;
extern (C++) __gshared Type tcomplex32;
extern (C++) __gshared Type tcomplex64;
extern (C++) __gshared Type tcomplex80;
extern (C++) __gshared Type tbool;
extern (C++) __gshared Type tchar;
extern (C++) __gshared Type twchar;
extern (C++) __gshared Type tdchar;

extern (C++) __gshared Type[TMAX] basic;

extern (C++) __gshared Type tshiftcnt;
extern (C++) __gshared Type tvoidptr; // void*
extern (C++) __gshared Type tstring; // immutable(char)[]
extern (C++) __gshared Type twstring; // immutable(wchar)[]
extern (C++) __gshared Type tdstring; // immutable(dchar)[]
extern (C++) __gshared Type tvalist; // va_list alias
extern (C++) __gshared Type terror; // for error recovery
extern (C++) __gshared Type tnull; // for null type

extern (C++) __gshared Type tsize_t; // matches size_t alias
extern (C++) __gshared Type tptrdiff_t; // matches ptrdiff_t alias
extern (C++) __gshared Type thash_t; // matches hash_t alias



extern (C++) __gshared ClassDeclaration dtypeinfo;
extern (C++) __gshared ClassDeclaration typeinfoclass;
extern (C++) __gshared ClassDeclaration typeinfointerface;
extern (C++) __gshared ClassDeclaration typeinfostruct;
extern (C++) __gshared ClassDeclaration typeinfopointer;
extern (C++) __gshared ClassDeclaration typeinfoarray;
extern (C++) __gshared ClassDeclaration typeinfostaticarray;
extern (C++) __gshared ClassDeclaration typeinfoassociativearray;
extern (C++) __gshared ClassDeclaration typeinfovector;
extern (C++) __gshared ClassDeclaration typeinfoenum;
extern (C++) __gshared ClassDeclaration typeinfofunction;
extern (C++) __gshared ClassDeclaration typeinfodelegate;
extern (C++) __gshared ClassDeclaration typeinfotypelist;
extern (C++) __gshared ClassDeclaration typeinfoconst;
extern (C++) __gshared ClassDeclaration typeinfoinvariant;
extern (C++) __gshared ClassDeclaration typeinfoshared;
extern (C++) __gshared ClassDeclaration typeinfowild;
extern (C++) __gshared StringTable stringtable;
extern (C++) __gshared ubyte[TMAX] sizeTy = ()
{
ubyte[TMAX] sizeTy = __traits(classInstanceSize, TypeBasic);
sizeTy[Tsarray] = __traits(classInstanceSize, TypeSArray);
Expand Down Expand Up @@ -2666,7 +2666,7 @@ struct ASTBase
stringtable._init(14000);

// Set basic types
static __gshared TY* basetab =
__gshared TY* basetab =
[
Tvoid,
Tint8,
Expand Down Expand Up @@ -6236,7 +6236,7 @@ struct ASTBase
const(char)* id;
}

static __gshared SCstring* table =
__gshared SCstring* table =
[
SCstring(STC.auto_, TOK.auto_),
SCstring(STC.scope_, TOK.scope_),
Expand Down Expand Up @@ -6314,7 +6314,7 @@ struct ASTBase

struct Target
{
extern (C++) static __gshared int ptrsize;
extern (C++) __gshared int ptrsize;

extern (C++) static Type va_listType()
{
Expand Down
9 changes: 4 additions & 5 deletions src/dmd/backend/blockopt.d
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ private void blreturn()
}
continue;
}
L1: ;
L1:
}
if (b.Belem)
{ /* Split b into a goto and a b */
Expand Down Expand Up @@ -1748,7 +1748,7 @@ private void bltailmerge()
} while (el_match(e,en));
}
}
nextb: ;
nextb:
}

/* Recombine elem lists into expression trees */
Expand Down Expand Up @@ -1815,11 +1815,11 @@ private void brmin()
go.changes++;
break;

L2: ;
L2:
}


L1: ;
L1:
}
}

Expand Down Expand Up @@ -2107,7 +2107,6 @@ void funcsideeffects()

Lside:
//printf(" function '%s' has side effects\n",funcsym_p.Sident);
;
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/dmd/backend/cgelem.d
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,6 @@ private elem *elor(elem *e, goal_t goal)
}
}
L1:
;

if (OPTIMIZER)
{
Expand Down Expand Up @@ -1754,7 +1753,7 @@ private elem *elor(elem *e, goal_t goal)
return e;
}

L2: ;
L2:
}

return elbitwise(e, goal);
Expand Down Expand Up @@ -3618,7 +3617,7 @@ static if (0)
e2.Eoper = OPxor;
return optelem(e,GOALvalue);

L8: ;
L8:
}

// Replace (a=(r1 pair r2)) with (a1=r1), (a2=r2)
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/backend/cgreg.d
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ static if (0 && TARGET_LINUX)
u.reglsw = reg;
u.regmsw = regmsw;
}
Ltried: ;
Ltried:
}

if (u.benefit > t.benefit)
Expand Down
Loading