================
@@ -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) {
----------------
gxyd wrote:

I've added an `assert`, I think should indeed suffice, can't think of a case 
where it will fail.

https://github.com/llvm/llvm-project/pull/202015
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to