[PATCH] D51261: Add preload option to clang-query
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 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> 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); 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 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> 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); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51261: Add preload option to clang-query
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. LG Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51261 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51261: Add preload option to clang-query
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 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> 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); 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 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> 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); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits