================
@@ -552,6 +552,39 @@ static bool containerIsConst(const Expr *ContainerExpr,
bool Dereference) {
return false;
}
+// Returns true if the token at `BeginLocation` is immediately preceded by an
+// identifier or keyword token with no space between them.
+static bool
+isPrecededByAdjacentIdentifierOrKeyword(SourceManager &SourceMgr,
+ const LangOptions &LangOpts,
+ SourceLocation BeginLocation) {
+ std::optional<Token> PrevToken =
+ Lexer::findPreviousToken(BeginLocation, SourceMgr, LangOpts, true);
+ if (!PrevToken)
+ return false;
+ // Check whether the token at `BeginLocation` is immediately adjacent to
+ // the previous token with no space between them.
+ const bool IsAdjacentToPrevToken = PrevToken->getEndLoc() == BeginLocation;
+ return PrevToken->isAnyIdentifier() && IsAdjacentToPrevToken;
+}
+
+// Returns true if the replacement text needs a leading space to avoid merging
+// with the preceding token. This occurs when `*it` is immediately adjacent to
+// a keyword, e.g. `delete*it`, where replacing `*it` with `it` would
+// incorrectly produce `deleteit`. So we insert a space b/w `delete` and `it`.
+static bool requiresLeadingSpace(SourceManager &SourceMgr,
----------------
vbvictor wrote:
```suggestion
static bool requiresLeadingSpace(const SourceManager &SourceMgr,
```
https://github.com/llvm/llvm-project/pull/202015
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits