Skip to content

Commit e65e265

Browse files
authored
Replace string matcher with AST matcher (#527)
Closes #447, depends on #529 Rules are matched on the AST instead of on printed strings. string_matcher and ir_src.json are deleted. cpp-rule-prepocessor is replaced by cpp-rule-indexer which walks the rules, compiles them, and creates an index (#451). --- The bodies of the used rules are loaded in the TU to match against their usages. A rule matches a usage if calling the rule with the operands of the usage would end up calling the same declaration as the usage. Concretely: 1. The usages is keyed by its declaration: `Member{class, member_name}`, `Constructor{class}`, `Unqualified{name}`. In Member we keep: data members, static members, function members. In Unqualified we keep everything outside a class: free function, macro, enumerators, etc. Every loaded rule with the same key is a candidate. 2. Between a usage and a candidate rule, let clang deduce the template arguments of a rule by calling the rule with the usage's operands. If this does not work (T1, T2, not used in the argument list), deduce using the return type. 3. The deduced arguments are subtituted in the rule's return expression. If the resolved expressoin has the same declaration as the usage, then it's a match. 4. If several rules mtach, non-template rules win over template rules. Otherwise let clang's partial ordering pick the most specialized one For example: ```cpp std::vector<int> v; v.push_back(3); template <typename T1> void f1(std::vector<T1> &a0, const T1& a1) { return a0.push_back(a1); } template <typename T1> void f2(std::vector<T1> &a0, T1&& a1) { return a0.push_back(std::move(a1)); } ``` At load time: both f1 and f2 are stored under `Member{vector, push_back}`. 1. Mapper calls `RuleRegistry::Search(expr)` which reaches `RuleRegistry::findExpr`. The decl of the usage (`vector<int>::push_back(int&&)`) is also keyed under `Member{vector, push_back}`. 2. `Match` takes the operands `[v, 3]` from the usage and gets: i. `f1(vector<T1>&, const T1&)` -> `T1 = int` ii. `f2(vector<T1>&, T1&&)` -> `T1 = int` 3. The deduced tempalate arguments are inserted in the return expression: i. f1: `a0.push_back(a1)` calls `push_back(const int&)`. Does not match the usage decl. ii. f2: `a0.push_back(std::move(a1))` calls `push_back(int&&)`. It matches the usage decl. 4. Only f2 is matches so there is no need for disambiguation. Type rules work the same. The usage type is deduced against the rule's alias with sugar preferred over the canonical type. --- Not all rules have deducible arguments, for example `std::map<T1, T2>::const_iterator`, in general every template argument that sits on the left of `::` is non-deducible. Such rules need changes so they become deducible: ```diff - template <typename T1, typename T2> - using t2 = typename std::map<T1, T2>::const_iterator; + template <typename It, typename T1 = KeyOf<It>, typename T2 = MappedOf<It>, + typename = SameAs<It, typename std::map<T1, T2>::const_iterator>> + using t2 = It; ``` Both T1 and T2 originally sat in non-deducible contexts. The new syntax works like this: 1. The iterator is taken as plain `It` which is always deducible 2. `T1` and `T2` are computed from `It` using iterator traits: `T1 = It::value_type::first_type` and `T2 = It::value_type::second_type` 3. `SameAs` constraints the rule only for const iterators of `std::map` so that they don't conflict with the rules for non-cosnt iterators for `std::map` or other map types --- Performance | branch | unit (500 TUs) | woff2 (20 TUs) | brunsli (17 TUs) | description | | --- | --- | --- | --- | --- | | master (unsafe + refcount) (s) | 33.2 | 11.9 | 26.5 | | | ast-matcher (unsafe + refcount) (s) | 32.7 | 11.6 | 25.6 | | | **speedup** per TU (ms)| 0.5 | 7.5 | 26.5 | (master - ast-matcher) / 2 / number-of-TUs * 1000 | | total **speedup** (%) | 1.5 | 2.5 | 3.4 | (master - ast-matcher) / master * 100 | --- Some nice implications for rule writing: 1. deque_cxx11 and vector_cxx11 disappear. Instead we change the definition of functions: ```cpp auto f12(std::deque<T1> &o, Init<T1, Args> &&...args) // in C++11 the return type is deduced as void // post-C++11 the return type is deduced as reference type -> decltype(o.emplace_back(std::forward<Args>(args)...)) { return o.emplace_back(std::forward<Args>(args)...); } ``` 2. We don't need to write rules for `T*`, `T**`, `T&`, `const T*`, etc. We only write one rule for T and the converter takes care of the rest, see `rules/builtin_types/src.c` and `rules/iostream/src.cpp` 3. We only write one constructor for std::pair that forwards the arguments, see `rules/pair/src.cpp` 4. We only write rules for `vector<T, A>`, rules for `vector<T>` are not needed. This drops a lot of useless rules in `rules/vector/src.cpp` This opens another new interesting opportunity: writing rules for multiple statements at once. Now that we match AST subtrees we can match an entire subtree at once and write more idiomatic rules. Also we can move some of the converter translations in rules: for exmaple binary operators which have a very complicated visitor today. --- Next steps after this PR: 1. The AST type matcher stops walking the sugar typedefs and starts translating rules for each typedef: off_t, value_type, time_t, etc 2. Stop masking NTTPs in rules (#435) 3. Add a cache on top of mapper to avoid deduction for results we already mapped
1 parent 4850ba3 commit e65e265

105 files changed

Lines changed: 2344 additions & 4421 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CMakeLists.txt‎

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ add_custom_target("check"
162162
DEPENDS check-libcc2rs check-libcc2rs-macros check-unit
163163
)
164164

165-
set(RULES_IR_DIR "${CMAKE_BINARY_DIR}/rules")
166-
167165
set(RUSTLS_HEADER "${PROJECT_SOURCE_DIR}/rules/rustls/rustls.h")
168166
set(BROTLI_HEADERS
169167
"${PROJECT_SOURCE_DIR}/rules/brotli/brotli/decode.h"
@@ -222,53 +220,33 @@ file(GLOB rule_subdirs CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/rules/*)
222220
file(GLOB rule_common_headers CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/rules/common/*.h)
223221
file(GLOB rule_indexer_sources CONFIGURE_DEPENDS
224222
${PROJECT_SOURCE_DIR}/cpp2rust/rule_preprocessing/*
225-
${PROJECT_SOURCE_DIR}/cpp2rust/converter/rules/rules_loader.*)
223+
${PROJECT_SOURCE_DIR}/cpp2rust/converter/rules/rules_loader.*
224+
${PROJECT_SOURCE_DIR}/cpp2rust/converter/rules/decls.*)
226225
set(_common_headers)
227226
foreach(_header IN LISTS rule_common_headers)
228227
list(APPEND _common_headers --common-header=${_header})
229228
endforeach()
230-
set(cpp_rules_ir_outputs)
231229
set(rules_index_parts)
232230
set(rules_index_parts_dir ${CMAKE_BINARY_DIR}/rules_index/parts)
231+
set(RULES_IR_DIR "${CMAKE_BINARY_DIR}/rules")
233232
set(rust_rules_ir_outputs)
234233
foreach(_rule_dir IN LISTS rule_subdirs)
235234
file(GLOB _cpp_srcs ${_rule_dir}/src.c ${_rule_dir}/src.cpp ${_rule_dir}/src_cxx*.cpp)
236235
if(NOT _cpp_srcs)
237236
continue()
238237
endif()
239238
get_filename_component(_rule_name ${_rule_dir} NAME)
240-
set(_out_dir ${RULES_IR_DIR}/${_rule_name})
241-
set(_cpp_out ${_out_dir}/ir_src.json)
242-
set(_cxxflags)
243-
set(_cxxflags_file)
244-
if(EXISTS ${_rule_dir}/cxxflags)
245-
set(_cxxflags_file ${_rule_dir}/cxxflags)
246-
file(STRINGS ${_cxxflags_file} _flags)
247-
foreach(_flag IN LISTS _flags)
248-
list(APPEND _cxxflags --cxxflags=${_flag})
249-
endforeach()
250-
endif()
239+
set(_part ${rules_index_parts_dir}/${_rule_name}.json)
251240
add_custom_command(
252-
OUTPUT ${_cpp_out}
253-
COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir}
254-
COMMAND $<TARGET_FILE:cpp-rule-preprocessor> --dir ${_rule_dir} --out ${_cpp_out} ${_cxxflags}
255-
DEPENDS ${_cpp_srcs} ${_cxxflags_file} ${rule_common_headers} ${PROJECT_SOURCE_DIR}/cpp2rust/rule_preprocessing/cpp_rule_preprocessor.cpp ${RUSTLS_HEADER} ${BROTLI_HEADERS}
241+
OUTPUT ${_part}
242+
COMMAND ${CMAKE_COMMAND} -E make_directory ${rules_index_parts_dir}
243+
COMMAND $<TARGET_FILE:cpp-rule-indexer> --dir ${_rule_dir} -o ${_part}
244+
DEPENDS ${_cpp_srcs} ${rule_common_headers} ${rule_indexer_sources} ${RUSTLS_HEADER} ${BROTLI_HEADERS}
256245
VERBATIM
257246
)
258-
list(APPEND cpp_rules_ir_outputs ${_cpp_out})
259-
260-
if(NOT _rule_name STREQUAL "builtin_types")
261-
set(_part ${rules_index_parts_dir}/${_rule_name}.json)
262-
add_custom_command(
263-
OUTPUT ${_part}
264-
COMMAND ${CMAKE_COMMAND} -E make_directory ${rules_index_parts_dir}
265-
COMMAND $<TARGET_FILE:cpp-rule-indexer> --dir ${_rule_dir} -o ${_part}
266-
DEPENDS ${_cpp_srcs} ${rule_common_headers} ${rule_indexer_sources} ${RUSTLS_HEADER} ${BROTLI_HEADERS}
267-
VERBATIM
268-
)
269-
list(APPEND rules_index_parts ${_part})
270-
endif()
247+
list(APPEND rules_index_parts ${_part})
271248

249+
set(_out_dir ${RULES_IR_DIR}/${_rule_name})
272250
set(_rust_srcs)
273251
set(_rust_out)
274252
if(EXISTS ${_rule_dir}/tgt_unsafe.rs)
@@ -297,8 +275,6 @@ foreach(_rule_dir IN LISTS rule_subdirs)
297275
list(APPEND rust_rules_ir_outputs ${_rust_out})
298276
endforeach()
299277

300-
add_custom_target("preprocess-cpp-rules" ALL DEPENDS ${cpp_rules_ir_outputs})
301-
302278
set(cpp_rules_index_outputs ${CMAKE_BINARY_DIR}/rules_index/c.json ${CMAKE_BINARY_DIR}/rules_index/cpp.json)
303279
add_custom_command(
304280
OUTPUT ${cpp_rules_index_outputs}

‎cpp2rust/CMakeLists.txt‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_compile_definitions(cpp2rust_core PUBLIC "-DCLANG_RESOURCE_DIR=\"${LLVM_L
2020
target_compile_definitions(cpp2rust_core PUBLIC "-DCOMPAT_INCLUDE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/compat\"")
2121
target_compile_definitions(cpp2rust_core PUBLIC "-DRULES_SRC_DIR=\"${PROJECT_SOURCE_DIR}/rules\"")
2222
target_compile_definitions(cpp2rust_core PUBLIC "-DRULES_INDEX_DIR=\"${CMAKE_BINARY_DIR}/rules_index\"")
23+
target_compile_definitions(cpp2rust_core PUBLIC "-DRULES_IR_DIR=\"${CMAKE_BINARY_DIR}/rules\"")
2324
target_compile_definitions(cpp2rust_core PUBLIC "-DRUST_STABLE_VERSION=\"${RUST_STABLE_VERSION}\"")
2425

2526
if (APPLE)
@@ -37,10 +38,6 @@ target_link_libraries(cpp2rust_core PUBLIC ${llvm_libs})
3738
add_clang_executable(cpp2rust PARTIAL_SOURCES_INTENDED cpp2rust.cpp)
3839
target_link_libraries(cpp2rust PRIVATE cpp2rust_core)
3940

40-
add_clang_executable(cpp-rule-preprocessor PARTIAL_SOURCES_INTENDED
41-
rule_preprocessing/cpp_rule_preprocessor.cpp)
42-
target_link_libraries(cpp-rule-preprocessor PRIVATE cpp2rust_core)
43-
4441
add_clang_executable(cpp-rule-indexer PARTIAL_SOURCES_INTENDED
4542
rule_preprocessing/cpp_rule_indexer.cpp)
4643
target_link_libraries(cpp-rule-indexer PRIVATE cpp2rust_core)

‎cpp2rust/ast_consumer.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
#include <llvm/Support/ErrorHandling.h>
77

88
#include "converter/converter.h"
9+
#include "converter/rules/registry.h"
910

1011
namespace cpp2rust {
1112
void ASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) {
1213
if (CI_.getDiagnostics().hasErrorOccurred()) {
1314
llvm::report_fatal_error(
1415
"the translation unit and its loaded rules do not compile");
1516
}
17+
RuleRegistry::Load(CI_.getSema(), model_);
1618
auto converter = CreateConverter(rs_code_, ctx, model_, rules_dir_);
1719
converter->SetSema(CI_.getSema());
1820
if (first_) {

‎cpp2rust/converter/converter.cpp‎

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ bool Converter::Convert(clang::QualType qual_type) {
135135
return TraverseType(qual_type);
136136
}
137137

138+
std::string Converter::GetUnboxedTypeAsString(clang::QualType qual_type) {
139+
return ToString(qual_type);
140+
}
141+
138142
bool Converter::ConvertMappedType(clang::QualType qual_type) {
139143
std::string type_as_string = Mapper::Map(*this, qual_type);
140144
if (type_as_string == token::kIgnoreRule) {
@@ -182,7 +186,11 @@ bool Converter::VisitRecordType(clang::RecordType *type) {
182186
}
183187

184188
StrCat(GetRecordName(decl));
185-
RuleRegistry::AddRuleForUserDefinedType(ctx_, decl);
189+
return false;
190+
}
191+
192+
bool Converter::VisitEnumType(clang::EnumType *type) {
193+
StrCat(GetRecordName(type->getDecl()));
186194
return false;
187195
}
188196

@@ -738,11 +746,19 @@ bool Converter::IsPassThroughRule(clang::Expr *expr) const {
738746
rule->body[0]);
739747
}
740748

741-
bool Converter::RecordDerivesCopy(const clang::RecordDecl *decl) const {
742-
auto *derives =
743-
RuleRegistry::MappedDerives(ctx_, ctx_.getCanonicalTagType(decl));
744-
return derives &&
745-
std::find(derives->begin(), derives->end(), "Copy") != derives->end();
749+
bool Converter::RecordDerivesCopy(const clang::RecordDecl *decl) {
750+
if (auto rule =
751+
RuleRegistry::Search(ctx_, ctx_.getCanonicalTagType(decl)).first) {
752+
auto &derives = rule->type_info.derives;
753+
return std::find(derives.begin(), derives.end(), "Copy") != derives.end();
754+
}
755+
decl = decl->getDefinition();
756+
if (!decl) {
757+
return false;
758+
}
759+
auto attrs = GetStructAttributes(decl);
760+
return std::find(attrs.begin(), attrs.end(), std::string_view("Copy")) !=
761+
attrs.end();
746762
}
747763

748764
bool Converter::RecordHasCopyableFields(const clang::RecordDecl *decl) {
@@ -801,7 +817,6 @@ bool Converter::VisitRecordDecl(clang::RecordDecl *decl) {
801817
return false;
802818
}
803819

804-
RuleRegistry::AddRuleForUserDefinedType(ctx_, decl);
805820
EmitRustStructOrUnion(decl);
806821

807822
return false;
@@ -868,9 +883,6 @@ void Converter::EmitRustStructOrUnion(clang::RecordDecl *decl) {
868883
EmitReprC(decl);
869884
}
870885
auto attrs = GetStructAttributes(decl);
871-
RuleRegistry::SetDerives(
872-
ctx_, ctx_.getCanonicalTagType(decl),
873-
std::vector<std::string>(attrs.begin(), attrs.end()));
874886
StrCat("#[derive(");
875887
for (auto *attr : attrs) {
876888
StrCat(attr, ',');
@@ -968,9 +980,6 @@ void Converter::EmitReprC(clang::RecordDecl *decl) {
968980
void Converter::EmitRustUnion(clang::RecordDecl *decl) {
969981
EmitReprC(decl);
970982
auto attrs = GetStructAttributes(decl);
971-
RuleRegistry::SetDerives(
972-
ctx_, ctx_.getCanonicalTagType(decl),
973-
std::vector<std::string>(attrs.begin(), attrs.end()));
974983
StrCat("#[derive(");
975984
for (auto *attr : attrs) {
976985
StrCat(attr, ',');
@@ -994,7 +1003,6 @@ void Converter::EmitRustUnion(clang::RecordDecl *decl) {
9941003
bool Converter::VisitCXXRecordDecl(clang::CXXRecordDecl *decl) {
9951004
decl->dump(log());
9961005

997-
RuleRegistry::AddRuleForUserDefinedType(ctx_, decl);
9981006
if (!IsConvertibleCXXRecordDecl(decl)) {
9991007
return false;
10001008
}
@@ -1950,7 +1958,7 @@ bool Converter::VisitCallExpr(clang::CallExpr *expr) {
19501958
}
19511959

19521960
auto ty = GetReturnTypeOfFunction(expr);
1953-
auto ref = clang::dyn_cast<clang::ReferenceType>(ty);
1961+
auto ref = ty->getAs<clang::ReferenceType>();
19541962

19551963
if (ref && !isAddrOf() && !isVoid()) {
19561964
{
@@ -3220,6 +3228,10 @@ std::string Converter::ConvertDeclRef(clang::Expr *expr,
32203228

32213229
if (ShouldReplaceWithMappedBody(decl)) {
32223230
if (auto str = GetMappedAsString(expr); !str.empty()) {
3231+
if (RuleRegistry::ReturnsReference(expr) && !isAddrOf()) {
3232+
return std::format("({}{})", GetPointerDerefPrefix(expr->getType()),
3233+
str);
3234+
}
32233235
return str;
32243236
}
32253237
}
@@ -3979,7 +3991,6 @@ bool Converter::VisitEnumDecl(clang::EnumDecl *decl) {
39793991
if (Mapper::Contains(ctx_, ctx_.getCanonicalTagType(decl))) {
39803992
return false;
39813993
}
3982-
RuleRegistry::AddRuleForUserDefinedType(ctx_, decl);
39833994
auto name = GetRecordName(decl);
39843995
StrCat(std::format("pub type {} = {};", name,
39853996
GetUnsafeTypeAsString(decl->getIntegerType())));
@@ -5344,13 +5355,10 @@ std::string
53445355
Converter::ConvertInitFragment(clang::Expr *expr,
53455356
const std::vector<clang::Expr *> &all_args) {
53465357
const auto *tgt_ir = RuleRegistry::GetExprRule(ctx_, expr);
5347-
assert(tgt_ir && tgt_ir->init_type.valid());
5348-
auto *callee = clang::cast<clang::CallExpr>(expr)->getDirectCallee();
5349-
assert(callee);
5350-
auto type = GetSema()
5351-
.getTemplateInstantiationArgs(callee)(tgt_ir->init_type.depth,
5352-
tgt_ir->init_type.index)
5353-
.getAsType();
5358+
if (!tgt_ir || !tgt_ir->usesInit()) {
5359+
llvm::report_fatal_error("expression rule does not use Init");
5360+
}
5361+
auto type = RuleRegistry::GetInitType(expr);
53545362

53555363
Buffer buf(*this);
53565364
ConvertConstructFromArgs(

‎cpp2rust/converter/converter.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
6161

6262
clang::ASTContext &GetASTContext() { return ctx_; }
6363

64+
virtual std::string GetUnboxedTypeAsString(clang::QualType qual_type);
65+
6466
bool VisitRecoveryExpr(clang::RecoveryExpr *expr);
6567

6668
virtual void EmitFilePreamble();
@@ -74,6 +76,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
7476

7577
virtual bool VisitRecordType(clang::RecordType *type);
7678

79+
bool VisitEnumType(clang::EnumType *type);
80+
7781
virtual bool VisitConstantArrayType(clang::ConstantArrayType *type);
7882

7983
virtual bool VisitIncompleteArrayType(clang::IncompleteArrayType *type);
@@ -363,7 +367,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
363367
// Option<fn> implements Copy
364368
virtual bool FunctionPointerImplementsCopy() const { return true; }
365369

366-
bool TypeIsCopyable(clang::QualType ty) const {
370+
bool TypeIsCopyable(clang::QualType ty) {
367371
if (ty->isFunctionPointerType() || ty->isFunctionType()) {
368372
return FunctionPointerImplementsCopy();
369373
}
@@ -785,7 +789,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
785789

786790
virtual bool TypeDerivesDefault(clang::QualType qual_type);
787791

788-
bool RecordDerivesCopy(const clang::RecordDecl *decl) const;
792+
bool RecordDerivesCopy(const clang::RecordDecl *decl);
789793

790794
bool IsPassThroughRule(clang::Expr *expr) const;
791795

‎cpp2rust/converter/converter_lib.cpp‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool IsAbstractUserClass(const clang::RecordDecl *decl) {
335335
definition->isAbstract();
336336
}
337337

338-
bool RefersToUserDefinedDecl(const clang::Expr *expr) {
338+
bool ExprHasUserDefinedDecl(const clang::Expr *expr) {
339339
expr = expr->IgnoreParenImpCasts();
340340
const clang::Decl *decl = nullptr;
341341
if (const auto *call = llvm::dyn_cast<clang::CallExpr>(expr)) {
@@ -1101,15 +1101,15 @@ const char *AccessSpecifierAsString(clang::AccessSpecifier spec) {
11011101
clang::QualType GetReturnTypeOfFunction(const clang::CallExpr *expr) {
11021102
if (auto *decl = expr->getCalleeDecl()) {
11031103
if (auto *fn = decl->getAsFunction()) {
1104-
return fn->getReturnType().getCanonicalType();
1104+
return fn->getReturnType();
11051105
}
11061106
}
11071107

11081108
auto callee_ty = expr->getCallee()->getType();
11091109
if (auto *ptr_ty = callee_ty->getAs<clang::PointerType>()) {
11101110
if (auto *fn_ty =
11111111
ptr_ty->getPointeeType()->getAs<clang::FunctionProtoType>()) {
1112-
return fn_ty->getReturnType().getCanonicalType();
1112+
return fn_ty->getReturnType();
11131113
}
11141114
}
11151115

@@ -1640,18 +1640,6 @@ clang::CXXConstructExpr *MakeConstructExpr(clang::ASTContext &ctx,
16401640
clang::SourceRange());
16411641
}
16421642

1643-
std::vector<clang::CXXRecordDecl *>
1644-
GetNestedStructs(const clang::CXXRecordDecl *decl) {
1645-
std::vector<clang::CXXRecordDecl *> nested_record_decls;
1646-
for (auto *d : decl->decls()) {
1647-
if (auto *rec = clang::dyn_cast<clang::CXXRecordDecl>(d);
1648-
rec && !rec->isImplicit()) {
1649-
nested_record_decls.push_back(rec);
1650-
}
1651-
}
1652-
return nested_record_decls;
1653-
}
1654-
16551643
std::optional<clang::ArrayRef<clang::TemplateArgument>>
16561644
GetTemplateArgs(clang::QualType qual_type, clang::Expr *expr) {
16571645
if (auto ty = clang::dyn_cast<clang::TemplateSpecializationType>(qual_type)) {

‎cpp2rust/converter/converter_lib.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool IsUserDefinedDecl(const clang::Decl *decl);
7171

7272
bool IsAbstractUserClass(const clang::RecordDecl *decl);
7373

74-
bool RefersToUserDefinedDecl(const clang::Expr *expr);
74+
bool ExprHasUserDefinedDecl(const clang::Expr *expr);
7575

7676
bool IsUnsignedArithOp(const clang::BinaryOperator *expr);
7777

@@ -274,9 +274,6 @@ clang::CXXConstructExpr *MakeConstructExpr(clang::ASTContext &ctx,
274274
clang::CXXConstructorDecl *ctor,
275275
llvm::ArrayRef<clang::Expr *> args);
276276

277-
std::vector<clang::CXXRecordDecl *>
278-
GetNestedStructs(const clang::CXXRecordDecl *decl);
279-
280277
std::optional<clang::ArrayRef<clang::TemplateArgument>>
281278
GetTemplateArgs(clang::QualType qual_type, clang::Expr *expr = nullptr);
282279

‎cpp2rust/converter/factory.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
#include "converter/factory.h"
55

66
#include "converter/models/converter_refcount.h"
7-
#include "converter/rules/registry.h"
87

98
namespace cpp2rust {
109

1110
std::unique_ptr<Converter> CreateConverter(std::string &rs_code,
1211
clang::ASTContext &ctx, Model model,
1312
const std::string &rules_dir) {
14-
RuleRegistry::Load(model, rules_dir);
1513
switch (model) {
1614
case Model::kUnsafe:
1715
return std::make_unique<Converter>(rs_code, ctx);

0 commit comments

Comments
 (0)