[PATCH] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-12 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289464: [clang-move] Use appendArgumentsAdjuster for adding 
extra arguments (authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D27669?vs=81052=81124#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27669

Files:
  clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp


Index: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
===
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
+++ clang-tools-extra/trunk/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 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 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
+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
+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
 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 ExtraArgs(argv, argv + argc);
-  ExtraArgs.insert(ExtraArgs.begin() + 1, "-extra-arg=-fparse-all-comments");
-  std::unique_ptr 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;


Index: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
===
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
+++ clang-tools-extra/trunk/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 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 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
+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
+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

[PATCH] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks!




Comment at: clang-move/tool/ClangMoveMain.cpp:109
 OptionsParser.getSourcePathList());
+  // Add "-fparse-all-comments" compile option to make clang parse all comments
+  Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(

Nit: Missing a trailing `.`.


Repository:
  rL LLVM

https://reviews.llvm.org/D27669



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-11 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
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 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 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
+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
+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
 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 ExtraArgs(argv, argv + argc);
-  ExtraArgs.insert(ExtraArgs.begin() + 1, "-extra-arg=-fparse-all-comments");
-  std::unique_ptr 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;


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 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 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
+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
+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
 Style("style",
@@ -95,18 +95,7 @@
 
 int main(int argc, const char **argv)