[clang-tools-extra] [clang-tidy] Fix modernize-loop-convert by introducing space (PR #202015)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 02:27:18 PDT 2026
================
@@ -698,11 +698,32 @@ void LoopConvertCheck::doConversion(
std::string ReplaceText;
SourceRange Range = Usage.Range;
if (Usage.Expression) {
+ // Decide whether `ReplaceText` needs to be pre-appended with a space
+ // or not. In cases like `delete*it`, we can't just change it to
+ // `deleteit` we need to introduce space after `delete` to make it
+ // `delete it`.
+ Token StarToken;
+ if (Usage.Kind == Usage::UK_Default &&
+ !Lexer::getRawToken(Usage.Range.getBegin(), StarToken,
+ Context->getSourceManager(), getLangOpts(),
+ false) &&
+ StarToken.is(tok::star)) {
+ std::optional<Token> PrevToken = Lexer::findPreviousToken(
+ Usage.Range.getBegin(), Context->getSourceManager(),
+ getLangOpts(), true);
+ if (PrevToken) {
----------------
vbvictor wrote:
This is strange because IIRC we can use `assert` to mitigate unchecked access (and we do in other places). Did you use Release + assertions configure in CMAKE? Because if you use pure Release, then all assertions are "removed" so this warning is triggered. In CI we use assertions build.
https://github.com/llvm/llvm-project/pull/202015
More information about the cfe-commits
mailing list