[PATCH] D51261: Add preload option to clang-query
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 25 09:18:48 PDT 2018
steveire created this revision.
Herald added a subscriber: cfe-commits.
This allows loading a file with pre-defined let commands for example.
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));
+
int 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 err;
}
} else {
+ if (!PreloadFile.empty()) {
+ if (auto err = runCommandsInFile(argv[0], PreloadFile, QS))
+ return err;
+ }
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.162555.patch
Type: text/x-patch
Size: 1401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180825/24dedf55/attachment.bin>
More information about the cfe-commits
mailing list