42 lines · c
1//===--- QueryCheck.h - clang-tidy ------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CUSTOM_QUERYCHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CUSTOM_QUERYCHECK_H11 12#include "../ClangTidyCheck.h"13#include "clang/ASTMatchers/Dynamic/VariantValue.h"14#include "clang/Basic/DiagnosticIDs.h"15#include "llvm/ADT/DenseMap.h"16#include "llvm/ADT/SmallVector.h"17#include "llvm/ADT/StringMap.h"18 19namespace clang::tidy::custom {20 21/// Implement of Clang-Query based check.22/// Not directly visible to users.23class QueryCheck : public ClangTidyCheck {24public:25 QueryCheck(llvm::StringRef Name, const ClangTidyOptions::CustomCheckValue &V,26 ClangTidyContext *Context);27 void registerMatchers(ast_matchers::MatchFinder *Finder) override;28 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;29 30private:31 llvm::SmallVector<ast_matchers::dynamic::DynTypedMatcher> Matchers;32 using BindNameMapToDiagMessage =33 llvm::StringMap<llvm::SmallVector<std::string>>;34 using DiagMaps =35 llvm::DenseMap<DiagnosticIDs::Level, BindNameMapToDiagMessage>;36 DiagMaps Diags;37};38 39} // namespace clang::tidy::custom40 41#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CUSTOM_QUERYCHECK_H42