mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 16:41:43 +00:00
Switch clang-query to use the lineeditor library.
Differential Revision: http://llvm-reviews.chandlerc.com/D2262 llvm-svn: 200603
This commit is contained in:
parent
a04504fe97
commit
c31176da02
@ -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)
|
||||
|
@ -1,5 +1,6 @@
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
Support
|
||||
lineeditor
|
||||
support
|
||||
)
|
||||
|
||||
add_clang_library(clangQuery
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user