carlosgalvezp added a comment.
I'm surprised we don't have unit tests that catch this?
================
Comment at: clang-tools-extra/clang-tidy/utils/LexerUtils.cpp:84-85
+ Lexer::findNextToken(Start, SM, LangOpts);
+ if (!CurrentToken || !CurrentToken->is(tok::comment))
+ return CurrentToken;
+
----------------
I'm not sure this logic is correct - `if (CurrentToken` is there to ensure that
`CurrentToken` is not a nullopt before dereferencing via `CurrentToken->is`. It
should be:
```
if (CurrentToken && !CurrentToken->is(tok::comment))
return CurrentToken;
```
================
Comment at: clang-tools-extra/clang-tidy/utils/LexerUtils.cpp:99
- while (Loc < Range.getEnd()) {
+ while (Loc <= Range.getEnd()) {
if (Loc.isMacroID())
----------------
This is a bit unintuitive if we compare it with e.g. STL iterators - `end()` is
always "one-past" the end. What's the convention for `SourceRange`, does `end`
contain a valid end range, or one-past-the-end?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146881/new/
https://reviews.llvm.org/D146881
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits