[clang-tools-extra] [clangd] Fix OverridePureVirtuals to preserve attributes and formatting (PR #184023)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 29 01:08:51 PDT 2026
================
@@ -101,30 +102,63 @@ std::string removePureVirtualSyntax(const std::string &MethodDecl,
assert(!MethodDecl.empty());
TokenStream TS = lex(MethodDecl, LangOpts);
+ auto Tokens = TS.tokens();
- std::string DeclString;
- for (const clangd::Token &Tk : TS.tokens()) {
- if (Tk.Kind == clang::tok::raw_identifier && Tk.text() == "virtual")
+ // Find the pure-specifier (= 0) by searching backwards.
+ size_t PureEqualIndex = Tokens.size();
+ for (int J = static_cast<int>(Tokens.size()) - 1; J >= 1; --J) {
----------------
timon-ul wrote:
Why are we using an `int` instead of a `size_t` for `J` ? Then there also is no need for the `static_cast`.
https://github.com/llvm/llvm-project/pull/184023
More information about the cfe-commits
mailing list