Skip to content

Commit 7c0a6a1

Browse files
volsaghaith
authored andcommitted
fix: (Some) validations for internal types
1 parent 8ddf223 commit 7c0a6a1

5 files changed

+33
-1
lines changed

src/validation/recursive.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ impl CycleDetector for CycleInvestigator<DataType> {
165165
let mut nodes_visited = FxIndexSet::default();
166166

167167
// Structs (includes arrays defined in structs)
168-
nodes_all.extend(index.get_types().values().filter(|x| x.get_type_information().is_struct()));
168+
nodes_all
169+
.extend(index.get_types().values().filter(|dt| dt.is_struct() && !dt.location.is_internal()));
169170

170171
// Function Blocks
171172
nodes_all.extend(index.get_pou_types().values().filter(|x| {

src/validation/types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ pub fn visit_data_type_declaration<T: AnnotationMap>(
1515
declaration: &DataTypeDeclaration,
1616
context: &ValidationContext<T>,
1717
) {
18+
if declaration.get_location().is_internal() {
19+
return;
20+
}
21+
1822
match declaration {
1923
DataTypeDeclaration::Reference { referenced_type, location } => {
2024
if context.index.find_effective_type_by_name(referenced_type).is_none() {

tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
source: tests/integration/cfc.rs
33
expression: output_file_content_without_headers
44
---
5+
%__vtable_conditional_return = type {}
56
%conditional_return = type { i32 }
67

8+
@____vtable_conditional_return__init = external global %__vtable_conditional_return
79
@__conditional_return__init = constant %conditional_return zeroinitializer
810
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___plc, i8* null }]
911

@@ -22,6 +24,13 @@ else_block: ; preds = %entry
2224
ret void
2325
}
2426

27+
define void @__init___vtable_conditional_return(%__vtable_conditional_return* %0) {
28+
entry:
29+
%self = alloca %__vtable_conditional_return*, align 8
30+
store %__vtable_conditional_return* %0, %__vtable_conditional_return** %self, align 8
31+
ret void
32+
}
33+
2534
define void @__init_conditional_return(%conditional_return* %0) {
2635
entry:
2736
%self = alloca %conditional_return*, align 8

tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
source: tests/integration/cfc.rs
33
expression: output_file_content_without_headers
44
---
5+
%__vtable_conditional_return = type {}
56
%conditional_return = type { i32 }
67

8+
@____vtable_conditional_return__init = external global %__vtable_conditional_return
79
@__conditional_return__init = constant %conditional_return zeroinitializer
810
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___plc, i8* null }]
911

@@ -46,6 +48,13 @@ else_block: ; preds = %entry
4648
ret void
4749
}
4850

51+
define void @__init___vtable_conditional_return(%__vtable_conditional_return* %0) {
52+
entry:
53+
%self = alloca %__vtable_conditional_return*, align 8
54+
store %__vtable_conditional_return* %0, %__vtable_conditional_return** %self, align 8
55+
ret void
56+
}
57+
4958
define void @__init_conditional_return(%conditional_return* %0) {
5059
entry:
5160
%self = alloca %conditional_return*, align 8

tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
source: tests/integration/cfc.rs
33
expression: output_file_content_without_headers
44
---
5+
%__vtable_conditional_return = type {}
56
%conditional_return = type { i32 }
67

8+
@____vtable_conditional_return__init = external global %__vtable_conditional_return
79
@__conditional_return__init = constant %conditional_return zeroinitializer
810
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___plc, i8* null }]
911

@@ -47,6 +49,13 @@ else_block: ; preds = %entry
4749
ret void
4850
}
4951

52+
define void @__init___vtable_conditional_return(%__vtable_conditional_return* %0) {
53+
entry:
54+
%self = alloca %__vtable_conditional_return*, align 8
55+
store %__vtable_conditional_return* %0, %__vtable_conditional_return** %self, align 8
56+
ret void
57+
}
58+
5059
define void @__init_conditional_return(%conditional_return* %0) {
5160
entry:
5261
%self = alloca %conditional_return*, align 8

0 commit comments

Comments
 (0)