aboutsummaryrefslogtreecommitdiff
path: root/subprojects/lix-clang-tidy/CharPtrCast.hh
blob: 66883d0550f2fc6f0c8fdecc0523c5bda7049a19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
///@file

#include <clang-tidy/ClangTidyCheck.h>
#include <clang-tidy/utils/IncludeInserter.h>
#include <clang/ASTMatchers/ASTMatchFinder.h>
#include <llvm/ADT/StringRef.h>

namespace nix::clang_tidy {

using namespace clang;
using namespace clang::tidy;

class CharPtrCastCheck : public ClangTidyCheck {
  tidy::utils::IncludeInserter Inserter{
      Options.getLocalOrGlobal("IncludeStyle",
                               tidy::utils::IncludeSorter::IS_Google),
      false};

public:
  CharPtrCastCheck(StringRef Name, ClangTidyContext *Context)
      : ClangTidyCheck(Name, Context) {}

  void registerPPCallbacks(const SourceManager &, Preprocessor *PP,
                           Preprocessor *) override {
    Inserter.registerPreprocessor(PP);
  }

  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
} // namespace nix::clang_tidy