Skip to content

Commit d734943

Browse files
committed
[clang-query] Use the new API for named values from the Parser.
Summary: This finishes the support for autocomplete for user defined values.. Reviewers: pcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4851 llvm-svn: 215474
1 parent cee9d0a commit d734943

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

clang-tools-extra/clang-query/QueryParser.cpp

+5-18
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,12 @@ QueryRef makeInvalidQueryFromDiagnostics(const Diagnostics &Diag) {
157157
return new InvalidQuery(OS.str());
158158
}
159159

160-
class QuerySessionSema : public Parser::RegistrySema {
161-
public:
162-
QuerySessionSema(const QuerySession &QS) : QS(QS) {}
163-
164-
ast_matchers::dynamic::VariantValue getNamedValue(StringRef Name) override {
165-
return QS.NamedValues.lookup(Name);
166-
}
167-
168-
private:
169-
const QuerySession &QS;
170-
};
171-
172160
} // namespace
173161

174162
QueryRef QueryParser::completeMatcherExpression() {
175163
std::vector<MatcherCompletion> Comps = Parser::completeExpression(
176-
StringRef(Begin, End - Begin), CompletionPos - Begin);
164+
StringRef(Begin, End - Begin), CompletionPos - Begin, nullptr,
165+
&QS.NamedValues);
177166
for (std::vector<MatcherCompletion>::iterator I = Comps.begin(),
178167
E = Comps.end();
179168
I != E; ++I) {
@@ -194,8 +183,6 @@ QueryRef QueryParser::doParse() {
194183
.Case("unlet", PQK_Unlet)
195184
.Default(PQK_Invalid);
196185

197-
QuerySessionSema S(QS);
198-
199186
switch (QKind) {
200187
case PQK_NoOp:
201188
return new NoOpQuery;
@@ -214,8 +201,8 @@ QueryRef QueryParser::doParse() {
214201

215202
Diagnostics Diag;
216203
ast_matchers::dynamic::VariantValue Value;
217-
if (!Parser::parseExpression(StringRef(Begin, End - Begin), &S, &Value,
218-
&Diag)) {
204+
if (!Parser::parseExpression(StringRef(Begin, End - Begin), nullptr,
205+
&QS.NamedValues, &Value, &Diag)) {
219206
return makeInvalidQueryFromDiagnostics(Diag);
220207
}
221208

@@ -228,7 +215,7 @@ QueryRef QueryParser::doParse() {
228215

229216
Diagnostics Diag;
230217
Optional<DynTypedMatcher> Matcher = Parser::parseMatcherExpression(
231-
StringRef(Begin, End - Begin), &S, &Diag);
218+
StringRef(Begin, End - Begin), nullptr, &QS.NamedValues, &Diag);
232219
if (!Matcher) {
233220
return makeInvalidQueryFromDiagnostics(Diag);
234221
}

0 commit comments

Comments
 (0)