Skip to content

Commit d9bc4e9

Browse files
Copilotnunoplopes
andauthored
Replace single-char stream string literals with chars
Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/d26a087d-4f6f-4369-8882-2f9b02a87fcf Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
1 parent c0195b8 commit d9bc4e9

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

cpp2rust/converter/converter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ bool Converter::VisitRecordType(clang::RecordType *type) {
152152
}
153153

154154
std::string Converter::ConvertPointer(clang::Expr *expr, int line) {
155-
log() << "ConvertPointer called from line " << line << "\n";
155+
log() << "ConvertPointer called from line " << line << '\n';
156156
PushExprKind push(*this, ExprKind::AddrOf);
157157
return ToString(expr);
158158
}
@@ -176,7 +176,7 @@ std::string Converter::ConvertLValue(clang::Expr *expr) {
176176
}
177177

178178
std::string Converter::ConvertRValue(clang::Expr *expr, int line) {
179-
log() << "ConvertRValue called from line " << line << "\n";
179+
log() << "ConvertRValue called from line " << line << '\n';
180180
PushExprKind push(*this, ExprKind::RValue);
181181
return ToString(expr);
182182
}
@@ -1086,7 +1086,7 @@ bool Converter::VisitCXXForRangeStmt(clang::CXXForRangeStmt *stmt) {
10861086
log() << "for range stmts only for types in std namespace\n";
10871087
}
10881088

1089-
log() << "GetClassName: " << GetClassName(range_init_type) << "\n";
1089+
log() << "GetClassName: " << GetClassName(range_init_type) << '\n';
10901090

10911091
if (GetClassName(range_init_type) == "std::map") {
10921092
return VisitCXXForRangeStmtMap(stmt);
@@ -3582,7 +3582,7 @@ void Converter::ConvertDeref(clang::Expr *expr) {
35823582
void Converter::ConvertArrow(clang::Expr *expr) { ConvertDeref(expr); }
35833583

35843584
void Converter::ConvertCast(clang::QualType qual_type, int line) {
3585-
log() << "[ConvertCast] Called from line " << line << "\n";
3585+
log() << "[ConvertCast] Called from line " << line << '\n';
35863586
StrCat(keyword::kAs, GetUnsafeTypeAsString(qual_type));
35873587
}
35883588

@@ -3633,7 +3633,7 @@ void Converter::PlaceholderCtx::dump() const {
36333633
<< declared_in_rule_as_rust_ptr << ", access: "
36343634
<< (access == TranslationRule::Access::kRead ? "read" : "write")
36353635
<< ", param_type: " << param_type
3636-
<< ", materialize_idx: " << materialize_idx << "\n";
3636+
<< ", materialize_idx: " << materialize_idx << '\n';
36373637
}
36383638

36393639
std::string Converter::ConvertPlaceholder(clang::Expr *expr, clang::Expr *arg,
@@ -3844,7 +3844,7 @@ void Converter::SetFreshType(clang::QualType type) {
38443844
void Converter::dump_expr_kinds() {
38453845
log() << "isRValue: " << isRValue() << ", isXValue: " << isXValue()
38463846
<< ", isAddrOf: " << isAddrOf() << ", isObject: " << isObject()
3847-
<< ", isVoid: " << isVoid() << "\n";
3847+
<< ", isVoid: " << isVoid() << '\n';
38483848
}
38493849

38503850
void Converter::emplace_back_plugin_construct_arg(

cpp2rust/converter/models/converter_refcount.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ static std::vector<const char *> printf2fmt(std::string &format) {
824824
}
825825
}
826826
}
827-
llvm::errs() << "Unknown printf format: " << format << "\n";
827+
llvm::errs() << "Unknown printf format: " << format << '\n';
828828
assert(0);
829829
}
830830
return types;
@@ -840,7 +840,7 @@ void ConverterRefCount::ConvertPrintf(clang::CallExpr *expr) {
840840
} else {
841841
llvm::errs() << "Uknown fprintf format: ";
842842
expr->getArg(1)->dump();
843-
llvm::errs() << "\n";
843+
llvm::errs() << '\n';
844844
exit(1);
845845
}
846846
bool ends_newline = format.ends_with("\\n\"");
@@ -851,7 +851,7 @@ void ConverterRefCount::ConvertPrintf(clang::CallExpr *expr) {
851851
} else if (fd == "stderr" || fd == "__stderrp") {
852852
StrCat(ends_newline ? "eprintln!(" : "eprint!(");
853853
} else {
854-
llvm::errs() << "Uknown fprintf fd: " << fd << "\n";
854+
llvm::errs() << "Uknown fprintf fd: " << fd << '\n';
855855
exit(1);
856856
}
857857
if (ends_newline) {

cpp2rust/converter/models/converter_refcount.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class ConverterRefCount final : public Converter {
249249
for (auto ck : c.conversion_kind_) {
250250
log() << c.ConversionKindToString(ck) << ", ";
251251
}
252-
log() << "\n";
252+
log() << '\n';
253253
}
254254
~PushConversionKind() {
255255
if (pushed) {
@@ -259,7 +259,7 @@ class ConverterRefCount final : public Converter {
259259
for (auto ck : c.conversion_kind_) {
260260
log() << c.ConversionKindToString(ck) << ", ";
261261
}
262-
log() << "\n";
262+
log() << '\n';
263263
}
264264
};
265265

cpp2rust/cpp2rust.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ int main(int argc, char *argv[]) {
128128
} else if (Model == "unsafe") {
129129
model = cpp2rust::Model::kUnsafe;
130130
} else {
131-
llvm::errs() << "ERROR: unknown model: " << Model << "\n";
131+
llvm::errs() << "ERROR: unknown model: " << Model << '\n';
132132
return EXIT_FAILURE;
133133
}
134134

135135
std::string cc_code;
136136
if (!CcFile.empty()) {
137137
std::ifstream file(CcFile);
138138
if (!file) {
139-
llvm::errs() << "ERROR: failed to open " << CcFile << "\n";
139+
llvm::errs() << "ERROR: failed to open " << CcFile << '\n';
140140
return EXIT_FAILURE;
141141
}
142142
cc_code = {std::istreambuf_iterator<char>(file),
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
167167

168168
std::ofstream file(RsFile);
169169
if (!file) {
170-
llvm::errs() << "ERROR: failed to open " << RsFile << "\n";
170+
llvm::errs() << "ERROR: failed to open " << RsFile << '\n';
171171
return EXIT_FAILURE;
172172
}
173173

0 commit comments

Comments
 (0)