-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when z3 is missing and add transform error reporting
- Loading branch information
1 parent
dbca946
commit 395a2f8
Showing
2 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
"""Patch to add transforms for setting type constraints and creating control flow graphs. | ||
""" | ||
|
||
import logging | ||
|
||
from pylint.lint import PyLinter | ||
|
||
from ..cfg.visitor import CFGVisitor | ||
from ..transforms.z3_visitor import Z3Visitor | ||
|
||
|
||
def patch_ast_transforms(z3: bool): | ||
old_get_ast = PyLinter.get_ast | ||
|
||
def new_get_ast(self, filepath, modname, data): | ||
ast = old_get_ast(self, filepath, modname, data) | ||
if ast is not None: | ||
if ast is None: | ||
return None | ||
|
||
# Run the Z3Visitor | ||
if z3: | ||
try: | ||
if z3: | ||
ast = Z3Visitor().visitor.visit(ast) | ||
ast.accept(CFGVisitor()) | ||
except: | ||
pass | ||
from ..transforms.z3_visitor import Z3Visitor | ||
|
||
ast = Z3Visitor().visitor.visit(ast) | ||
except Exception as e: | ||
logging.warning(f"Could not run Z3Visitor: {e}") | ||
|
||
# Run the CFGVisitor | ||
try: | ||
ast.accept(CFGVisitor()) | ||
except Exception as e: | ||
logging.warning(f"Could not run Z3Visitor: {e}") | ||
|
||
return ast | ||
|
||
PyLinter.get_ast = new_get_ast |