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);
@@ -2341,8 +2342,8 @@ bool Converter::ConvertCXXOperatorCallExpr(clang::CXXOperatorCallExpr *expr) {
23412342 break ;
23422343 default :
23432344 // FIXME: improve error handling
2344- llvm::errs () << " unsupported CXXOperatorCallExpr: "
2345- << clang::getOperatorSpelling (expr->getOperator ()) << ' \n ' ;
2345+ verrs () << " unsupported CXXOperatorCallExpr: "
2346+ << clang::getOperatorSpelling (expr->getOperator ()) << ' \n ' ;
23462347 assert (0 );
23472348 }
23482349 return false ;
@@ -2670,7 +2671,7 @@ bool Converter::VisitUnaryExprOrTypeTraitExpr(
26702671 break ;
26712672 default :
26722673 // FIXME: improve error handling
2673- llvm::errs () << " unsupported unary expr or type trait expr\n " ;
2674+ verrs () << " unsupported unary expr or type trait expr\n " ;
26742675 }
26752676 return false ;
26762677}
@@ -3302,8 +3303,7 @@ void Converter::AddOrdTrait(const clang::CXXRecordDecl *decl) {
33023303 }
33033304
33043305 if (methods.size () > 1 ) {
3305- llvm::errs ()
3306- << " Currently supporting only one overloaded comparison operator\n " ;
3306+ verrs () << " Currently supporting only one overloaded comparison operator\n " ;
33073307 abort ();
33083308 }
33093309
@@ -3394,8 +3394,8 @@ void Converter::ConvertUnsignedArithBinaryOperator(clang::BinaryOperator *op,
33943394 break ;
33953395 default :
33963396 // FIXME: improve error handling
3397- llvm::errs () << " unsupported unsigned binary operator: " << opcode << ' \n ' ;
3398- op->dumpColor ( );
3397+ verrs () << " unsupported unsigned binary operator: " << opcode << ' \n ' ;
3398+ op->dump ( verrs (), ctx_ );
33993399 assert (0 );
34003400 }
34013401 PushParen paren (*this );
@@ -3705,9 +3705,9 @@ void Converter::SetFreshType(clang::QualType type) {
37053705}
37063706
37073707void Converter::dump_expr_kinds () {
3708- llvm::errs () << " isRValue: " << isRValue () << " , isXValue: " << isXValue ()
3709- << " , isAddrOf: " << isAddrOf () << " , isObject: " << isObject ()
3710- << " , isVoid: " << isVoid () << " \n " ;
3708+ verrs () << " isRValue: " << isRValue () << " , isXValue: " << isXValue ()
3709+ << " , isAddrOf: " << isAddrOf () << " , isObject: " << isObject ()
3710+ << " , isVoid: " << isVoid () << " \n " ;
37113711}
37123712
37133713void Converter::emplace_back_plugin_construct_arg (
0 commit comments