From f1e3b77d428d53d3c8efaeb77e7ab5d68a082fc0 Mon Sep 17 00:00:00 2001 From: Vladiwostok <55026261+Vladiwostok@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:46:04 +0200 Subject: [PATCH] Update dmd to latest version (02d6d07a69280f8cc88380a682717bb67ca485fb) & fix checks using parens (#90) * Update dmd module * Fix checks using Expreesion.parens * Update windows build --- build.bat | 2 -- dmd | 2 +- dub.json | 2 +- makefile | 6 ++---- src/dscanner/analysis/logic_precedence.d | 23 +++++++++-------------- src/dscanner/analysis/redundant_parens.d | 20 +++++++------------- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/build.bat b/build.bat index 69b67c5..9747453 100644 --- a/build.bat +++ b/build.bat @@ -35,9 +35,7 @@ set DMD_FRONTEND_DENYLIST=^ dmd\compiler\src\dmd\e2ir.d^ dmd\compiler\src\dmd\eh.d^ dmd\compiler\src\dmd\glue.d^ - dmd\compiler\src\dmd\iasm.d^ dmd\compiler\src\dmd\iasmdmd.d^ - dmd\compiler\src\dmd\iasmgcc.d^ dmd\compiler\src\dmd\irstate.d^ dmd\compiler\src\dmd\lib.d^ dmd\compiler\src\dmd\libelf.d^ diff --git a/dmd b/dmd index 8548189..02d6d07 160000 --- a/dmd +++ b/dmd @@ -1 +1 @@ -Subproject commit 85481894447684c107347e21d405f8f6b34b2369 +Subproject commit 02d6d07a69280f8cc88380a682717bb67ca485fb diff --git a/dub.json b/dub.json index cfc28a1..89c4dc3 100644 --- a/dub.json +++ b/dub.json @@ -18,7 +18,7 @@ "libddoc": "~>0.8.0", "dmd": { "repository": "git+https://github.com/dlang/dmd.git", - "version": "85481894447684c107347e21d405f8f6b34b2369" + "version": "02d6d07a69280f8cc88380a682717bb67ca485fb" } }, "targetPath" : "bin", diff --git a/makefile b/makefile index 8b3c122..17a413e 100644 --- a/makefile +++ b/makefile @@ -20,9 +20,7 @@ DMD_FRONTEND_SRC := \ ! -name "e2ir.d" \ ! -name "eh.d" \ ! -name "glue.d" \ - ! -name "iasm.d" \ ! -name "iasmdmd.d" \ - ! -name "iasmgcc.d" \ ! -name "irstate.d" \ ! -name "lib.d" \ ! -name "libelf.d" \ @@ -42,8 +40,8 @@ DMD_FRONTEND_SRC := \ ! -name "todt.d" \ ! -name "toir.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/backend -name "*.d") \ +# $(shell find dmd/compiler/src/dmd -maxdepth 1 -name "*.d" ! -name "mars.d" ) DMD_LEXER_SRC := \ dmd/compiler/src/dmd/console.d \ diff --git a/src/dscanner/analysis/logic_precedence.d b/src/dscanner/analysis/logic_precedence.d index 3fb968b..ec0871c 100644 --- a/src/dscanner/analysis/logic_precedence.d +++ b/src/dscanner/analysis/logic_precedence.d @@ -15,13 +15,13 @@ import dscanner.analysis.helpers; * if (a && (b || c)) // good * --- */ -extern(C++) class LogicPrecedenceCheck(AST) : BaseAnalyzerDmd +extern (C++) class LogicPrecedenceCheck(AST) : BaseAnalyzerDmd { enum string KEY = "dscanner.confusing.logical_precedence"; mixin AnalyzerInfo!"logical_precedence_check"; alias visit = BaseAnalyzerDmd.visit; - extern(D) this(string fileName, bool skipTests = false) + extern (D) this(string fileName, bool skipTests = false) { super(fileName, skipTests); } @@ -43,25 +43,21 @@ extern(C++) class LogicPrecedenceCheck(AST) : BaseAnalyzerDmd if (!left && !right) goto END; - - // TODO: fix - //if ((left && left.parens) || (right && right.parens)) - //goto END; + + if ((left && left.parens) || (right && right.parens)) + goto END; if ((left !is null && left.e2 is null) && (right !is null && right.e2 is null)) goto END; - // TODO: fixme - //addErrorMessage(cast(ulong) le.loc.linnum, cast(ulong) le.loc.charnum, KEY, - //"Use parenthesis to clarify this expression."); - -END: + addErrorMessage(cast(ulong) le.loc.linnum, cast(ulong) le.loc.charnum, + KEY, "Use parenthesis to clarify this expression."); + + END: super.visit(le); } } -/* -TODO: fixme unittest { import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig; @@ -80,4 +76,3 @@ unittest }c, sac); stderr.writeln("Unittest for LogicPrecedenceCheck passed."); } -*/ diff --git a/src/dscanner/analysis/redundant_parens.d b/src/dscanner/analysis/redundant_parens.d index 516fc4c..a0863c5 100644 --- a/src/dscanner/analysis/redundant_parens.d +++ b/src/dscanner/analysis/redundant_parens.d @@ -7,26 +7,24 @@ module dscanner.analysis.redundant_parens; import dscanner.analysis.base; -// TODO: check and fix /** * Checks for redundant parenthesis */ -extern(C++) class RedundantParenCheck(AST) : BaseAnalyzerDmd +extern (C++) class RedundantParenCheck(AST) : BaseAnalyzerDmd { alias visit = BaseAnalyzerDmd.visit; mixin AnalyzerInfo!"redundant_parens_check"; /// - extern(D) this(string fileName, bool skipTests = false) + extern (D) this(string fileName, bool skipTests = false) { super(fileName, skipTests); } override void visit(AST.IfStatement s) { - //if (s.condition.parens) - //addErrorMessage(cast(ulong) s.loc.linnum, cast(ulong) s.loc.charnum, - //KEY, MESSAGE); + if (s.condition.parens) + addErrorMessage(cast(ulong) s.loc.linnum, cast(ulong) s.loc.charnum, KEY, MESSAGE); } private: @@ -34,18 +32,16 @@ private: enum string MESSAGE = "Redundant parenthesis."; } -/* -TODO: check and fix unittest { import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig; + import dscanner.analysis.helpers : assertAnalyzerWarningsDMD; import std.stdio : stderr; - import dscanner.analysis.helpers : assertAnalyzerWarnings = assertAnalyzerWarningsDMD; StaticAnalysisConfig sac = disabledConfig(); sac.redundant_parens_check = Check.enabled; - assertAnalyzerWarnings(q{ + assertAnalyzerWarningsDMD(q{ void testRedundantParens() { int a = 0; @@ -54,7 +50,7 @@ unittest if ((a + 2 == 3)) // [warn]: Redundant parenthesis. { - } + } if ((b)) // [warn]: Redundant parenthesis. { @@ -68,6 +64,4 @@ unittest }c, sac); stderr.writeln("Unittest for RedundantParenthesis passed."); - } -*/