[PATCH] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments
Alexander Shaposhnikov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 11 22:51:32 PST 2016
alexshap created this revision.
alexshap added reviewers: hokein, klimek.
alexshap added a subscriber: cfe-commits.
alexshap set the repository for this revision to rL LLVM.
1. Remove some boilerplate plate code for appending -fparse-all-comments to the list of arguments.
2. Run clang-format -i against ClangMoveMain.cpp
Test plan:
make check-all + test locally
Repository:
rL LLVM
https://reviews.llvm.org/D27669
Files:
clang-move/tool/ClangMoveMain.cpp
Index: clang-move/tool/ClangMoveMain.cpp
===================================================================
--- clang-move/tool/ClangMoveMain.cpp
+++ clang-move/tool/ClangMoveMain.cpp
@@ -61,19 +61,19 @@
NewCC("new_cc", cl::desc("The relative/absolute file path of new cc."),
cl::cat(ClangMoveCategory));
-cl::opt<bool> OldDependOnNew(
- "old_depend_on_new",
- cl::desc(
- "Whether old header will depend on new header. If true, clang-move will "
- "add #include of new header to old header."),
- cl::init(false), cl::cat(ClangMoveCategory));
-
-cl::opt<bool> NewDependOnOld(
- "new_depend_on_old",
- cl::desc(
- "Whether new header will depend on old header. If true, clang-move will "
- "add #include of old header to new header."),
- cl::init(false), cl::cat(ClangMoveCategory));
+cl::opt<bool>
+ OldDependOnNew("old_depend_on_new",
+ cl::desc("Whether old header will depend on new header. If "
+ "true, clang-move will "
+ "add #include of new header to old header."),
+ cl::init(false), cl::cat(ClangMoveCategory));
+
+cl::opt<bool>
+ NewDependOnOld("new_depend_on_old",
+ cl::desc("Whether new header will depend on old header. If "
+ "true, clang-move will "
+ "add #include of old header to new header."),
+ cl::init(false), cl::cat(ClangMoveCategory));
cl::opt<std::string>
Style("style",
@@ -95,18 +95,7 @@
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
- // Add "-fparse-all-comments" compile option to make clang parse all comments,
- // otherwise, ordinary comments like "//" and "/*" won't get parsed (This is
- // a bit of hacky).
- std::vector<std::string> ExtraArgs(argv, argv + argc);
- ExtraArgs.insert(ExtraArgs.begin() + 1, "-extra-arg=-fparse-all-comments");
- std::unique_ptr<const char *[]> RawExtraArgs(
- new const char *[ExtraArgs.size()]);
- for (size_t i = 0; i < ExtraArgs.size(); ++i)
- RawExtraArgs[i] = ExtraArgs[i].c_str();
- int Argc = argc + 1;
- tooling::CommonOptionsParser OptionsParser(Argc, RawExtraArgs.get(),
- ClangMoveCategory);
+ tooling::CommonOptionsParser OptionsParser(argc, argv, ClangMoveCategory);
if (OldDependOnNew && NewDependOnOld) {
llvm::errs() << "Provide either --old_depend_on_new or "
@@ -117,6 +106,9 @@
tooling::RefactoringTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
+ // Add "-fparse-all-comments" compile option to make clang parse all comments
+ Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(
+ "-fparse-all-comments", ArgumentInsertPosition::BEGIN));
move::MoveDefinitionSpec Spec;
Spec.Names = {Names.begin(), Names.end()};
Spec.OldHeader = OldHeader;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27669.81052.patch
Type: text/x-patch
Size: 3010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161212/71363b2e/attachment.bin>
More information about the cfe-commits
mailing list