diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2014-02-01 01:42:42 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2014-02-01 01:42:42 +0000 |
| commit | c31176da0265ee3b47c76e3a6af8273d5dd26561 (patch) | |
| tree | b93abd9b3cd46d6f04f3364ed44ebd9e395b7bc2 | |
| parent | a04504fe978140a2ef7fc4651f376d2653bee6f1 (diff) | |
| download | bcm5719-llvm-c31176da0265ee3b47c76e3a6af8273d5dd26561.tar.gz bcm5719-llvm-c31176da0265ee3b47c76e3a6af8273d5dd26561.zip | |
Switch clang-query to use the lineeditor library.
Differential Revision: http://llvm-reviews.chandlerc.com/D2262
llvm-svn: 200603
| -rw-r--r-- | clang-tools-extra/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | clang-tools-extra/clang-query/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | clang-tools-extra/clang-query/tool/ClangQuery.cpp | 32 |
3 files changed, 6 insertions, 32 deletions
diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 02ca7c0065e..a0d5e2eeecc 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -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) diff --git a/clang-tools-extra/clang-query/CMakeLists.txt b/clang-tools-extra/clang-query/CMakeLists.txt index ae748369f13..0fb8c3c24d0 100644 --- a/clang-tools-extra/clang-query/CMakeLists.txt +++ b/clang-tools-extra/clang-query/CMakeLists.txt @@ -1,5 +1,6 @@ set(LLVM_LINK_COMPONENTS - Support + lineeditor + support ) add_clang_library(clangQuery diff --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp b/clang-tools-extra/clang-query/tool/ClangQuery.cpp index bac86b0c372..0150d416064 100644 --- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp +++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp @@ -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::Positional, 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); |

