From 5ff2257b12056aa44f99296ee0f4bbdb1a2de183 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 11 May 2017 10:21:59 -0700 Subject: [PATCH] Check for unknown instruction attributes. (#80) * Check for unknown instruction attributes. * Avoid has_key, at flake8's advice. * Use AssertionError instead of RuntimeError, per review request. --- lib/cretonne/meta/cdsl/instructions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cretonne/meta/cdsl/instructions.py b/lib/cretonne/meta/cdsl/instructions.py index a900c95ab6..6724b775ea 100644 --- a/lib/cretonne/meta/cdsl/instructions.py +++ b/lib/cretonne/meta/cdsl/instructions.py @@ -122,6 +122,10 @@ class Instruction(object): i for i, o in enumerate(self.ins) if o.is_immediate()) self._verify_polymorphic() + for attr in kwargs: + if attr not in Instruction.ATTRIBS: + raise AssertionError( + "unknown instruction attribute '" + attr + "'") for attr in Instruction.ATTRIBS: setattr(self, attr, not not kwargs.get(attr, False)) InstructionGroup.append(self)