[PATCH] D67654: [clang-tidy] Fix a potential infinite loop in readability-isolate-declaration check.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 18 08:48:39 PDT 2019
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/utils/LexerUtils.h:38
template <typename TokenKind, typename... TokenKinds>
SourceLocation findPreviousAnyTokenKind(SourceLocation Start,
const SourceManager &SM,
----------------
hokein wrote:
> ilya-biryukov wrote:
> > Would `findPrevious` have the same problem on the first token of the file?
> > Can be hard to check without unit-tests, though.
> it depends on the caller. Calling this function directly would probably get into infinite loop. As this function is only used in `readability-isolate-declaration` check, it seems that the check adds some additional guard code before calling this function, it is probably safe, I assume. (I could not figure out a case that causes the problem).
Fair point, but putting an assertion or fixing the function would be good too.
But we really need unit tests to properly ensure the invariants.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67654/new/
https://reviews.llvm.org/D67654
More information about the cfe-commits
mailing list