[PATCH] D116318: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 28 08:49:44 PST 2021


owenpan added a comment.

In D116318#3211258 <https://reviews.llvm.org/D116318#3211258>, @curdeius wrote:

> Wasn't assert enough? Could you add a test with code that provokes the problem?

This fix is an NFC, so there will be no (user) test case for it. :)

The current behavior does not match the description on line 35, and I need this function to be able to return null to simply my code. Otherwise, l would have to do something like the following:

  if (Position == 0)
    return false;
  const FormatToken *Previous = AllTokens[Position - 1];
  assert(Previous);
  return Previous->is(tok::comment);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116318



More information about the cfe-commits mailing list