Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
470 changes: 102 additions & 368 deletions cpp2rust/converter/converter.cpp

Large diffs are not rendered by default.

59 changes: 8 additions & 51 deletions cpp2rust/converter/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <format>
#include <functional>
#include <initializer_list>
#include <map>
#include <memory>
#include <optional>
Expand Down Expand Up @@ -313,6 +314,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {

virtual std::string GetReturnSlotArg(std::string_view receiver) const;

void InitializeReturnSlot(clang::QualType type, clang::Expr *value);

std::string GetReturnSlotParam(clang::QualType type);

virtual bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *decl);
Expand Down Expand Up @@ -504,25 +507,14 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {

CallInfo CollectCallInfo(clang::CallExpr *expr);

bool EmitComparisonTraitCallee(const CallInfo &info);

void ConvertComparisonTraitImpl(clang::FunctionDecl *decl,
const RecordTrait &trait);

virtual std::string
GetComparisonTraitSignature(const RecordTrait &trait, std::string_view lhs,
std::string_view rhs,
std::string_view rhs_type) const;

std::pair<std::string, std::string>
GetComparisonOperandNames(const clang::FunctionDecl *op);
void EmitComparisonTraits(const clang::CXXRecordDecl *decl);

void ConvertEqualityComparableImpl(const clang::CXXRecordDecl *decl,
const clang::FunctionDecl *op);
void EmitComparisonTrait(const ComparisonTrait &trait,
const Comparisons &comparisons);

void ConvertPartiallyOrderedWithImpl(const clang::CXXRecordDecl *decl);
void EmitComparisonBody(llvm::function_ref<void()> body);

std::string GetComparisonCategory(const clang::FunctionDecl *op);
virtual const char *GetComparisonMacro() const;

void ConvertParamTy(clang::QualType param_type, clang::Expr *expr);

Expand Down Expand Up @@ -989,34 +981,6 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {

bool ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl);

void AddOrdTrait(const clang::CXXRecordDecl *decl);

void ConvertComparisonTraitWrappers(const clang::CXXRecordDecl *decl,
const clang::FunctionDecl *eq,
const clang::FunctionDecl *lt,
const clang::FunctionDecl *cmp);

std::string GetComparisonCall(const clang::FunctionDecl *op,
const clang::CXXRecordDecl *decl,
std::string_view lhs, std::string_view rhs);

std::string GetComparisonBool(const clang::FunctionDecl *op,
const clang::CXXRecordDecl *decl,
std::string_view lhs, std::string_view rhs);

// The argument for param of a comparison operator of decl, from an operand
// of the comparison.
virtual std::string GetComparisonArg(const clang::ParmVarDecl *param,
const clang::CXXRecordDecl *decl,
std::string_view value);

virtual std::string
GetComparisonResultReceiver(const clang::CXXMethodDecl *method,
bool returns_ref, std::string_view result);

virtual std::string GetComparisonReceiver(const clang::CXXMethodDecl *method,
std::string_view lhs);

virtual bool RecordImplementsClone(const clang::RecordDecl *decl);

bool RecordDerivesTriviallyCopyable(const clang::RecordDecl *decl);
Expand Down Expand Up @@ -1411,13 +1375,6 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {

static DeferredBlock &DeferredImpl(std::string header);

DeferredBlock &ComparisonTraitImpl(const RecordTrait &trait,
std::string_view self,
std::string_view other);

void AddComparisonTraitMethod(const clang::FunctionDecl *op,
const RecordTrait &trait,
std::string_view method);
static std::map<std::string, std::map<std::string, const RecordTrait *>>
declared_record_traits_;
static std::set<std::pair<std::string, std::string>> converted_record_traits_;
Expand Down
Loading
Loading