[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 30 03:11:10 PST 2024
================
@@ -0,0 +1,110 @@
+//===--- UseSpanFirstLastCheck.cpp - clang-tidy-----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "UseSpanFirstLastCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+void UseSpanFirstLastCheck::registerMatchers(MatchFinder *Finder) {
+ if (!getLangOpts().CPlusPlus20)
+ return;
----------------
5chmidti wrote:
This should be done in `isLanguageVersionSupported` instead: https://github.com/llvm/llvm-project/blob/a8a494faab8af60754c4647dbb7b24bc86a80aab/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h#L26-L28
https://github.com/llvm/llvm-project/pull/118074
More information about the cfe-commits
mailing list