Start handling variable declarations (#571)

TODOs in the test for known issues.

I may switch the approach to getting the variable type (on examination, this isn't working quite as well as I'd thought) but for now I think it's okay. I had an earlier approach though that may work better overall -- I'd been thinking this would work better, but as you can see in the null check for type information, I think I missed a key point.

Anyways, what'd really been vexing me was `int i, j` which I think I handle passably well now. There's obviously room for improvement, but given I've been going at this for a couple days now, I thought it best to checkpoint where I was.

This also includes some related framework changes to fix bumps I was running into. Overall the tool should operate a bit more smoothly with these changes. There are still issues with overlapping replacements, but I think it's primarily with range-based for loops which I just need to take some time to fix.
This commit is contained in:
Jon Meow
2021-06-23 10:58:32 -07:00
committed by GitHub
parent b897e9e38b
commit 2344a52e24
38 changed files with 1103 additions and 952 deletions
+12 -7
View File
@@ -37,11 +37,15 @@ class _Workflow(object):
def run(self):
"""Runs the migration workflow."""
self._gather_files()
self._clang_tidy()
self._cpp_refactoring()
self._rename_files()
self._print_header("Done!")
try:
self._gather_files()
self._clang_tidy()
self._cpp_refactoring()
self._rename_files()
self._print_header("Done!")
except subprocess.CalledProcessError as e:
# Discard the stack for subprocess errors.
sys.exit(e)
def _data_file(self, relative_path):
"""Returns the path to a data file."""
@@ -75,14 +79,15 @@ class _Workflow(object):
with open(self._data_file("clang_tidy.yaml")) as f:
config = f.read()
subprocess.run(
["clang-tidy", "--fix", "--config", config] + self._cpp_files
["clang-tidy", "--fix", "--config", config] + self._cpp_files,
check=True,
)
def _cpp_refactoring(self):
"""Runs cpp_refactoring to migrate C++ files towards Carbon syntax."""
self._print_header("Running cpp_refactoring...")
cpp_refactoring = self._data_file(_CPP_REFACTORING)
subprocess.run([cpp_refactoring] + self._cpp_files)
subprocess.run([cpp_refactoring] + self._cpp_files, check=True)
def _rename_files(self):
"""Renames C++ files to the destination Carbon filenames."""