Skip to content

Commit c49ca51

Browse files
committed
Clippy fix and add CI workflows
1 parent f786255 commit c49ca51

10 files changed

Lines changed: 81 additions & 25 deletions

File tree

.github/workflows/tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ jobs:
5757
- name: Ensure correct dependency resolution
5858
run: |
5959
bazel mod deps --lockfile_mode=update
60+
- name: Run Libclang Parser Tooling clippy
61+
run: |
62+
bazel build //cpp/libclang/... --config=clippy
63+
- name: Run Libclang Parser Tooling tests
64+
run: |
65+
bazel test //cpp/libclang/...

cpp/libclang/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
<!-- ----------------------------------------------------------------------------
2+
Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
4+
See the NOTICE file(s) distributed with this work for additional
5+
information regarding copyright ownership.
6+
7+
This program and the accompanying materials are made available under the
8+
terms of the Apache License Version 2.0 which is available at
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
SPDX-License-Identifier: Apache-2.0
12+
----------------------------------------------------------------------------- -->
13+
114
# Run C++ parser targets
215

316
## Configure a parser target in `BUILD`

cpp/libclang/integration_test/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
<!-- ----------------------------------------------------------------------------
2+
Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
4+
See the NOTICE file(s) distributed with this work for additional
5+
information regarding copyright ownership.
6+
7+
This program and the accompanying materials are made available under the
8+
terms of the Apache License Version 2.0 which is available at
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
SPDX-License-Identifier: Apache-2.0
12+
----------------------------------------------------------------------------- -->
13+
114
# libclang Integration Tests
215

316
This directory contains integration tests for the C++ libclang parser and related tooling.

cpp/libclang/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct Args {
4949

5050
fn parse_file(
5151
file: &PathBuf,
52-
compilation_flags: &Vec<String>,
52+
compilation_flags: &[String],
5353
index: &clang::Index,
5454
ast_file_output_path: &PathBuf,
5555
all_classes: &mut BTreeMap<String, context::TypeMapValue>,
@@ -64,7 +64,7 @@ fn parse_file(
6464
}
6565
};
6666

67-
let parse_result = index.parser(&file).arguments(&compilation_flags).parse();
67+
let parse_result = index.parser(file).arguments(compilation_flags).parse();
6868

6969
match parse_result {
7070
Ok(parsed) => {
@@ -76,7 +76,7 @@ fn parse_file(
7676
}
7777

7878
let entity = parsed.get_entity();
79-
print_entity(&entity, 0, PrintMode::File(&ast_file_output_path));
79+
print_entity(&entity, 0, PrintMode::File(ast_file_output_path));
8080
print_entity(&entity, 0, PrintMode::Stdout);
8181

8282
let mut ctx = VisitContext::default();
@@ -139,8 +139,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
139139
let compilation_flags = &command_line_args.extra_args;
140140

141141
parse_file(
142-
&file,
143-
&compilation_flags,
142+
file,
143+
compilation_flags,
144144
&index,
145145
&ast_file_output_path,
146146
&mut all_classes,

cpp/libclang/src/visitor/src/class_parser_helper.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
// SPDX-License-Identifier: Apache-2.0
1212
////////////////////////////////////////////////////////////////////////////////////
13+
#![cfg_attr(test, allow(dead_code))]
14+
1315
use clang::{Entity, EntityKind, Type, TypeKind};
1416
use serde::{Deserialize, Serialize};
1517

@@ -450,7 +452,7 @@ fn resolve_unqualified_type(original: &Type, canonical: &Type) -> ResolvedType {
450452

451453
ResolvedType::Array {
452454
element: Box::new(element),
453-
size: original.get_size().map(|s| s as usize),
455+
size: original.get_size(),
454456
}
455457
}
456458

@@ -624,7 +626,7 @@ fn build_fqn_from_entity(entity: &Entity) -> String {
624626
// Traversal is semantic (not lexical) so aliases/nested constructs resolve to
625627
// stable ownership hierarchy used by relationship and id matching.
626628
let mut parts: Vec<(String, bool)> = Vec::new();
627-
let mut current = Some(entity.clone());
629+
let mut current = Some(*entity);
628630

629631
while let Some(entity) = current {
630632
match entity.get_kind() {

cpp/libclang/src/visitor/src/class_visitor.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl ClassVisitor {
7474
};
7575

7676
let mut class_entity = SimpleEntity {
77-
id: id,
77+
id,
7878
name: name.clone(),
7979
enclosing_namespace_id: namespace.map(|ns| ns.to_string()),
8080
..Default::default()
@@ -153,12 +153,8 @@ fn parse_source_location(entity: &Entity) -> (Option<String>, Option<u32>) {
153153
}
154154

155155
fn collect_variable_type(entity: &Entity) -> Option<ParsedVariableType> {
156-
let Some(name) = entity.get_name() else {
157-
return None;
158-
};
159-
let Some(field_type) = entity.get_type() else {
160-
return None;
161-
};
156+
let name = entity.get_name()?;
157+
let field_type = entity.get_type()?;
162158

163159
Some(ParsedVariableType {
164160
name,

cpp/libclang/src/visitor/src/enum_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl EnumVisitor {
3636
};
3737
Some(SimpleEntity {
3838
id: full_qualified_id,
39-
name: name,
39+
name,
4040
enclosing_namespace_id: namespace_id,
4141
entity_type: EntityType::Enum,
4242
enum_literals: get_literals(entity),

plantuml/parser/puml_serializer/src/serialize/sequence_serializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use flatbuffers::FlatBufferBuilder;
1515
use sequence_fbs::sequence_metamodel as fb;
16-
use sequence_logic::{ConditionType, Event, SequenceNode, SequenceTree};
16+
use sequence_diagram::{ConditionType, Event, SequenceNode, SequenceTree};
1717

1818
pub struct SequenceSerializer;
1919

third_party/libclang/patchv1.8.2.patch

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
114
diff --git a/CHANGELOG.md b/CHANGELOG.md
215
index 169ae2d..dd3548f 100644
316
--- a/CHANGELOG.md
@@ -14,17 +27,17 @@ index 169ae2d..dd3548f 100644
1427
+when using target-prefixed `clang` binaries
1528
+
1629
## [1.8.1] - 2024-05-28
17-
30+
1831
### Added
1932
@@ -20,8 +30,6 @@
2033
### Fixed
2134
- Fixed handling of paths that contain characters that have special meaning in
2235
glob patterns (e.g., `[` or `]`)
2336
-- Fixed `Clang::find` to support both the `-target` and `--target` arguments
2437
-when using target-prefixed `clang` binaries
25-
38+
2639
## [1.7.0] - 2023-12-31
27-
40+
2841
diff --git a/build/common.rs b/build/common.rs
2942
index 696d923..6653478 100644
3043
--- a/build/common.rs
@@ -43,7 +56,7 @@ index d24490f..87e32cc 100644
4356
+++ b/build/dynamic.rs
4457
@@ -263,8 +263,8 @@ pub fn link() {
4558
let name = filename.trim_start_matches("lib");
46-
59+
4760
// Strip extensions and trailing version numbers (e.g., the `.so.7.0` in
4861
- // `libclang.so.7.0`).
4962
- let name = match name.find(".dylib").or_else(|| name.find(".so")) {
@@ -66,7 +79,7 @@ index 58e64b5..87f94ba 100644
6679
+ pub(crate) path: PathBuf,
6780
pub functions: Functions,
6881
}
69-
82+
7083
diff --git a/src/support.rs b/src/support.rs
7184
index 51764d2..2d28b1c 100644
7285
--- a/src/support.rs
@@ -91,7 +104,7 @@ index 51764d2..2d28b1c 100644
91104
/// ## Cross-compilation
92105
///
93106
@@ -70,7 +72,7 @@ impl Clang {
94-
107+
95108
let mut target = None;
96109
for i in 0..args.len() {
97110
- if (args[i] == "-target" || args[i] == "-target") && i + 1 < args.len() {
@@ -102,7 +115,7 @@ index 51764d2..2d28b1c 100644
102115
@@ -83,6 +85,16 @@ impl Clang {
103116
paths.push(path.into());
104117
}
105-
118+
106119
+ #[cfg(feature = "runtime")]
107120
+ if let Some(library) = crate::get_library() {
108121
+ if let Some(directory) = library.path().parent() {

third_party/libclang/patchv1.9.0.patch

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
114
diff --git a/CHANGELOG.md b/CHANGELOG.md
215
index dd3548f..e512edf 100644
316
--- a/CHANGELOG.md
@@ -9,14 +22,14 @@ index dd3548f..e512edf 100644
922
+- Added `--link-static` flag when listing static libraries to link to
1023
+
1124
## [1.8.2] - 2024-05-29
12-
25+
1326
### Changed
1427
diff --git a/build/static.rs b/build/static.rs
1528
index 6bc2bea..e835178 100644
1629
--- a/build/static.rs
1730
+++ b/build/static.rs
1831
@@ -41,7 +41,7 @@ fn get_library_name(path: &Path) -> Option<String> {
19-
32+
2033
/// Gets the LLVM static libraries required to link to `libclang`.
2134
fn get_llvm_libraries() -> Vec<String> {
2235
- common::run_llvm_config(&["--libs"])

0 commit comments

Comments
 (0)