Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9fb200b
Guard by standard
lucic71 Oct 2, 2026
1c35103
Include rules at the end of the TU
lucic71 Oct 2, 2026
3220040
Load rules decls
lucic71 Oct 2, 2026
dd8eb34
Update rules
lucic71 Oct 2, 2026
8b5f41a
Delete string matcher and cpp-rule-preprocessor
lucic71 Oct 2, 2026
6872f52
Update mapper
lucic71 Oct 2, 2026
dc7923e
Pass caller to Mapper
lucic71 Oct 2, 2026
a77dfa7
Update registry
lucic71 Oct 2, 2026
c63f621
Don't load IR src
lucic71 Oct 2, 2026
ad965a9
Update rule decls
lucic71 Oct 2, 2026
9a7883f
Stop checking for ir_src.json
lucic71 Oct 2, 2026
5f1b2e3
Update rules prelude
lucic71 Oct 2, 2026
fac7c1f
Add AST matcher
lucic71 Oct 2, 2026
b4608ca
Add ubuntu libc++ config
lucic71 Oct 2, 2026
45c69c1
Add rule for vector::size_type
lucic71 Oct 2, 2026
5b34f11
Update rules
lucic71 Oct 3, 2026
93a3acf
Add IsStdSetw
lucic71 Oct 3, 2026
fc845f2
Register user types on every TU
lucic71 Oct 3, 2026
8efcc17
Fix addition of user types
lucic71 Oct 3, 2026
153bb22
Revert "Add ubuntu libc++ config"
lucic71 Oct 3, 2026
abc9338
Add standard-version ifdefs in rules
lucic71 Oct 3, 2026
f516529
Add tyepofexprtype
lucic71 Oct 3, 2026
8f4f6a1
Move select to C
lucic71 Oct 3, 2026
5c488d4
Move more things in src.c
lucic71 Oct 3, 2026
47c7534
Use rules as system header
lucic71 Oct 3, 2026
5673744
Merge branch 'c-rules' into ast-tree-matcher
lucic71 Oct 4, 2026
5a475e2
Merge branch 'standard-dependent-rules' into ast-tree-matcher
lucic71 Oct 4, 2026
e2fe039
Move more C specific rules in src.c
lucic71 Oct 4, 2026
ef1b143
Don't include C++ rules in C mode
lucic71 Oct 4, 2026
cb07afe
Handle bool in C vs C++ mode
lucic71 Oct 4, 2026
2c793b4
Revert unchanged code
lucic71 Oct 4, 2026
feb2c19
Don't use module to describe rules
lucic71 Oct 4, 2026
9ad2c3b
clang-format
lucic71 Oct 4, 2026
8315809
Pass converter to mapper
lucic71 Oct 4, 2026
8d813b6
Add double const pointer test
lucic71 Oct 4, 2026
1d900a0
Delete find for user defined types in mapper
lucic71 Oct 4, 2026
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
22 changes: 0 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ add_custom_command(
)

file(GLOB rule_subdirs CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/rules/*)
set(cpp_rules_ir_outputs)
set(rust_rules_ir_outputs)
foreach(_rule_dir IN LISTS rule_subdirs)
file(GLOB _cpp_srcs ${_rule_dir}/src.c ${_rule_dir}/src.cpp)
Expand All @@ -224,25 +223,6 @@ foreach(_rule_dir IN LISTS rule_subdirs)
endif()
get_filename_component(_rule_name ${_rule_dir} NAME)
set(_out_dir ${RULES_IR_DIR}/${_rule_name})
set(_cpp_out ${_out_dir}/ir_src.json)
set(_cxxflags)
set(_cxxflags_file)
if(EXISTS ${_rule_dir}/cxxflags)
set(_cxxflags_file ${_rule_dir}/cxxflags)
file(STRINGS ${_cxxflags_file} _flags)
foreach(_flag IN LISTS _flags)
list(APPEND _cxxflags --cxxflags=${_flag})
endforeach()
endif()
add_custom_command(
OUTPUT ${_cpp_out}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir}
COMMAND $<TARGET_FILE:cpp-rule-preprocessor> --dir ${_rule_dir} --out ${_cpp_out} ${_cxxflags}
DEPENDS ${_cpp_srcs} ${_cxxflags_file} ${PROJECT_SOURCE_DIR}/cpp2rust/cpp_rule_preprocessor.cpp ${RUSTLS_HEADER} ${BROTLI_HEADERS}
VERBATIM
)
list(APPEND cpp_rules_ir_outputs ${_cpp_out})

set(_rust_srcs)
set(_rust_out)
if(EXISTS ${_rule_dir}/tgt_unsafe.rs)
Expand Down Expand Up @@ -271,8 +251,6 @@ foreach(_rule_dir IN LISTS rule_subdirs)
list(APPEND rust_rules_ir_outputs ${_rust_out})
endforeach()

add_custom_target("preprocess-cpp-rules" ALL DEPENDS ${cpp_rules_ir_outputs})

add_custom_target("preprocess-rust-rules" ALL
DEPENDS ${rust_rules_ir_outputs})

Expand Down
5 changes: 1 addition & 4 deletions cpp2rust/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
file(GLOB_RECURSE CORE_SOURCES "*.cpp")
list(REMOVE_ITEM CORE_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/cpp2rust.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/cpp_rule_preprocessor.cpp"
)

add_library(cpp2rust_core STATIC ${CORE_SOURCES})
Expand All @@ -17,6 +16,7 @@ target_compile_definitions(cpp2rust_core PUBLIC "-DCLANG_C_COMPILER=\"${CMAKE_C_
target_compile_definitions(cpp2rust_core PUBLIC "-DCLANG_CXX_COMPILER=\"${CMAKE_CXX_COMPILER}\"")
target_compile_definitions(cpp2rust_core PUBLIC "-DCLANG_RESOURCE_DIR=\"${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}\"")
target_compile_definitions(cpp2rust_core PUBLIC "-DCOMPAT_INCLUDE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/compat\"")
target_compile_definitions(cpp2rust_core PUBLIC "-DRULES_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}/rules\"")
target_compile_definitions(cpp2rust_core PUBLIC "-DRUST_STABLE_VERSION=\"${RUST_STABLE_VERSION}\"")

if (APPLE)
Expand All @@ -33,6 +33,3 @@ target_link_libraries(cpp2rust_core PUBLIC ${llvm_libs})

add_clang_executable(cpp2rust PARTIAL_SOURCES_INTENDED cpp2rust.cpp)
target_link_libraries(cpp2rust PRIVATE cpp2rust_core)

add_clang_executable(cpp-rule-preprocessor PARTIAL_SOURCES_INTENDED cpp_rule_preprocessor.cpp)
target_link_libraries(cpp-rule-preprocessor PRIVATE cpp2rust_core)
4 changes: 4 additions & 0 deletions cpp2rust/ast_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
#include "ast_consumer.h"

#include "converter/converter.h"
#include "converter/rules/matcher.h"
#include "converter/rules/registry.h"
#include "converter/rules/rule_decls.h"

namespace cpp2rust {
void ASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) {
auto converter = CreateConverter(rs_code_, ctx, model_, rules_dir_);
RuleDecls::Collect(CI_.getSema());
converter->SetSema(CI_.getSema());
if (first_) {
converter->EmitFilePreamble();
Expand Down
Loading
Loading