Skip to content
Open
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
20 changes: 0 additions & 20 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/libclang/docs/ast-traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ not filtered out, it dispatches to the relevant specialized visitor:
| --- | --- |
| `ClassDecl`, `StructDecl`, `ClassTemplate`, and `ClassTemplatePartialSpecialization` | Extract class/struct entities, members, aliases, bases, and relationship inputs. |
| `EnumDecl` | Extract enum entities and literals. |
| `FunctionDecl`, `FunctionTemplate`, and `Method` | Extract callable definitions and their body control flow. Function templates are classified as free functions, methods, or static methods according to their scope. |
| `FunctionDecl`, `FunctionTemplate`, `Method`, `Constructor`, and `Destructor` | Extract callable definitions and their body control flow. Function templates are classified as free functions, methods, or static methods according to their scope. Constructors and destructors are routed through the same callable visitor and participate in body extraction when they have a direct compound body. |

After traversal, class relationship resolution uses the collected base,
variable, and method type information to populate the class-diagram
Expand Down
8 changes: 5 additions & 3 deletions cpp/libclang/docs/function-extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,17 @@ The top-level visitor currently dispatches these cursor kinds to
| `FunctionDecl` | `Free` |
| `FunctionTemplate` | `Free` at global or namespace scope; `Method` or `StaticMethod` at type scope |
| `Method` | `Method` or `StaticMethod` |
| `Constructor` | `Constructor` |
| `Destructor` | `Destructor` |

C++ member operator overloads such as `operator+` and `operator[]` are normally
reported as `Method`; the current model does not use a distinct operator-method
kind.

`FunctionVisitor` has internal kind mappings for `Constructor`, `Destructor`,
and `ConversionFunction`, but the top-level visitor currently logs and ignores
those cursor kinds. Therefore they do not currently produce `FunctionDef`
entries. A conversion operator such as `operator bool()` is a
and `ConversionFunction`. The top-level visitor currently dispatches
constructors and destructors for extraction, but still logs and ignores
`ConversionFunction`. A conversion operator such as `operator bool()` is a
`ConversionFunction` and is distinct from a normal operator overload.

Namespace-level function templates are extracted as `FunctionDef` entries with
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("//cpp/libclang/integration_test:test_rules.bzl", "cpp_parser_integration_test")

cc_library(
name = "definition_then_forward_decl",
srcs = [
"first.cpp",
"second.cpp",
],
hdrs = [
"widget_forward.h",
"widget_full.h",
],
visibility = ["//cpp/libclang:__subpackages__"],
)

cpp_parser_integration_test(
name = "test_definition_then_forward_decl",
expected_output = ["expected.json"],
target = ":definition_then_forward_decl",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"types": {
"util::Widget": {
"id": "util::Widget",
"name": "Widget",
"enclosing_namespace_id": "util",
"stereotypes": [],
"entity_type": "Class",
"type_aliases": [],
"variables": [
{
"name": "value",
"data_type": "int",
"visibility": "public",
"is_static": false,
"source_location": {
"file": "cpp/libclang/integration_test/cases/definition_then_forward_decl/widget_full.h",
"line": 19
}
}
],
"methods": [],
"template_parameters": null,
"enum_literals": [],
"relationships": [],
"source_location": {
"file": "cpp/libclang/integration_test/cases/definition_then_forward_decl/widget_full.h",
"line": 17
}
}
},
"functions": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#include "widget_forward.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Currect Include?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is intentional.
The purpose of this test case is to cover the scenario where the parser sees a forward declaration in one TU and the full definition in another, so first.cpp only includes the forward declaration on purpose.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************

use test_framework::run_parser_case;

#[test]
fn test_definition_then_forward_decl() {
run_parser_case();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#include "widget_full.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#pragma once

namespace util {
class Widget;
} // namespace util
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#pragma once

namespace util {
class Widget {
public:
int value;
};
} // namespace util
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,60 @@
}
}
},
"free_function_declarations": [
{
"name": "declval",
"enclosing_namespace_id": null,
"return_type": "T",
"parameters": [],
"template_parameters": [
{
"Type": {
"name": "T",
"is_pack": false
}
}
],
"source_location": {
"file": "cpp/libclang/integration_test/cases/dependent_decltype_base/dependent_base.cpp",
"line": 19
}
},
{
"name": "is_maplike_container_impl",
"enclosing_namespace_id": null,
"return_type": "decltype(value.begin())",
"parameters": [
{
"name": "value",
"param_type": "T",
"is_variadic": false
}
],
"template_parameters": [
{
"Type": {
"name": "T",
"is_pack": false
}
}
],
"source_location": {
"file": "cpp/libclang/integration_test/cases/dependent_decltype_base/dependent_base.cpp",
"line": 22
}
},
{
"name": "make_widget",
"enclosing_namespace_id": null,
"return_type": "Widget",
"parameters": [],
"template_parameters": null,
"source_location": {
"file": "cpp/libclang/integration_test/cases/dependent_decltype_base/dependent_base.cpp",
"line": 43
}
}
],
"functions": []
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{
"free_function_declarations": [
{
"name": "notify",
"enclosing_namespace_id": null,
"return_type": "void",
"parameters": [],
"template_parameters": null,
"source_location": {
"file": "cpp/libclang/integration_test/function_cases/class_method_template_body/functions.cpp",
"line": 14
}
}
],
"functions": [
{
"id": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,63 @@
{
"types": {},
"free_function_declarations": [
{
"name": "specialized",
"enclosing_namespace_id": "utility",
"return_type": "T",
"parameters": [
{
"name": "value",
"param_type": "T",
"is_variadic": false
}
],
"template_parameters": [
{
"Type": {
"name": "T",
"is_pack": false
}
}
],
"source_location": {
"file": "cpp/libclang/integration_test/function_cases/explicit_specialization/specialization.h",
"line": 21
}
},
{
"name": "specialized",
"enclosing_namespace_id": "utility",
"return_type": "int",
"parameters": [
{
"name": "value",
"param_type": "int",
"is_variadic": false
}
],
"template_parameters": null,
"source_location": {
"file": "cpp/libclang/integration_test/function_cases/explicit_specialization/specialization.h",
"line": 25
}
}
],
"functions": [
{
"id": {
"name": "specialized",
"scope": {
"Namespace": [
"utility"
]
}
},
"name": "specialized"
},
"kind": "Free",
"return_type": {
"Builtin": "int"
},
"body": []
}
],
"types": {}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ load("//cpp/libclang/integration_test:test_rules.bzl", "cpp_parser_integration_t

cc_library(
name = "free_function_identity",
srcs = glob(["*.cpp"]),
srcs = ["functions.cpp"],
hdrs = ["functions.hpp"],
visibility = ["//cpp/libclang:__subpackages__"],
)

Expand Down
Loading
Loading