From b292799a0700297ac438ca372d3c71e4e17546e0 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Tue, 19 Aug 2014 20:50:57 +0000 Subject: [PATCH] ASM style checker improvements --- analysis/asm_style.d | 4 +++- astprinter.d | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/analysis/asm_style.d b/analysis/asm_style.d index 5e23553..24c3a81 100644 --- a/analysis/asm_style.d +++ b/analysis/asm_style.d @@ -26,7 +26,8 @@ class AsmStyleCheck : BaseAnalyzer override void visit(const AsmBrExp brExp) { - if (brExp.asmBrExp !is null) + if (brExp.asmBrExp !is null && brExp.asmBrExp.asmUnaExp !is null + && brExp.asmBrExp.asmUnaExp.asmPrimaryExp !is null) { addErrorMessage(brExp.line, brExp.column, "This is confusing because it looks like an array index. Rewrite a[1] as [a + 1] to clarify."); @@ -46,6 +47,7 @@ unittest asm { mov a, someArray[1]; // [warn]: This is confusing because it looks like an array index. Rewrite a[1] as [a + 1] to clarify. + add near ptr [EAX], 3; } } }c, sac); diff --git a/astprinter.d b/astprinter.d index fb222e6..43747f3 100644 --- a/astprinter.d +++ b/astprinter.d @@ -1045,6 +1045,7 @@ class XMLPrinter : ASTVisitor override void visit(const PragmaDeclaration pragmaDeclaration) { mixin (tagAndAccept!"pragmaDeclaration"); } override void visit(const PragmaExpression pragmaExpression) { mixin (tagAndAccept!"pragmaExpression"); } override void visit(const PrimaryExpression primaryExpression) { mixin (tagAndAccept!"primaryExpression"); } + override void visit(const Register register) { mixin (tagAndAccept!"register"); } override void visit(const ScopeGuardStatement scopeGuardStatement) { mixin (tagAndAccept!"scopeGuardStatement"); } override void visit(const SharedStaticConstructor sharedStaticConstructor) { mixin (tagAndAccept!"sharedStaticConstructor"); } override void visit(const SharedStaticDestructor sharedStaticDestructor) { mixin (tagAndAccept!"sharedStaticDestructor"); }