c2r 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- c2r-1.0.0/.gitignore +5 -0
- c2r-1.0.0/.idea/.gitignore +5 -0
- c2r-1.0.0/.idea/c2r.iml +12 -0
- c2r-1.0.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- c2r-1.0.0/.idea/misc.xml +4 -0
- c2r-1.0.0/.idea/modules.xml +8 -0
- c2r-1.0.0/.idea/vcs.xml +6 -0
- c2r-1.0.0/Cargo.lock +460 -0
- c2r-1.0.0/Cargo.toml +25 -0
- c2r-1.0.0/PKG-INFO +94 -0
- c2r-1.0.0/README.md +75 -0
- c2r-1.0.0/benches/run_bench.rs +5 -0
- c2r-1.0.0/c2r/__init__.py +1 -0
- c2r-1.0.0/c2r/cli.py +115 -0
- c2r-1.0.0/docs/SPECIFICATION_PT.md +208 -0
- c2r-1.0.0/pyproject.toml +32 -0
- c2r-1.0.0/run_demo.py +84 -0
- c2r-1.0.0/src/analysis/andersen.rs +108 -0
- c2r-1.0.0/src/analysis/cycles.rs +64 -0
- c2r-1.0.0/src/analysis/mod.rs +8 -0
- c2r-1.0.0/src/analysis/oo_mapper.rs +23 -0
- c2r-1.0.0/src/analysis/regions.rs +106 -0
- c2r-1.0.0/src/analysis/split_tree.rs +41 -0
- c2r-1.0.0/src/analysis/steensgaard.rs +41 -0
- c2r-1.0.0/src/analysis/thread_safety.rs +69 -0
- c2r-1.0.0/src/analysis/traits.rs +32 -0
- c2r-1.0.0/src/analyzer.rs +321 -0
- c2r-1.0.0/src/bench_harness.rs +39 -0
- c2r-1.0.0/src/clang_frontend_mock.rs +68 -0
- c2r-1.0.0/src/cpp_parser.rs +112 -0
- c2r-1.0.0/src/disjoint_set.rs +75 -0
- c2r-1.0.0/src/lib.rs +53 -0
- c2r-1.0.0/src/piir.rs +115 -0
- c2r-1.0.0/temp_cpp_check/src/main.cpp +12 -0
- c2r-1.0.0/temp_cpp_check/src/math/vector.h +5 -0
- c2r-1.0.0/tests/cpp_samples/01_basic_box.cpp +5 -0
- c2r-1.0.0/tests/cpp_samples/02_leak.cpp +5 -0
- c2r-1.0.0/tests/cpp_samples/03_double_free.cpp +5 -0
- c2r-1.0.0/tests/cpp_samples/04_aliasing.cpp +4 -0
- c2r-1.0.0/tests/cpp_samples/05_doubly_linked_list.cpp +13 -0
- c2r-1.0.0/tests/cpp_samples/06_threads.cpp +10 -0
c2r-1.0.0/.gitignore
ADDED
c2r-1.0.0/.idea/c2r.iml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
<component name="PyDocumentationSettings">
|
|
9
|
+
<option name="format" value="PLAIN" />
|
|
10
|
+
<option name="myDocStringFormat" value="Plain" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
c2r-1.0.0/.idea/misc.xml
ADDED
c2r-1.0.0/.idea/vcs.xml
ADDED
c2r-1.0.0/Cargo.lock
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.4"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "anstream"
|
|
16
|
+
version = "0.6.21"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"anstyle",
|
|
21
|
+
"anstyle-parse",
|
|
22
|
+
"anstyle-query",
|
|
23
|
+
"anstyle-wincon",
|
|
24
|
+
"colorchoice",
|
|
25
|
+
"is_terminal_polyfill",
|
|
26
|
+
"utf8parse",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "anstyle"
|
|
31
|
+
version = "1.0.13"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "anstyle-parse"
|
|
37
|
+
version = "0.2.7"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"utf8parse",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[[package]]
|
|
45
|
+
name = "anstyle-query"
|
|
46
|
+
version = "1.1.5"
|
|
47
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
48
|
+
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
|
49
|
+
dependencies = [
|
|
50
|
+
"windows-sys",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[[package]]
|
|
54
|
+
name = "anstyle-wincon"
|
|
55
|
+
version = "3.0.11"
|
|
56
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
57
|
+
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
|
58
|
+
dependencies = [
|
|
59
|
+
"anstyle",
|
|
60
|
+
"once_cell_polyfill",
|
|
61
|
+
"windows-sys",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[[package]]
|
|
65
|
+
name = "autocfg"
|
|
66
|
+
version = "1.5.0"
|
|
67
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
|
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "bitflags"
|
|
72
|
+
version = "2.10.0"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "c2r_core"
|
|
78
|
+
version = "1.0.0"
|
|
79
|
+
dependencies = [
|
|
80
|
+
"env_logger",
|
|
81
|
+
"log",
|
|
82
|
+
"proc-macro2",
|
|
83
|
+
"pyo3",
|
|
84
|
+
"quote",
|
|
85
|
+
"regex",
|
|
86
|
+
"syn",
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
[[package]]
|
|
90
|
+
name = "cfg-if"
|
|
91
|
+
version = "1.0.4"
|
|
92
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
93
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
94
|
+
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "colorchoice"
|
|
97
|
+
version = "1.0.4"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
|
100
|
+
|
|
101
|
+
[[package]]
|
|
102
|
+
name = "env_filter"
|
|
103
|
+
version = "0.1.4"
|
|
104
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
105
|
+
checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2"
|
|
106
|
+
dependencies = [
|
|
107
|
+
"log",
|
|
108
|
+
"regex",
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[[package]]
|
|
112
|
+
name = "env_logger"
|
|
113
|
+
version = "0.11.8"
|
|
114
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
115
|
+
checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
|
|
116
|
+
dependencies = [
|
|
117
|
+
"anstream",
|
|
118
|
+
"anstyle",
|
|
119
|
+
"env_filter",
|
|
120
|
+
"jiff",
|
|
121
|
+
"log",
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
[[package]]
|
|
125
|
+
name = "heck"
|
|
126
|
+
version = "0.4.1"
|
|
127
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
128
|
+
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "indoc"
|
|
132
|
+
version = "2.0.7"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
|
135
|
+
dependencies = [
|
|
136
|
+
"rustversion",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[[package]]
|
|
140
|
+
name = "is_terminal_polyfill"
|
|
141
|
+
version = "1.70.2"
|
|
142
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
143
|
+
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
|
144
|
+
|
|
145
|
+
[[package]]
|
|
146
|
+
name = "jiff"
|
|
147
|
+
version = "0.2.18"
|
|
148
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
149
|
+
checksum = "e67e8da4c49d6d9909fe03361f9b620f58898859f5c7aded68351e85e71ecf50"
|
|
150
|
+
dependencies = [
|
|
151
|
+
"jiff-static",
|
|
152
|
+
"log",
|
|
153
|
+
"portable-atomic",
|
|
154
|
+
"portable-atomic-util",
|
|
155
|
+
"serde_core",
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
[[package]]
|
|
159
|
+
name = "jiff-static"
|
|
160
|
+
version = "0.2.18"
|
|
161
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
162
|
+
checksum = "e0c84ee7f197eca9a86c6fd6cb771e55eb991632f15f2bc3ca6ec838929e6e78"
|
|
163
|
+
dependencies = [
|
|
164
|
+
"proc-macro2",
|
|
165
|
+
"quote",
|
|
166
|
+
"syn",
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
[[package]]
|
|
170
|
+
name = "libc"
|
|
171
|
+
version = "0.2.180"
|
|
172
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
173
|
+
checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
|
|
174
|
+
|
|
175
|
+
[[package]]
|
|
176
|
+
name = "lock_api"
|
|
177
|
+
version = "0.4.14"
|
|
178
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
179
|
+
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
|
180
|
+
dependencies = [
|
|
181
|
+
"scopeguard",
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
[[package]]
|
|
185
|
+
name = "log"
|
|
186
|
+
version = "0.4.29"
|
|
187
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
188
|
+
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
|
189
|
+
|
|
190
|
+
[[package]]
|
|
191
|
+
name = "memchr"
|
|
192
|
+
version = "2.7.6"
|
|
193
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
194
|
+
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
|
195
|
+
|
|
196
|
+
[[package]]
|
|
197
|
+
name = "memoffset"
|
|
198
|
+
version = "0.9.1"
|
|
199
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
200
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
201
|
+
dependencies = [
|
|
202
|
+
"autocfg",
|
|
203
|
+
]
|
|
204
|
+
|
|
205
|
+
[[package]]
|
|
206
|
+
name = "once_cell"
|
|
207
|
+
version = "1.21.3"
|
|
208
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
209
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
210
|
+
|
|
211
|
+
[[package]]
|
|
212
|
+
name = "once_cell_polyfill"
|
|
213
|
+
version = "1.70.2"
|
|
214
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
215
|
+
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
|
216
|
+
|
|
217
|
+
[[package]]
|
|
218
|
+
name = "parking_lot"
|
|
219
|
+
version = "0.12.5"
|
|
220
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
221
|
+
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
|
|
222
|
+
dependencies = [
|
|
223
|
+
"lock_api",
|
|
224
|
+
"parking_lot_core",
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
[[package]]
|
|
228
|
+
name = "parking_lot_core"
|
|
229
|
+
version = "0.9.12"
|
|
230
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
231
|
+
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
|
232
|
+
dependencies = [
|
|
233
|
+
"cfg-if",
|
|
234
|
+
"libc",
|
|
235
|
+
"redox_syscall",
|
|
236
|
+
"smallvec",
|
|
237
|
+
"windows-link",
|
|
238
|
+
]
|
|
239
|
+
|
|
240
|
+
[[package]]
|
|
241
|
+
name = "portable-atomic"
|
|
242
|
+
version = "1.13.0"
|
|
243
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
244
|
+
checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950"
|
|
245
|
+
|
|
246
|
+
[[package]]
|
|
247
|
+
name = "portable-atomic-util"
|
|
248
|
+
version = "0.2.4"
|
|
249
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
250
|
+
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
|
|
251
|
+
dependencies = [
|
|
252
|
+
"portable-atomic",
|
|
253
|
+
]
|
|
254
|
+
|
|
255
|
+
[[package]]
|
|
256
|
+
name = "proc-macro2"
|
|
257
|
+
version = "1.0.106"
|
|
258
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
259
|
+
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
260
|
+
dependencies = [
|
|
261
|
+
"unicode-ident",
|
|
262
|
+
]
|
|
263
|
+
|
|
264
|
+
[[package]]
|
|
265
|
+
name = "pyo3"
|
|
266
|
+
version = "0.20.3"
|
|
267
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
268
|
+
checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233"
|
|
269
|
+
dependencies = [
|
|
270
|
+
"cfg-if",
|
|
271
|
+
"indoc",
|
|
272
|
+
"libc",
|
|
273
|
+
"memoffset",
|
|
274
|
+
"parking_lot",
|
|
275
|
+
"portable-atomic",
|
|
276
|
+
"pyo3-build-config",
|
|
277
|
+
"pyo3-ffi",
|
|
278
|
+
"pyo3-macros",
|
|
279
|
+
"unindent",
|
|
280
|
+
]
|
|
281
|
+
|
|
282
|
+
[[package]]
|
|
283
|
+
name = "pyo3-build-config"
|
|
284
|
+
version = "0.20.3"
|
|
285
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
286
|
+
checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7"
|
|
287
|
+
dependencies = [
|
|
288
|
+
"once_cell",
|
|
289
|
+
"target-lexicon",
|
|
290
|
+
]
|
|
291
|
+
|
|
292
|
+
[[package]]
|
|
293
|
+
name = "pyo3-ffi"
|
|
294
|
+
version = "0.20.3"
|
|
295
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
296
|
+
checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa"
|
|
297
|
+
dependencies = [
|
|
298
|
+
"libc",
|
|
299
|
+
"pyo3-build-config",
|
|
300
|
+
]
|
|
301
|
+
|
|
302
|
+
[[package]]
|
|
303
|
+
name = "pyo3-macros"
|
|
304
|
+
version = "0.20.3"
|
|
305
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
306
|
+
checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158"
|
|
307
|
+
dependencies = [
|
|
308
|
+
"proc-macro2",
|
|
309
|
+
"pyo3-macros-backend",
|
|
310
|
+
"quote",
|
|
311
|
+
"syn",
|
|
312
|
+
]
|
|
313
|
+
|
|
314
|
+
[[package]]
|
|
315
|
+
name = "pyo3-macros-backend"
|
|
316
|
+
version = "0.20.3"
|
|
317
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
318
|
+
checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185"
|
|
319
|
+
dependencies = [
|
|
320
|
+
"heck",
|
|
321
|
+
"proc-macro2",
|
|
322
|
+
"pyo3-build-config",
|
|
323
|
+
"quote",
|
|
324
|
+
"syn",
|
|
325
|
+
]
|
|
326
|
+
|
|
327
|
+
[[package]]
|
|
328
|
+
name = "quote"
|
|
329
|
+
version = "1.0.44"
|
|
330
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
331
|
+
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
|
|
332
|
+
dependencies = [
|
|
333
|
+
"proc-macro2",
|
|
334
|
+
]
|
|
335
|
+
|
|
336
|
+
[[package]]
|
|
337
|
+
name = "redox_syscall"
|
|
338
|
+
version = "0.5.18"
|
|
339
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
340
|
+
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
|
341
|
+
dependencies = [
|
|
342
|
+
"bitflags",
|
|
343
|
+
]
|
|
344
|
+
|
|
345
|
+
[[package]]
|
|
346
|
+
name = "regex"
|
|
347
|
+
version = "1.12.2"
|
|
348
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
349
|
+
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
|
350
|
+
dependencies = [
|
|
351
|
+
"aho-corasick",
|
|
352
|
+
"memchr",
|
|
353
|
+
"regex-automata",
|
|
354
|
+
"regex-syntax",
|
|
355
|
+
]
|
|
356
|
+
|
|
357
|
+
[[package]]
|
|
358
|
+
name = "regex-automata"
|
|
359
|
+
version = "0.4.13"
|
|
360
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
361
|
+
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
|
362
|
+
dependencies = [
|
|
363
|
+
"aho-corasick",
|
|
364
|
+
"memchr",
|
|
365
|
+
"regex-syntax",
|
|
366
|
+
]
|
|
367
|
+
|
|
368
|
+
[[package]]
|
|
369
|
+
name = "regex-syntax"
|
|
370
|
+
version = "0.8.8"
|
|
371
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
372
|
+
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
|
373
|
+
|
|
374
|
+
[[package]]
|
|
375
|
+
name = "rustversion"
|
|
376
|
+
version = "1.0.22"
|
|
377
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
378
|
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
379
|
+
|
|
380
|
+
[[package]]
|
|
381
|
+
name = "scopeguard"
|
|
382
|
+
version = "1.2.0"
|
|
383
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
384
|
+
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
385
|
+
|
|
386
|
+
[[package]]
|
|
387
|
+
name = "serde_core"
|
|
388
|
+
version = "1.0.228"
|
|
389
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
390
|
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
|
391
|
+
dependencies = [
|
|
392
|
+
"serde_derive",
|
|
393
|
+
]
|
|
394
|
+
|
|
395
|
+
[[package]]
|
|
396
|
+
name = "serde_derive"
|
|
397
|
+
version = "1.0.228"
|
|
398
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
399
|
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|
400
|
+
dependencies = [
|
|
401
|
+
"proc-macro2",
|
|
402
|
+
"quote",
|
|
403
|
+
"syn",
|
|
404
|
+
]
|
|
405
|
+
|
|
406
|
+
[[package]]
|
|
407
|
+
name = "smallvec"
|
|
408
|
+
version = "1.15.1"
|
|
409
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
410
|
+
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|
411
|
+
|
|
412
|
+
[[package]]
|
|
413
|
+
name = "syn"
|
|
414
|
+
version = "2.0.114"
|
|
415
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
416
|
+
checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
|
|
417
|
+
dependencies = [
|
|
418
|
+
"proc-macro2",
|
|
419
|
+
"quote",
|
|
420
|
+
"unicode-ident",
|
|
421
|
+
]
|
|
422
|
+
|
|
423
|
+
[[package]]
|
|
424
|
+
name = "target-lexicon"
|
|
425
|
+
version = "0.12.16"
|
|
426
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
427
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
428
|
+
|
|
429
|
+
[[package]]
|
|
430
|
+
name = "unicode-ident"
|
|
431
|
+
version = "1.0.22"
|
|
432
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
433
|
+
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
|
434
|
+
|
|
435
|
+
[[package]]
|
|
436
|
+
name = "unindent"
|
|
437
|
+
version = "0.2.4"
|
|
438
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
439
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
440
|
+
|
|
441
|
+
[[package]]
|
|
442
|
+
name = "utf8parse"
|
|
443
|
+
version = "0.2.2"
|
|
444
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
445
|
+
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|
446
|
+
|
|
447
|
+
[[package]]
|
|
448
|
+
name = "windows-link"
|
|
449
|
+
version = "0.2.1"
|
|
450
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
451
|
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
452
|
+
|
|
453
|
+
[[package]]
|
|
454
|
+
name = "windows-sys"
|
|
455
|
+
version = "0.61.2"
|
|
456
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
457
|
+
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
|
458
|
+
dependencies = [
|
|
459
|
+
"windows-link",
|
|
460
|
+
]
|
c2r-1.0.0/Cargo.toml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "c2r_core"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Core Rust library for the c2r transpiler"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
repository = "https://github.com/ferrum/c2r"
|
|
9
|
+
|
|
10
|
+
[lib]
|
|
11
|
+
name = "c2r_core"
|
|
12
|
+
crate-type = ["cdylib", "rlib"]
|
|
13
|
+
|
|
14
|
+
[dependencies]
|
|
15
|
+
pyo3 = { version = "0.20", features = ["extension-module"] }
|
|
16
|
+
regex = "1.10"
|
|
17
|
+
log = "0.4"
|
|
18
|
+
env_logger = "0.11"
|
|
19
|
+
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
|
20
|
+
quote = "1.0"
|
|
21
|
+
proc-macro2 = "1.0"
|
|
22
|
+
|
|
23
|
+
[[bin]]
|
|
24
|
+
name = "bench_runner"
|
|
25
|
+
path = "benches/run_bench.rs"
|
c2r-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: c2r
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
10
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Requires-Dist: click
|
|
13
|
+
Summary: Deterministic C++ to Rust Transpiler with Industrial-Grade Static Analysis
|
|
14
|
+
Author-email: Ferrum Team <dev@ferrum.io>
|
|
15
|
+
License: MIT
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
18
|
+
|
|
19
|
+
# c2r: The Industrial C++ to Rust Transpiler
|
|
20
|
+
|
|
21
|
+
**c2r** (formerly Ferrum) is a deterministic, static-analysis driven tool designed to migrate legacy C++ codebases to idiomatic, safe Rust. Unlike LLM-based solutions that hallucinate, c2r uses rigorous mathematical models to prove ownership and lifetimes.
|
|
22
|
+
|
|
23
|
+
## 🚀 Features
|
|
24
|
+
|
|
25
|
+
* **Deterministic Translation**: No AI guessing. Uses Steensgaard's and Andersen's analysis for aliasing.
|
|
26
|
+
* **Ownership Reconstruction**: Infers `Box<T>`, `Arc<T>`, `Rc<T>` based on usage patterns.
|
|
27
|
+
* **Thread Safety Analysis**: Automatically detects data races and injects `Arc<Mutex<T>>`.
|
|
28
|
+
* **Cycle Detection**: Identifies reference cycles (SCCs) and suggests `Weak<T>` or `RefCell<T>`.
|
|
29
|
+
* **Smart Pointers**: Maps `std::unique_ptr` and `std::shared_ptr` to Rust equivalents.
|
|
30
|
+
* **Safety Audit**: Reports a "Safety Score" indicating the ratio of safe/unsafe code generated.
|
|
31
|
+
|
|
32
|
+
## 📦 Installation
|
|
33
|
+
|
|
34
|
+
c2r is available as a Python package with a high-performance Rust backend.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install c2r
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 🛠 Usage
|
|
41
|
+
|
|
42
|
+
c2r provides a CLI to migrate projects.
|
|
43
|
+
|
|
44
|
+
### Migrate a Project
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
c2r migrate ./legacy_cpp_project -o ./new_rust_project
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This command will:
|
|
51
|
+
1. Analyze all `.cpp` and `.h` files in the input directory.
|
|
52
|
+
2. Generate a valid Cargo project structure (`src/models`, `src/utils`).
|
|
53
|
+
3. Create a `Cargo.toml` with necessary production dependencies (`tokio`, `serde`, `parking_lot`).
|
|
54
|
+
4. Transpile the code, resolving include dependencies and type definitions.
|
|
55
|
+
|
|
56
|
+
## 🚀 Publishing to PyPI
|
|
57
|
+
|
|
58
|
+
To publish a new version of `c2r`, ensure you have `maturin` installed.
|
|
59
|
+
|
|
60
|
+
1. **Build Release Artifacts**:
|
|
61
|
+
```bash
|
|
62
|
+
maturin build --release
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. **Publish to PyPI**:
|
|
66
|
+
```bash
|
|
67
|
+
maturin publish
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 🏗 Architecture
|
|
71
|
+
|
|
72
|
+
c2r operates on a multi-pass architecture:
|
|
73
|
+
|
|
74
|
+
1. **Ingestion (Industrial Frontend)**: Simulates Clang AST parsing to generate a Property-Oriented Intermediate Representation (PIIR).
|
|
75
|
+
2. **Points-To Analysis**:
|
|
76
|
+
* **Steensgaard ($O(N \alpha(N))$)**: Fast partitioning of memory regions.
|
|
77
|
+
* **Andersen ($O(N^3)$)**: Precise subset-based constraint solving for aliasing.
|
|
78
|
+
3. **Region Inference (Tofte-Talpin)**: Infers lifetimes (`'a`) and scopes.
|
|
79
|
+
4. **Cycle Detection**: Detects Strongly Connected Components using Tarjan's algorithm concepts.
|
|
80
|
+
5. **Thread Safety Pass**: Simulates execution flow to detect concurrent mutations.
|
|
81
|
+
6. **Code Generation**: Uses `syn` and `quote` to construct a valid Rust AST.
|
|
82
|
+
|
|
83
|
+
## 📊 Benchmarks
|
|
84
|
+
|
|
85
|
+
c2r includes a built-in benchmarking harness to verify the scalability of its analysis algorithms.
|
|
86
|
+
|
|
87
|
+
* **100 Pointers**: ~0.2ms
|
|
88
|
+
* **1,000 Pointers**: ~2.2ms
|
|
89
|
+
* **5,000 Pointers**: ~11.4ms
|
|
90
|
+
|
|
91
|
+
## 📄 License
|
|
92
|
+
|
|
93
|
+
MIT License.
|
|
94
|
+
|