[PATCH] [clang-query] Use the new API for named values from the Parser.

Samuel Benzaquen sbenza at google.com
Mon Aug 11 12:43:19 PDT 2014


Hi pcc,

This finishes the support for autocomplete for user defined values..

http://reviews.llvm.org/D4851

Files:
  clang-query/QueryParser.cpp

Index: clang-query/QueryParser.cpp
===================================================================
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -157,23 +157,12 @@
   return new InvalidQuery(OS.str());
 }
 
-class QuerySessionSema : public Parser::RegistrySema {
-public:
-  QuerySessionSema(const QuerySession &QS) : QS(QS) {}
-
-  ast_matchers::dynamic::VariantValue getNamedValue(StringRef Name) override {
-    return QS.NamedValues.lookup(Name);
-  }
-
-private:
-  const QuerySession &QS;
-};
-
 }  // namespace
 
 QueryRef QueryParser::completeMatcherExpression() {
   std::vector<MatcherCompletion> Comps = Parser::completeExpression(
-      StringRef(Begin, End - Begin), CompletionPos - Begin);
+      StringRef(Begin, End - Begin), CompletionPos - Begin, nullptr,
+      &QS.NamedValues);
   for (std::vector<MatcherCompletion>::iterator I = Comps.begin(),
                                                 E = Comps.end();
        I != E; ++I) {
@@ -194,8 +183,6 @@
                               .Case("unlet", PQK_Unlet)
                               .Default(PQK_Invalid);
 
-  QuerySessionSema S(QS);
-
   switch (QKind) {
   case PQK_NoOp:
     return new NoOpQuery;
@@ -214,8 +201,8 @@
 
     Diagnostics Diag;
     ast_matchers::dynamic::VariantValue Value;
-    if (!Parser::parseExpression(StringRef(Begin, End - Begin), &S, &Value,
-                                 &Diag)) {
+    if (!Parser::parseExpression(StringRef(Begin, End - Begin), nullptr,
+                                 &QS.NamedValues, &Value, &Diag)) {
       return makeInvalidQueryFromDiagnostics(Diag);
     }
 
@@ -228,7 +215,7 @@
 
     Diagnostics Diag;
     Optional<DynTypedMatcher> Matcher = Parser::parseMatcherExpression(
-        StringRef(Begin, End - Begin), &S, &Diag);
+        StringRef(Begin, End - Begin), nullptr, &QS.NamedValues, &Diag);
     if (!Matcher) {
       return makeInvalidQueryFromDiagnostics(Diag);
     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4851.12364.patch
Type: text/x-patch
Size: 1953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140811/f80ca783/attachment.bin>


More information about the cfe-commits mailing list