1//===--- DeprecatedHeadersCheck.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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
11
12#include "../ClangTidyCheck.h"
13
14namespace clang::tidy::modernize {
15
16/// This check replaces deprecated C library headers with their C++ STL
17/// alternatives.
18///
19/// Before:
20/// ~~~{.cpp}
21/// #include <header.h>
22/// ~~~
23///
24/// After:
25/// ~~~{.cpp}
26/// #include <cheader>
27/// ~~~
28///
29/// Example: ``<stdio.h> => <cstdio>``
30///
31/// For the user-facing documentation see:
32/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/deprecated-headers.html
33class DeprecatedHeadersCheck : public ClangTidyCheck {
34public:
35 DeprecatedHeadersCheck(StringRef Name, ClangTidyContext *Context);
36 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
37 return LangOpts.CPlusPlus;
38 }
39 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
40 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
41 Preprocessor *ModuleExpanderPP) override;
42 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
43 void onEndOfTranslationUnit() override;
44 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
45
46 struct IncludeMarker {
47 std::string Replacement;
48 StringRef FileName;
49 SourceRange ReplacementRange;
50 SourceLocation DiagLoc;
51 };
52
53private:
54 std::vector<IncludeMarker> IncludesToBeProcessed;
55 bool CheckHeaderFile;
56};
57
58} // namespace clang::tidy::modernize
59
60#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
61

source code of clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h