[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / clang-tools-extra / clang-tidy / modernize / DeprecatedHeadersCheck.h
blob68305efdb5d23526eb4cc014152548d049cc122a
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 //===----------------------------------------------------------------------===//
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
12 #include "../ClangTidyCheck.h"
14 namespace clang::tidy::modernize {
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
33 class DeprecatedHeadersCheck : public ClangTidyCheck {
34 public:
35 DeprecatedHeadersCheck(StringRef Name, ClangTidyContext *Context);
36 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
37 return LangOpts.CPlusPlus;
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;
46 struct IncludeMarker {
47 std::string Replacement;
48 StringRef FileName;
49 SourceRange ReplacementRange;
50 SourceLocation DiagLoc;
53 private:
54 std::vector<IncludeMarker> IncludesToBeProcessed;
55 bool CheckHeaderFile;
58 } // namespace clang::tidy::modernize
60 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H