================
@@ -720,18 +720,29 @@ bool SimplifyBooleanExprCheck::issueDiag(const ASTContext
&Context,
void SimplifyBooleanExprCheck::replaceWithThenStatement(
const ASTContext &Context, const IfStmt *IfStatement,
const Expr *BoolLiteral) {
+ // Added .str() below
+ std::string Replacement = getText(Context, *IfStatement->getThen()).str();
+ if (const Stmt *Init = IfStatement->getInit()) {
+ Replacement =
+ (Twine("{ ") + getText(Context, *Init) + Replacement + " }").str();
+ }
issueDiag(Context, BoolLiteral->getBeginLoc(), SimplifyConditionDiagnostic,
- IfStatement->getSourceRange(),
- getText(Context, *IfStatement->getThen()));
+ IfStatement->getSourceRange(), Replacement);
}
void SimplifyBooleanExprCheck::replaceWithElseStatement(
const ASTContext &Context, const IfStmt *IfStatement,
const Expr *BoolLiteral) {
const Stmt *ElseStatement = IfStatement->getElse();
+ // Added .str() below
----------------
zeyi2 wrote:
```suggestion
```
https://github.com/llvm/llvm-project/pull/172220
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits