diff options
author | Erick Velez <erickvelez7@gmail.com> | 2023-06-01 10:22:19 -0700 |
---|---|---|
committer | Erick Velez <erickvelez7@gmail.com> | 2023-08-02 10:19:05 -0700 |
commit | 8b76b44e46ac5b4efbf8cb3702f09d353af2a112 (patch) | |
tree | 8b98f65fb35d222a4db0f6d32925ca5038b8ceda /clang/test/ExtractAPI/constructor_destructor.cpp | |
parent | b711d11c83aeed3b7266ea09532f64229e81bfd6 (diff) | |
download | llvm-8b76b44e46ac5b4efbf8cb3702f09d353af2a112.zip llvm-8b76b44e46ac5b4efbf8cb3702f09d353af2a112.tar.gz llvm-8b76b44e46ac5b4efbf8cb3702f09d353af2a112.tar.bz2 |
[clang][ExtractAPI] Add support for C++ classes
Add ExtractAPI support C++ classes, fields, methods, and various qualifiers and specifiers
Differential Revision: https://reviews.llvm.org/D153557
Diffstat (limited to 'clang/test/ExtractAPI/constructor_destructor.cpp')
-rw-r--r-- | clang/test/ExtractAPI/constructor_destructor.cpp | 227 |
1 files changed, 227 insertions, 0 deletions
diff --git a/clang/test/ExtractAPI/constructor_destructor.cpp b/clang/test/ExtractAPI/constructor_destructor.cpp new file mode 100644 index 0000000..3c8e982 --- /dev/null +++ b/clang/test/ExtractAPI/constructor_destructor.cpp @@ -0,0 +1,227 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \ +// RUN: %t/reference.output.json.in >> %t/reference.output.json +// RUN: %clang++ -extract-api -target arm64-apple-macosx -x c++-header \ +// RUN: %t/input.h -o %t/output.json -Xclang -verify + +// Generator version is not consistent across test runs, normalize it. +// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \ +// RUN: %t/output.json >> %t/output-normalized.json +// RUN: diff %t/reference.output.json %t/output-normalized.json + +//--- input.h +class Foo { + Foo(); + ~Foo(); +}; +/// expected-no-diagnostics + +//--- reference.output.json.in +{ + "metadata": { + "formatVersion": { + "major": 0, + "minor": 5, + "patch": 3 + }, + "generator": "?" + }, + "module": { + "name": "", + "platform": { + "architecture": "arm64", + "operatingSystem": { + "minimumVersion": { + "major": 11, + "minor": 0, + "patch": 0 + }, + "name": "macosx" + }, + "vendor": "apple" + } + }, + "relationships": [ + { + "kind": "memberOf", + "source": "c:@S@Foo@F@Foo#", + "target": "c:@S@Foo", + "targetFallback": "Foo" + }, + { + "kind": "memberOf", + "source": "c:@S@Foo@F@~Foo#", + "target": "c:@S@Foo", + "targetFallback": "Foo" + } + ], + "symbols": [ + { + "accessLevel": "public", + "declarationFragments": [ + { + "kind": "keyword", + "spelling": "class" + }, + { + "kind": "text", + "spelling": " " + }, + { + "kind": "identifier", + "spelling": "Foo" + }, + { + "kind": "text", + "spelling": ";" + } + ], + "identifier": { + "interfaceLanguage": "c++", + "precise": "c:@S@Foo" + }, + "kind": { + "displayName": "Class", + "identifier": "c++.class" + }, + "location": { + "position": { + "character": 7, + "line": 1 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "navigator": [ + { + "kind": "identifier", + "spelling": "Foo" + } + ], + "subHeading": [ + { + "kind": "identifier", + "spelling": "Foo" + } + ], + "title": "Foo" + }, + "pathComponents": [ + "Foo" + ] + }, + { + "accessLevel": "private", + "declarationFragments": [ + { + "kind": "identifier", + "spelling": "Foo" + }, + { + "kind": "text", + "spelling": "();" + } + ], + "functionSignature": { + "returns": [ + { + "kind": "typeIdentifier", + "preciseIdentifier": "c:v", + "spelling": "void" + } + ] + }, + "identifier": { + "interfaceLanguage": "c++", + "precise": "c:@S@Foo@F@Foo#" + }, + "kind": { + "displayName": "Constructor", + "identifier": "c++.method" + }, + "location": { + "position": { + "character": 3, + "line": 2 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "navigator": [ + { + "kind": "identifier", + "spelling": "Foo" + } + ], + "subHeading": [ + { + "kind": "identifier", + "spelling": "Foo" + } + ], + "title": "Foo" + }, + "pathComponents": [ + "Foo", + "Foo" + ] + }, + { + "accessLevel": "private", + "declarationFragments": [ + { + "kind": "identifier", + "spelling": "~Foo" + }, + { + "kind": "text", + "spelling": "();" + } + ], + "functionSignature": { + "returns": [ + { + "kind": "typeIdentifier", + "preciseIdentifier": "c:v", + "spelling": "void" + } + ] + }, + "identifier": { + "interfaceLanguage": "c++", + "precise": "c:@S@Foo@F@~Foo#" + }, + "kind": { + "displayName": "Destructor", + "identifier": "c++.method" + }, + "location": { + "position": { + "character": 3, + "line": 3 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "navigator": [ + { + "kind": "identifier", + "spelling": "~Foo" + } + ], + "subHeading": [ + { + "kind": "identifier", + "spelling": "Foo" + } + ], + "title": "~Foo" + }, + "pathComponents": [ + "Foo", + "~Foo" + ] + } + ] +} |