[clang-tools-extra] r200603 - Switch clang-query to use the lineeditor library.
Peter Collingbourne
peter at pcc.me.uk
Fri Jan 31 17:42:42 PST 2014
Author: pcc
Date: Fri Jan 31 19:42:42 2014
New Revision: 200603
URL: http://llvm.org/viewvc/llvm-project?rev=200603&view=rev
Log:
Switch clang-query to use the lineeditor library.
Differential Revision: http://llvm-reviews.chandlerc.com/D2262
Modified:
clang-tools-extra/trunk/CMakeLists.txt
clang-tools-extra/trunk/clang-query/CMakeLists.txt
clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=200603&r1=200602&r2=200603&view=diff
==============================================================================
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Fri Jan 31 19:42:42 2014
@@ -1,6 +1,3 @@
-include(CheckLibraryExists)
-check_library_exists(edit el_init "" HAVE_LIBEDIT)
-
add_subdirectory(clang-apply-replacements)
add_subdirectory(clang-modernize)
add_subdirectory(clang-query)
Modified: clang-tools-extra/trunk/clang-query/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/CMakeLists.txt?rev=200603&r1=200602&r2=200603&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-query/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-query/CMakeLists.txt Fri Jan 31 19:42:42 2014
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
- Support
+ lineeditor
+ support
)
add_clang_library(clangQuery
Modified: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp?rev=200603&r1=200602&r2=200603&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp (original)
+++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp Fri Jan 31 19:42:42 2014
@@ -33,11 +33,11 @@
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/LineEditor/LineEditor.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Signals.h"
#include <fstream>
-#include <histedit.h>
#include <string>
using namespace clang;
@@ -61,11 +61,6 @@ static cl::list<std::string> SourcePaths
cl::desc("<source0> [... <sourceN>]"),
cl::OneOrMore);
-static char *ReturnPrompt(EditLine *EL) {
- static char Prompt[] = "clang-query> ";
- return Prompt;
-}
-
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
cl::ParseCommandLineOptions(argc, argv);
@@ -124,30 +119,11 @@ int main(int argc, const char **argv) {
}
}
} else {
- History *Hist = history_init();
- HistEvent Event;
- history(Hist, &Event, H_SETSIZE, 100);
-
- EditLine *EL = el_init("clang-query", stdin, stdout, stderr);
- el_set(EL, EL_PROMPT, ReturnPrompt);
- el_set(EL, EL_EDITOR, "emacs");
- el_set(EL, EL_HIST, history, Hist);
-
- int Count;
- while (const char *Line = el_gets(EL, &Count)) {
- if (Count == 0)
- break;
-
- history(Hist, &Event, H_ENTER, Line);
-
- QueryRef Q = ParseQuery(Line);
+ LineEditor LE("clang-query");
+ while (llvm::Optional<std::string> Line = LE.readLine()) {
+ QueryRef Q = ParseQuery(*Line);
Q->run(llvm::outs(), QS);
}
-
- history_end(Hist);
- el_end(EL);
-
- llvm::outs() << "\n";
}
llvm::DeleteContainerPointers(ASTs);
More information about the cfe-commits
mailing list