1414#include " converter/converter_lib.h"
1515#include " converter/lex.h"
1616#include " converter/mapper.h"
17+ #include " logging.h"
1718
1819namespace cpp2rust {
1920std::unordered_map<std::string, std::string> Converter::inner_structs_;
@@ -52,8 +53,8 @@ use std::rc::Rc;
5253}
5354
5455bool Converter::VisitRecoveryExpr (clang::RecoveryExpr *expr) {
55- llvm::errs () << " RecoveryExpr: " ;
56- expr->dump ();
56+ verrs () << " RecoveryExpr: " ;
57+ expr->dump (verrs (), ctx_ );
5758 exit (1 );
5859 return false ;
5960}
@@ -122,7 +123,7 @@ bool Converter::VisitBuiltinType(clang::BuiltinType *type) {
122123 break ;
123124 default :
124125 // FIXME: improve error handling
125- llvm::errs () << " unsupported builtin type\n " ;
126+ verrs () << " unsupported builtin type\n " ;
126127 break ;
127128 }
128129 return false ;
@@ -151,7 +152,7 @@ bool Converter::VisitRecordType(clang::RecordType *type) {
151152}
152153
153154std::string Converter::ConvertPointer (clang::Expr *expr, int line) {
154- llvm::errs () << " ConvertPointer called from line " << line << " \n " ;
155+ verrs () << " ConvertPointer called from line " << line << " \n " ;
155156 PushExprKind push (*this , ExprKind::AddrOf);
156157 return ToString (expr);
157158}
@@ -175,7 +176,7 @@ std::string Converter::ConvertLValue(clang::Expr *expr) {
175176}
176177
177178std::string Converter::ConvertRValue (clang::Expr *expr, int line) {
178- llvm::errs () << " ConvertRValue called from line " << line << " \n " ;
179+ verrs () << " ConvertRValue called from line " << line << " \n " ;
179180 PushExprKind push (*this , ExprKind::RValue);
180181 return ToString (expr);
181182}
@@ -295,7 +296,7 @@ bool Converter::VisitFunctionDecl(clang::FunctionDecl *decl) {
295296 if (!IsInMainFile (decl) && !decl_ids_.insert (GetID (decl)).second ) {
296297 return false ;
297298 }
298- decl->dump ();
299+ decl->dump (verrs () );
299300 curr_function_ = decl;
300301 std::string function_name;
301302 if (decl->isMain ()) {
@@ -582,7 +583,7 @@ static bool recordDerivesCopy(const clang::RecordDecl *decl) {
582583}
583584
584585bool Converter::VisitRecordDecl (clang::RecordDecl *decl) {
585- decl->dumpColor ( );
586+ decl->dump ( verrs () );
586587
587588 // VisitCXXRecordDecl already visited the record
588589 if (clang::isa<clang::CXXRecordDecl>(decl)) {
@@ -694,7 +695,7 @@ bool Converter::VisitCXXRecordDecl(clang::CXXRecordDecl *decl) {
694695 materializeTemplateSpecialization (decl);
695696 }
696697
697- decl->dump ();
698+ decl->dump (verrs () );
698699
699700 Mapper::AddRuleForUserDefinedType (decl);
700701 if (!IsConvertibleCXXRecordDecl (decl)) {
@@ -741,7 +742,7 @@ bool Converter::VisitCXXRecordDecl(clang::CXXRecordDecl *decl) {
741742}
742743
743744bool Converter::VisitCXXMethodDecl (clang::CXXMethodDecl *decl) {
744- decl->dump ();
745+ decl->dump (verrs () );
745746 if (!IsConvertibleCXXMethodDecl (decl)) {
746747 return false ;
747748 }
@@ -1085,10 +1086,10 @@ bool Converter::VisitCXXForRangeStmt(clang::CXXForRangeStmt *stmt) {
10851086
10861087 if (!Mapper::Contains (range_init_type.getUnqualifiedType ())) {
10871088 // FIXME: improve error handling
1088- llvm::errs () << " for range stmts only for types in std namespace\n " ;
1089+ verrs () << " for range stmts only for types in std namespace\n " ;
10891090 }
10901091
1091- llvm::errs () << " GetClassName: " << GetClassName (range_init_type) << " \n " ;
1092+ verrs () << " GetClassName: " << GetClassName (range_init_type) << " \n " ;
10921093
10931094 if (GetClassName (range_init_type) == " std::map" ) {
10941095 return VisitCXXForRangeStmtMap (stmt);
@@ -2363,8 +2364,8 @@ bool Converter::ConvertCXXOperatorCallExpr(clang::CXXOperatorCallExpr *expr) {
23632364 break ;
23642365 default :
23652366 // FIXME: improve error handling
2366- llvm::errs () << " unsupported CXXOperatorCallExpr: "
2367- << clang::getOperatorSpelling (expr->getOperator ()) << ' \n ' ;
2367+ verrs () << " unsupported CXXOperatorCallExpr: "
2368+ << clang::getOperatorSpelling (expr->getOperator ()) << ' \n ' ;
23682369 assert (0 );
23692370 }
23702371 return false ;
@@ -2692,7 +2693,7 @@ bool Converter::VisitUnaryExprOrTypeTraitExpr(
26922693 break ;
26932694 default :
26942695 // FIXME: improve error handling
2695- llvm::errs () << " unsupported unary expr or type trait expr\n " ;
2696+ verrs () << " unsupported unary expr or type trait expr\n " ;
26962697 }
26972698 return false ;
26982699}
@@ -3344,8 +3345,7 @@ void Converter::AddOrdTrait(const clang::CXXRecordDecl *decl) {
33443345 }
33453346
33463347 if (methods.size () > 1 ) {
3347- llvm::errs ()
3348- << " Currently supporting only one overloaded comparison operator\n " ;
3348+ verrs () << " Currently supporting only one overloaded comparison operator\n " ;
33493349 abort ();
33503350 }
33513351
@@ -3436,8 +3436,8 @@ void Converter::ConvertUnsignedArithBinaryOperator(clang::BinaryOperator *op,
34363436 break ;
34373437 default :
34383438 // FIXME: improve error handling
3439- llvm::errs () << " unsupported unsigned binary operator: " << opcode << ' \n ' ;
3440- op->dumpColor ( );
3439+ verrs () << " unsupported unsigned binary operator: " << opcode << ' \n ' ;
3440+ op->dump ( verrs (), ctx_ );
34413441 assert (0 );
34423442 }
34433443 PushParen paren (*this );
@@ -3747,9 +3747,9 @@ void Converter::SetFreshType(clang::QualType type) {
37473747}
37483748
37493749void Converter::dump_expr_kinds () {
3750- llvm::errs () << " isRValue: " << isRValue () << " , isXValue: " << isXValue ()
3751- << " , isAddrOf: " << isAddrOf () << " , isObject: " << isObject ()
3752- << " , isVoid: " << isVoid () << " \n " ;
3750+ verrs () << " isRValue: " << isRValue () << " , isXValue: " << isXValue ()
3751+ << " , isAddrOf: " << isAddrOf () << " , isObject: " << isObject ()
3752+ << " , isVoid: " << isVoid () << " \n " ;
37533753}
37543754
37553755void Converter::emplace_back_plugin_construct_arg (
0 commit comments