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
+39 -18
View File
@@ -11,28 +11,11 @@ cc_binary(
srcs = ["main.cpp"],
deps = [
":fn_inserter",
":var_decl",
"@llvm-project//clang:tooling",
],
)
cc_library(
name = "fn_inserter",
srcs = ["fn_inserter.cpp"],
hdrs = ["fn_inserter.h"],
deps = [":matcher"],
)
cc_test(
name = "fn_inserter_test",
srcs = ["fn_inserter_test.cpp"],
deps = [
":fn_inserter",
":matcher_test_base",
"@llvm-project//clang:tooling",
"@llvm-project//llvm:gtest_main",
],
)
cc_library(
name = "matcher",
srcs = ["matcher.cpp"],
@@ -55,3 +38,41 @@ cc_library(
"@llvm-project//llvm:gtest",
],
)
# Individual matchers
cc_library(
name = "fn_inserter",
srcs = ["fn_inserter.cpp"],
hdrs = ["fn_inserter.h"],
deps = [":matcher"],
)
cc_test(
name = "fn_inserter_test",
srcs = ["fn_inserter_test.cpp"],
deps = [
":fn_inserter",
":matcher_test_base",
"@llvm-project//clang:tooling",
"@llvm-project//llvm:gtest_main",
],
)
cc_library(
name = "var_decl",
srcs = ["var_decl.cpp"],
hdrs = ["var_decl.h"],
deps = [":matcher"],
)
cc_test(
name = "var_decl_test",
srcs = ["var_decl_test.cpp"],
deps = [
":matcher_test_base",
":var_decl",
"@llvm-project//clang:tooling",
"@llvm-project//llvm:gtest_main",
],
)