clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

QueryParser.h
Go to the documentation of this file.
1 //===--- QueryParser.h - clang-query ----------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
12
13 #include "Query.h"
14 #include "QuerySession.h"
15 #include "llvm/LineEditor/LineEditor.h"
16 #include <stddef.h>
17
18 namespace clang {
19 namespace query {
20
21 class QuerySession;
22
23 class QueryParser {
24 public:
25 /// Parse \a Line as a query.
26 ///
27 /// \return A QueryRef representing the query, which may be an InvalidQuery.
28 static QueryRef parse(StringRef Line, const QuerySession &QS);
29
30 /// Compute a list of completions for \a Line assuming a cursor at
31 /// \param Pos characters past the start of \a Line, ordered from most
32 /// likely to least likely.
33 ///
34 /// \return A vector of completions for \a Line.
35 static std::vector<llvm::LineEditor::Completion>
36 complete(StringRef Line, size_t Pos, const QuerySession &QS);
37
38 private:
39 QueryParser(StringRef Line, const QuerySession &QS)
40 : Begin(Line.begin()), End(Line.end()),
41 CompletionPos(nullptr), QS(QS) {}
42
43 StringRef lexWord();
44
45 template <typename T> struct LexOrCompleteWord;
46 template <typename T> LexOrCompleteWord<T> lexOrCompleteWord(StringRef &Str);
47
48 QueryRef parseSetBool(bool QuerySession::*Var);
49 QueryRef parseSetOutputKind();
50 QueryRef completeMatcherExpression();
51
52 QueryRef endQuery(QueryRef Q);
53
54 /// \brief Parse [\p Begin,\p End).
55 ///
56 /// \return A reference to the parsed query object, which may be an
57 /// \c InvalidQuery if a parse error occurs.
58 QueryRef doParse();
59
60 const char *Begin;
61 const char *End;
62
63 const char *CompletionPos;
64 std::vector<llvm::LineEditor::Completion> Completions;
65
66 const QuerySession &QS;
67 };
68
69 } // namespace query
70 } // namespace clang
71
72 #endif
clang::query::QueryParser::parse
static QueryRef parse(StringRef Line, const QuerySession &QS)
Parse Line as a query.
Definition: QueryParser.cpp:272
clang::query::QuerySession
Represents the state for a particular clang-query session.
Definition: QuerySession.h:25
clang::query::QueryParser::complete
static std::vector< llvm::LineEditor::Completion > complete(StringRef Line, size_t Pos, const QuerySession &QS)
Compute a list of completions for Line assuming a cursor at.
Definition: QueryParser.cpp:277
Query.h
QuerySession.h
clang::query::QueryParser::LexOrCompleteWord
Definition: QueryParser.cpp:52
clang::query::QueryRef
llvm::IntrusiveRefCntPtr< Query > QueryRef
Definition: Query.h:52
Line
int Line
Definition: PreprocessorTracker.cpp:527
clang::query::QueryParser
Definition: QueryParser.h:23