================
@@ -268,13 +270,15 @@ void UseRangesCheck::check(const MatchFinder::MatchResult
&Result) {
for (const auto &[First, Second, Replace] : Sig) {
auto ArgNode = ArgName + std::to_string(First);
if (const auto *ArgExpr = Result.Nodes.getNodeAs<Expr>(ArgNode)) {
- Diag << FixItHint::CreateReplacement(
- Call->getArg(Replace == Indexes::Second ? Second : First)
- ->getSourceRange(),
- Lexer::getSourceText(
- CharSourceRange::getTokenRange(ArgExpr->getSourceRange()),
- Result.Context->getSourceManager(),
- Result.Context->getLangOpts()));
+ const Expr *RangeArg =
+ Call->getArg(Replace == Indexes::Second ? Second : First);
+ std::string ReplaceText =
+ tooling::fixit::getText(*ArgExpr, *Result.Context).str();
+ if (ArgExpr->getType()->isPointerType() &&
+ isa<CXXMemberCallExpr>(RangeArg->IgnoreParenImpCasts()))
+ ReplaceText = fixit::formatDereference(*ArgExpr, *Result.Context);
----------------
vbvictor wrote:
Use `if/else` or ternary. Otherwise we sometimes calculate getText only to
discard it later.
https://github.com/llvm/llvm-project/pull/226739
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits