[clang-tools-extra] [clang-tidy] [NFC] Move comment scanning to `LexerUtils` and add tests (PR #180371)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 9 06:39:53 PST 2026


================
@@ -99,6 +100,66 @@ bool rangeContainsExpansionsOrDirectives(SourceRange Range,
   return false;
 }
 
+std::vector<CommentToken>
+getTrailingCommentsInRange(CharSourceRange Range, const SourceManager &SM,
+                           const LangOptions &LangOpts) {
+  std::vector<CommentToken> Comments;
+  if (!Range.isValid())
+    return Comments;
+
+  const CharSourceRange FileRange =
+      Lexer::makeFileCharRange(Range, SM, LangOpts);
+  if (!FileRange.isValid())
----------------
vbvictor wrote:

```suggestion
  if (FileRange.isInValid())
```

https://github.com/llvm/llvm-project/pull/180371


More information about the cfe-commits mailing list