[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 18 23:26:19 PDT 2024


owenca wrote:

> I've done all your changes in a second commit just to be able to keep track of my previous changes; but I am actually not sure how your suggested modifications are any different from mine? Well, I admit it looks a bit better, but it works the same? Or am I missing something? You are just storing the old value of Cursor and resetting it when no changes, while I was doing it the other way around: storing the new value and updating it only if no changes.

It's been a while, but IIRC your original fix was not equivalent to my suggestion, which IMO is simpler and cleaner.

> It does not fix the tests I mentioned.

My bad. I copy-pasted the two tests you said would fail and ran FormatTests with my suggested fix, and they passed. Of course, I missed the comments in your snippet, e.g.:
```
  EXPECT_EQ(15u, newCursor(Code, 14)); // FIXME: should expect 16, caused by \r
```

https://github.com/llvm/llvm-project/pull/77456


More information about the cfe-commits mailing list