Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions clang-tools-extra/test/clang-doc/json/class-requires.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.json

template<typename T>
concept Addable = requires(T a, T b) {
{ a + b };
};

template<typename T>
requires Addable<T>
struct MyClass;

// CHECK: "Name": "MyClass",
// CHECK-NEXT: "Namespace": [
// CHECK-NEXT: "GlobalNamespace"
// CHECK-NEXT: ],
// CHECK-NEXT: "Path": "GlobalNamespace",
// CHECK-NEXT: "TagType": "struct",
// CHECK-NEXT: "Template": {
// CHECK-NOT: "Constraints": [
// CHECK-NOT: {
// CHECK-NOT: "Expression": "Addable<T>",
// CHECK-NOT: "Name": "Addable",
// CHECK-NOT: "Path": "",
// CHECK-NOT: "QualName": "Addable",
// CHECK-NOT: "USR": "{{[0-9A-F]*}}"
// CHECK-NOT: }
// CHECK-NOT: ],
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"
37 changes: 37 additions & 0 deletions clang-tools-extra/test/clang-doc/json/concept.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileCheck is omitted here because since nothing is mapped, no file is created.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s try to mark it fail with filecheck. If that’s doesn’t work, I’m ok with this.


// Requires that T suports post and pre-incrementing.
template<typename T>
concept Incrementable = requires(T x) {
++x;
x++;
};

// CHECK: {
// CHECK-NOT: "Concepts": [
// CHECK-NOT: {
// CHECK-NOT: "ConstraintExpression": "requires (T x) { ++x; x++; }",
// CHECK-NOT: "Description": [
// CHECK-NOT: {
// CHECK-NOT: "FullComment": {
// CHECK-NOT: "Children": [
// CHECK-NOT: {
// CHECK-NOT: "ParagraphComment": {
// CHECK-NOT: "Children": [
// CHECK-NOT: {
// CHECK-NOT: "TextComment": " Requires that T suports post and pre-incrementing."
// CHECK-NOT: ],
// CHECK-NOT: "IsType": true,
// CHECK-NOT: "Name": "Incrementable",
// CHECK-NOT: "Template": {
// CHECK-NOT: "Parameters": [
// CHECK-NOT: "typename T"
// CHECK-NOT: ]
// CHECK-NOT: },
// CHECK-NOT: "USR": "{{[0-9A-F]*}}"
// CHECK-NOT: }
// CHECK-NOT: ],
// CHECK: "Name": "",
// CHECK: "USR": "0000000000000000000000000000000000000000"
// CHECK: }
79 changes: 79 additions & 0 deletions clang-tools-extra/test/clang-doc/json/function-requires.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
// RUN: FileCheck %s < %t/GlobalNamespace/index.json

template<typename T>
concept Incrementable = requires(T x) {
++x;
x++;
};

template<typename T> void increment(T t) requires Incrementable<T>;

template<Incrementable T> Incrementable auto incrementTwo(T t);

// CHECK: "Functions": [
// CHECK-NEXT: {
// CHECK-NEXT: "IsStatic": false,
// CHECK-NEXT: "Name": "increment",
// CHECK-NEXT: "Params": [
// CHECK-NEXT: {
// CHECK-NEXT: "Name": "t",
// CHECK-NEXT: "Type": "T"
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "ReturnType": {
// CHECK-NEXT: "IsBuiltIn": false,
// CHECK-NEXT: "IsTemplate": false,
// CHECK-NEXT: "Name": "void",
// CHECK-NEXT: "QualName": "void",
// CHECK-NEXT: "USR": "0000000000000000000000000000000000000000"
// CHECK-NEXT: },
// CHECK-NEXT: "Template": {
// CHECK-NOT: "Constraints": [
// CHECK-NOT: {
// CHECK-NOT: "Expression": "Incrementable<T>",
// CHECK-NOT: "Name": "Incrementable",
// CHECK-NOT: "Path": "",
// CHECK-NOT: "QualName": "Incrementable",
// CHECK-NOT: "USR": "{{[0-9A-F]*}}"
// CHECK-NOT: }
// CHECK-NOT: ],
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "IsStatic": false,
// CHECK-NEXT: "Name": "incrementTwo",
// CHECK-NEXT: "Params": [
// CHECK-NEXT: {
// CHECK-NEXT: "Name": "t",
// CHECK-NEXT: "Type": "T"
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "ReturnType": {
// CHECK-NEXT: "IsBuiltIn": false,
// CHECK-NEXT: "IsTemplate": false,
// CHECK-NEXT: "Name": "Incrementable auto",
// CHECK-NEXT: "QualName": "Incrementable auto",
// CHECK-NEXT: "USR": "0000000000000000000000000000000000000000"
// CHECK-NEXT: },
// CHECK-NEXT: "Template": {
// CHECK-NOT: "Constraints": [
// CHECK-NOT: {
// CHECK-NOT: "Expression": "Incrementable<T>",
// CHECK-NOT: "Name": "Incrementable",
// CHECK-NOT: "Path": "",
// CHECK-NOT: "QualName": "Incrementable",
// CHECK-NOT: "USR": "{{[0-9A-F]*}}"
// CHECK-NOT: }
// CHECK-NOT: ],
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "Incrementable T"
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"
// CHECK-NEXT: }
Loading