[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 22 13:07:02 PDT 2022
HazardyKnusperkeks added a comment.
Just a side note, I often get this on your changes:
Unhandled Exception ("Exception")
Found unknown intradiff source line, expected a line beginning with "+", "-", or " " (space): \ No newline at end of file
.
================
Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:85
+ auto Tokens = annotate("x - 0");
+ EXPECT_EQ(Tokens.size(), 4u) << Tokens;
+ EXPECT_TOKEN(Tokens[1], tok::minus, TT_BinaryOperator);
----------------
sstwcw wrote:
> HazardyKnusperkeks wrote:
> > I know the other cases also use EXPECT, but the size should be an ASSERT, so there would be no seg fault if the number would change (it shouldn't).
> I tried a wrong number and `EXPECT_EQ` didn't give a segfault.
The potential segfault is not in `EXPECT_EQ`, but in accessing a non existent token.
The number of tokens will most likely never change, but than again we don't need the `EXPECT_EQ` either.
But if it changes (gets smaller) we want to abort the test after the failed check and not accessing `Tokens` with an invalid index, that's why I'm pleading (and using) `ASSERT_EQ`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121754/new/
https://reviews.llvm.org/D121754
More information about the cfe-commits
mailing list