mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 01:29:52 +00:00
[clang-query] Add 'detailed-ast' output as an alias for 'dump'
Summary: Future development can then dump other content than AST. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53500 llvm-svn: 345193
This commit is contained in:
parent
4c3d7a969a
commit
51707b21a0
@ -53,8 +53,10 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
|
||||
"Pretty-print bound nodes.\n"
|
||||
" diag "
|
||||
"Diagnostic location for bound nodes.\n"
|
||||
" detailed-ast "
|
||||
"Detailed AST output for bound nodes.\n"
|
||||
" dump "
|
||||
"Detailed AST output for bound nodes.\n\n";
|
||||
"Detailed AST output for bound nodes (alias of detailed-ast).\n\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -124,7 +126,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
|
||||
OS << "\n";
|
||||
break;
|
||||
}
|
||||
case OK_Dump: {
|
||||
case OK_DetailedAST: {
|
||||
OS << "Binding for \"" << BI->first << "\":\n";
|
||||
BI->second.dump(OS, AST->getSourceManager());
|
||||
OS << "\n";
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace clang {
|
||||
namespace query {
|
||||
|
||||
enum OutputKind { OK_Diag, OK_Print, OK_Dump };
|
||||
enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
|
||||
|
||||
enum QueryKind {
|
||||
QK_Invalid,
|
||||
|
@ -111,11 +111,13 @@ QueryRef QueryParser::parseSetOutputKind() {
|
||||
unsigned OutKind = LexOrCompleteWord<unsigned>(this, ValStr)
|
||||
.Case("diag", OK_Diag)
|
||||
.Case("print", OK_Print)
|
||||
.Case("dump", OK_Dump)
|
||||
.Case("detailed-ast", OK_DetailedAST)
|
||||
.Case("dump", OK_DetailedAST)
|
||||
.Default(~0u);
|
||||
if (OutKind == ~0u) {
|
||||
return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
|
||||
ValStr + "'");
|
||||
return new InvalidQuery(
|
||||
"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
|
||||
"'");
|
||||
}
|
||||
return new SetQuery<OutputKind>(&QuerySession::OutKind, OutputKind(OutKind));
|
||||
}
|
||||
|
@ -103,7 +103,8 @@ TEST_F(QueryEngineTest, Basic) {
|
||||
|
||||
Str.clear();
|
||||
|
||||
EXPECT_TRUE(SetQuery<OutputKind>(&QuerySession::OutKind, OK_Dump).run(OS, S));
|
||||
EXPECT_TRUE(
|
||||
SetQuery<OutputKind>(&QuerySession::OutKind, OK_DetailedAST).run(OS, S));
|
||||
EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
|
||||
|
||||
EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
|
||||
|
@ -70,7 +70,7 @@ TEST_F(QueryParserTest, Set) {
|
||||
|
||||
Q = parse("set output");
|
||||
ASSERT_TRUE(isa<InvalidQuery>(Q));
|
||||
EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
|
||||
EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got ''",
|
||||
cast<InvalidQuery>(Q)->ErrStr);
|
||||
|
||||
Q = parse("set bind-root true foo");
|
||||
@ -79,13 +79,18 @@ TEST_F(QueryParserTest, Set) {
|
||||
|
||||
Q = parse("set output foo");
|
||||
ASSERT_TRUE(isa<InvalidQuery>(Q));
|
||||
EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
|
||||
EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got 'foo'",
|
||||
cast<InvalidQuery>(Q)->ErrStr);
|
||||
|
||||
Q = parse("set output dump");
|
||||
ASSERT_TRUE(isa<SetQuery<OutputKind> >(Q));
|
||||
EXPECT_EQ(&QuerySession::OutKind, cast<SetQuery<OutputKind> >(Q)->Var);
|
||||
EXPECT_EQ(OK_Dump, cast<SetQuery<OutputKind> >(Q)->Value);
|
||||
EXPECT_EQ(OK_DetailedAST, cast<SetQuery<OutputKind>>(Q)->Value);
|
||||
|
||||
Q = parse("set output detailed-ast");
|
||||
ASSERT_TRUE(isa<SetQuery<OutputKind>>(Q));
|
||||
EXPECT_EQ(&QuerySession::OutKind, cast<SetQuery<OutputKind>>(Q)->Var);
|
||||
EXPECT_EQ(OK_DetailedAST, cast<SetQuery<OutputKind>>(Q)->Value);
|
||||
|
||||
Q = parse("set bind-root foo");
|
||||
ASSERT_TRUE(isa<InvalidQuery>(Q));
|
||||
|
Loading…
Reference in New Issue
Block a user