Skip to content

Commit 58010d4

Browse files
committed
Fix StringRef to std::string conversion error
1 parent 41b87ac commit 58010d4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,8 @@ bool SimplifyBooleanExprCheck::issueDiag(const ASTContext &Context,
720720
void SimplifyBooleanExprCheck::replaceWithThenStatement(
721721
const ASTContext &Context, const IfStmt *IfStatement,
722722
const Expr *BoolLiteral) {
723-
std::string Replacement = getText(Context, *IfStatement->getThen());
723+
// Added .str() below
724+
std::string Replacement = getText(Context, *IfStatement->getThen()).str();
724725
if (const Stmt *Init = IfStatement->getInit()) {
725726
Replacement = (Twine("{ ") + getText(Context, *Init) + Replacement + " }").str();
726727
}
@@ -732,7 +733,8 @@ void SimplifyBooleanExprCheck::replaceWithElseStatement(
732733
const ASTContext &Context, const IfStmt *IfStatement,
733734
const Expr *BoolLiteral) {
734735
const Stmt *ElseStatement = IfStatement->getElse();
735-
std::string Replacement = ElseStatement ? getText(Context, *ElseStatement) : "";
736+
// Added .str() below
737+
std::string Replacement = ElseStatement ? getText(Context, *ElseStatement).str() : "";
736738
if (const Stmt *Init = IfStatement->getInit()) {
737739
Replacement = (Twine("{ ") + getText(Context, *Init) + Replacement + " }").str();
738740
}

0 commit comments

Comments
 (0)