[PATCH] D73140: [clangd] Add C++20 concepts support to TargetFinder

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 12:17:51 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcbcd07a4815f: [clangd] Add C++20 concepts support to TargetFinder (authored by nridge).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73140/new/

https://reviews.llvm.org/D73140

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -339,6 +339,24 @@
                {"struct Test", Rel::TemplatePattern});
 }
 
+TEST_F(TargetDeclTest, Concept) {
+  Code = R"cpp(
+    template <typename T>
+    concept Fooable = requires (T t) { t.foo(); };
+
+    template <typename T> requires [[Fooable]]<T>
+    void bar(T t) {
+      t.foo();
+    }
+  )cpp";
+  Flags.push_back("-std=c++2a");
+  EXPECT_DECLS(
+      "ConceptSpecializationExpr",
+      // FIXME: Should we truncate the pretty-printed form of a concept decl
+      // somewhere?
+      {"template <typename T> concept Fooable = requires (T t) { t.foo(); };"});
+}
+
 TEST_F(TargetDeclTest, FunctionTemplate) {
   Code = R"cpp(
     // Implicit specialization.
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -279,6 +280,9 @@
       void VisitCallExpr(const CallExpr *CE) {
         Outer.add(CE->getCalleeDecl(), Flags);
       }
+      void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E) {
+        Outer.add(E->getNamedConcept(), Flags);
+      }
       void VisitDeclRefExpr(const DeclRefExpr *DRE) {
         const Decl *D = DRE->getDecl();
         // UsingShadowDecl allows us to record the UsingDecl.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73140.239975.patch
Type: text/x-patch
Size: 1832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200123/7939120c/attachment.bin>


More information about the cfe-commits mailing list