[PATCH] D143099: [clang][lex] Expose findBeginningOfLine()

Kyle Edwards via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 30 10:19:15 PDT 2023


KyleFromKitware added inline comments.


================
Comment at: clang/unittests/Lex/LexerTest.cpp:673
+  EXPECT_EQ(FindBeginningOfLineOffset("int func1();\nint func2();", 13), 13);
+  EXPECT_EQ(FindBeginningOfLineOffset("int func1();\nint func2();", 12), 13);
+  EXPECT_EQ(FindBeginningOfLineOffset("int func1();\nint func2();", 11), 0);
----------------
tahonermann wrote:
> I find this case interesting. I'm assuming it is intentional that an offset that corresponds to an EOL character indicates that the offset of the character following it be returned. That suggests some additional cases to test:
>     EXPECT_EQ(FindBeginningOfLineOffset("int func1();\n\n", 12), 13);
>     EXPECT_EQ(FindBeginningOfLineOffset("int func1();\n", 12), 13);  // 13? Or perhaps invalid?
> 
> My intuition is that an offset corresponding to an EOL character would result in the offset of the line containing the EOL character being returned.
I did my best to preserve the existing behavior of the function while fixing a corner case that was obviously wrong. Should this be fixed as well?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143099/new/

https://reviews.llvm.org/D143099



More information about the cfe-commits mailing list