Update dmd to latest version (02d6d07a69280f8cc88380a682717bb67ca485fb) & fix checks using parens (#90)

* Update dmd module

* Fix checks using Expreesion.parens

* Update windows build
This commit is contained in:
Vladiwostok 2024-03-05 10:46:04 +02:00 committed by Vladiwostok
parent 24f7754fef
commit 860ddf1994
6 changed files with 20 additions and 35 deletions

View file

@ -35,9 +35,7 @@ set DMD_FRONTEND_DENYLIST=^
dmd\compiler\src\dmd\e2ir.d^ dmd\compiler\src\dmd\e2ir.d^
dmd\compiler\src\dmd\eh.d^ dmd\compiler\src\dmd\eh.d^
dmd\compiler\src\dmd\glue.d^ dmd\compiler\src\dmd\glue.d^
dmd\compiler\src\dmd\iasm.d^
dmd\compiler\src\dmd\iasmdmd.d^ dmd\compiler\src\dmd\iasmdmd.d^
dmd\compiler\src\dmd\iasmgcc.d^
dmd\compiler\src\dmd\irstate.d^ dmd\compiler\src\dmd\irstate.d^
dmd\compiler\src\dmd\lib.d^ dmd\compiler\src\dmd\lib.d^
dmd\compiler\src\dmd\libelf.d^ dmd\compiler\src\dmd\libelf.d^

2
dmd

@ -1 +1 @@
Subproject commit 85481894447684c107347e21d405f8f6b34b2369 Subproject commit 02d6d07a69280f8cc88380a682717bb67ca485fb

View file

@ -18,7 +18,7 @@
"libddoc": "~>0.8.0", "libddoc": "~>0.8.0",
"dmd": { "dmd": {
"repository": "git+https://github.com/dlang/dmd.git", "repository": "git+https://github.com/dlang/dmd.git",
"version": "85481894447684c107347e21d405f8f6b34b2369" "version": "02d6d07a69280f8cc88380a682717bb67ca485fb"
} }
}, },
"targetPath" : "bin", "targetPath" : "bin",

View file

@ -20,9 +20,7 @@ DMD_FRONTEND_SRC := \
! -name "e2ir.d" \ ! -name "e2ir.d" \
! -name "eh.d" \ ! -name "eh.d" \
! -name "glue.d" \ ! -name "glue.d" \
! -name "iasm.d" \
! -name "iasmdmd.d" \ ! -name "iasmdmd.d" \
! -name "iasmgcc.d" \
! -name "irstate.d" \ ! -name "irstate.d" \
! -name "lib.d" \ ! -name "lib.d" \
! -name "libelf.d" \ ! -name "libelf.d" \
@ -42,8 +40,8 @@ DMD_FRONTEND_SRC := \
! -name "todt.d" \ ! -name "todt.d" \
! -name "toir.d" \ ! -name "toir.d" \
) )
#$(shell find dmd/compiler/src/dmd/backend -name "*.d")\ # $(shell find dmd/compiler/src/dmd/backend -name "*.d") \
#$(shell find dmd/compiler/src/dmd -maxdepth 1 -name "*.d" ! -name "mars.d" ) # $(shell find dmd/compiler/src/dmd -maxdepth 1 -name "*.d" ! -name "mars.d" )
DMD_LEXER_SRC := \ DMD_LEXER_SRC := \
dmd/compiler/src/dmd/console.d \ dmd/compiler/src/dmd/console.d \

View file

@ -15,13 +15,13 @@ import dscanner.analysis.helpers;
* if (a && (b || c)) // good * if (a && (b || c)) // good
* --- * ---
*/ */
extern(C++) class LogicPrecedenceCheck(AST) : BaseAnalyzerDmd extern (C++) class LogicPrecedenceCheck(AST) : BaseAnalyzerDmd
{ {
enum string KEY = "dscanner.confusing.logical_precedence"; enum string KEY = "dscanner.confusing.logical_precedence";
mixin AnalyzerInfo!"logical_precedence_check"; mixin AnalyzerInfo!"logical_precedence_check";
alias visit = BaseAnalyzerDmd.visit; alias visit = BaseAnalyzerDmd.visit;
extern(D) this(string fileName, bool skipTests = false) extern (D) this(string fileName, bool skipTests = false)
{ {
super(fileName, skipTests); super(fileName, skipTests);
} }
@ -43,25 +43,21 @@ extern(C++) class LogicPrecedenceCheck(AST) : BaseAnalyzerDmd
if (!left && !right) if (!left && !right)
goto END; goto END;
// TODO: fix if ((left && left.parens) || (right && right.parens))
//if ((left && left.parens) || (right && right.parens)) goto END;
//goto END;
if ((left !is null && left.e2 is null) && (right !is null && right.e2 is null)) if ((left !is null && left.e2 is null) && (right !is null && right.e2 is null))
goto END; goto END;
// TODO: fixme addErrorMessage(cast(ulong) le.loc.linnum, cast(ulong) le.loc.charnum,
//addErrorMessage(cast(ulong) le.loc.linnum, cast(ulong) le.loc.charnum, KEY, KEY, "Use parenthesis to clarify this expression.");
//"Use parenthesis to clarify this expression.");
END:
END:
super.visit(le); super.visit(le);
} }
} }
/*
TODO: fixme
unittest unittest
{ {
import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig; import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig;
@ -80,4 +76,3 @@ unittest
}c, sac); }c, sac);
stderr.writeln("Unittest for LogicPrecedenceCheck passed."); stderr.writeln("Unittest for LogicPrecedenceCheck passed.");
} }
*/

View file

@ -7,26 +7,24 @@ module dscanner.analysis.redundant_parens;
import dscanner.analysis.base; import dscanner.analysis.base;
// TODO: check and fix
/** /**
* Checks for redundant parenthesis * Checks for redundant parenthesis
*/ */
extern(C++) class RedundantParenCheck(AST) : BaseAnalyzerDmd extern (C++) class RedundantParenCheck(AST) : BaseAnalyzerDmd
{ {
alias visit = BaseAnalyzerDmd.visit; alias visit = BaseAnalyzerDmd.visit;
mixin AnalyzerInfo!"redundant_parens_check"; mixin AnalyzerInfo!"redundant_parens_check";
/// ///
extern(D) this(string fileName, bool skipTests = false) extern (D) this(string fileName, bool skipTests = false)
{ {
super(fileName, skipTests); super(fileName, skipTests);
} }
override void visit(AST.IfStatement s) override void visit(AST.IfStatement s)
{ {
//if (s.condition.parens) if (s.condition.parens)
//addErrorMessage(cast(ulong) s.loc.linnum, cast(ulong) s.loc.charnum, addErrorMessage(cast(ulong) s.loc.linnum, cast(ulong) s.loc.charnum, KEY, MESSAGE);
//KEY, MESSAGE);
} }
private: private:
@ -34,18 +32,16 @@ private:
enum string MESSAGE = "Redundant parenthesis."; enum string MESSAGE = "Redundant parenthesis.";
} }
/*
TODO: check and fix
unittest unittest
{ {
import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig; import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig;
import dscanner.analysis.helpers : assertAnalyzerWarningsDMD;
import std.stdio : stderr; import std.stdio : stderr;
import dscanner.analysis.helpers : assertAnalyzerWarnings = assertAnalyzerWarningsDMD;
StaticAnalysisConfig sac = disabledConfig(); StaticAnalysisConfig sac = disabledConfig();
sac.redundant_parens_check = Check.enabled; sac.redundant_parens_check = Check.enabled;
assertAnalyzerWarnings(q{ assertAnalyzerWarningsDMD(q{
void testRedundantParens() void testRedundantParens()
{ {
int a = 0; int a = 0;
@ -54,7 +50,7 @@ unittest
if ((a + 2 == 3)) // [warn]: Redundant parenthesis. if ((a + 2 == 3)) // [warn]: Redundant parenthesis.
{ {
} }
if ((b)) // [warn]: Redundant parenthesis. if ((b)) // [warn]: Redundant parenthesis.
{ {
@ -68,6 +64,4 @@ unittest
}c, sac); }c, sac);
stderr.writeln("Unittest for RedundantParenthesis passed."); stderr.writeln("Unittest for RedundantParenthesis passed.");
} }
*/