Author: steveire Date: Wed Oct 24 13:33:45 2018 New Revision: 345193 URL: http://llvm.org/viewvc/llvm-project?rev=345193&view=rev Log: [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 Modified: clang-tools-extra/trunk/clang-query/Query.cpp clang-tools-extra/trunk/clang-query/Query.h clang-tools-extra/trunk/clang-query/QueryParser.cpp clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp Modified: clang-tools-extra/trunk/clang-query/Query.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345193&r1=345192&r2=345193&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-query/Query.cpp (original) +++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:45 2018 @@ -53,8 +53,10 @@ bool HelpQuery::run(llvm::raw_ostream &O "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 << "\n"; break; } - case OK_Dump: { + case OK_DetailedAST: { OS << "Binding for \"" << BI->first << "\":\n"; BI->second.dump(OS, AST->getSourceManager()); OS << "\n"; Modified: clang-tools-extra/trunk/clang-query/Query.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=345193&r1=345192&r2=345193&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-query/Query.h (original) +++ clang-tools-extra/trunk/clang-query/Query.h Wed Oct 24 13:33:45 2018 @@ -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, Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=345193&r1=345192&r2=345193&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original) +++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct 24 13:33:45 2018 @@ -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)); } Modified: clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp?rev=345193&r1=345192&r2=345193&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp (original) +++ clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp Wed Oct 24 13:33:45 2018 @@ -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); Modified: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp?rev=345193&r1=345192&r2=345193&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp (original) +++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp Wed Oct 24 13:33:45 2018 @@ -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)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits