This is the first change as part of developing a clang-query based search and replace tool.
Details
- Reviewers
klimek ioeric jbangert bkramer sbenza - Commits
- rGfc9213e0e518: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks
rC302624: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks
rL302624: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks
Diff Detail
- Build Status
Buildable 6257 Build 6257: arc lint + arc unit
Event Timeline
lib/Tooling/RefactoringCallbacks.cpp | ||
---|---|---|
45 | Could you add a comment here explaining why the replacements in callbacks need to be cleared? | |
258 | Just use if since there is a continue? | |
263 | You might want to use llvm_unreachable instead so that it also bails out in non-assertion build. | |
304 | Looks like you are using clang-format with Google-style. Please reformat your changes with LLVM style. |
include/clang/Tooling/RefactoringCallbacks.h | ||
---|---|---|
61 | Why emplace_back instead of push_back? | |
lib/Tooling/RefactoringCallbacks.cpp | ||
253 | We should do the parsing in the constructor, instead of on each match. | |
267 | This is making two lookups into the map when one is enough. | |
285 | X += instead of X = X + |
Thank you for the initial feedback!
include/clang/Tooling/RefactoringCallbacks.h | ||
---|---|---|
61 | Changed to push_back. Is there ever an advantage to using push_back over emplace_back (the latter falls back to a copy constructor). |
Fixed the test -- I am still getting used to the different ninja test targets.
lib/Tooling/RefactoringCallbacks.cpp | ||
---|---|---|
160 | Now it is. |
Looks good. Could you also add test cases where ReplaceNodeWithTemplate::create fails to parse templates?
include/clang/Tooling/RefactoringCallbacks.h | ||
---|---|---|
61 | push_back and emplace_back are equivalent when the value you are passing is already a T. std::vector<std::vector<int>> v; ... many lines below ... v.push_back(1); // fails v.emplace_back(1); // works, but it didn't add a 1 to the vector. |
lib/Tooling/RefactoringCallbacks.cpp | ||
---|---|---|
213 | I don't know if stderr is the best place for this error output. | |
214 | I don't think this is ok. | |
227 | Same as above. This error can be triggered from user input. |
lib/Tooling/RefactoringCallbacks.cpp | ||
---|---|---|
213 | There's a FIXME: above that addresses the need for better error handling, and this one just duplicated their workaround. | |
214 | Using llvm::report_fatal_error for now. See the above for better error handling. |
unittests/Tooling/RefactoringCallbacksTest.cpp | ||
---|---|---|
101 | ninja check-clang-tools works. |
Still LGTM. Please run ninja check-clang and fix the warning. I'll land this patch for you afterwards.
lib/Tooling/RefactoringCallbacks.cpp | ||
---|---|---|
222 | ninja check-clang RefactoringCallbacks.cpp:222:5: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default] Please remove the default. |
Why emplace_back instead of push_back?