================
@@ -26,6 +26,129 @@ AST_MATCHER(clang::LinkageSpecDecl, isExternCLinkage) {
 
 namespace clang::tidy::modernize {
 
+namespace lexer = clang::tidy::utils::lexer;
+
+namespace {
+struct RangeTextInfo {
+  std::string Text;
+  lexer::TokenRangeInfo Tokens;
+};
+} // namespace
+
+static bool hasNonWhitespace(llvm::StringRef Text) {
+  return Text.find_first_not_of(" \t\n\r\f\v") != llvm::StringRef::npos;
+}
+
+static RangeTextInfo getRangeTextInfo(clang::SourceLocation Begin,
+                                      clang::SourceLocation End,
+                                      const clang::SourceManager &SM,
+                                      const clang::LangOptions &LangOpts) {
+  RangeTextInfo Info;
+  if (!Begin.isValid() || !End.isValid() || Begin.isMacroID() ||
+      End.isMacroID())
+    return Info;
+
+  const clang::CharSourceRange Range =
+      clang::CharSourceRange::getCharRange(Begin, End);
+  Info.Text = lexer::getSourceText(Range, SM, LangOpts);
+  Info.Tokens = lexer::analyzeTokenRange(Range, SM, LangOpts);
----------------
vbvictor wrote:

Can we construct in-place? `Info = {..., ...}`

https://github.com/llvm/llvm-project/pull/180372
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to