[PATCH] D51261: Add preload option to clang-query

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 30 16:26:49 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE341145: Add preload option to clang-query (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51261?vs=162555&id=163445#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51261

Files:
  clang-query/tool/ClangQuery.cpp


Index: clang-query/tool/ClangQuery.cpp
===================================================================
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,11 @@
                                           cl::value_desc("file"),
                                           cl::cat(ClangQueryCategory));
 
+static cl::opt<std::string> PreloadFile(
+    "preload",
+    cl::desc("Preload commands from file and start interactive mode"),
+    cl::value_desc("file"), cl::cat(ClangQueryCategory));
+
 bool runCommandsInFile(const char *ExeName, std::string const &FileName,
                        QuerySession &QS) {
   std::ifstream Input(FileName.c_str());
@@ -86,6 +91,12 @@
     return 1;
   }
 
+  if ((!Commands.empty() || !CommandFiles.empty()) && !PreloadFile.empty()) {
+    llvm::errs() << argv[0]
+                 << ": cannot specify both -c or -f with --preload\n";
+    return 1;
+  }
+
   ClangTool Tool(OptionsParser.getCompilations(),
                  OptionsParser.getSourcePathList());
   std::vector<std::unique_ptr<ASTUnit>> ASTs;
@@ -106,6 +117,10 @@
         return 1;
     }
   } else {
+    if (!PreloadFile.empty()) {
+      if (runCommandsInFile(argv[0], PreloadFile, QS))
+        return 1;
+    }
     LineEditor LE("clang-query");
     LE.setListCompleter([&QS](StringRef Line, size_t Pos) {
       return QueryParser::complete(Line, Pos, QS);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51261.163445.patch
Type: text/x-patch
Size: 1408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180830/cc17a06d/attachment-0001.bin>


More information about the cfe-commits mailing list