1 //===--- DeprecatedHeadersCheck.h - clang-tidy-------------------*- C++ -*-===//
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
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
21 /// #include <header.h>
26 /// #include <cheader>
29 /// Example: ``<stdio.h> => <cstdio>``
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
{
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
;
49 SourceRange ReplacementRange
;
50 SourceLocation DiagLoc
;
54 std::vector
<IncludeMarker
> IncludesToBeProcessed
;
58 } // namespace clang::tidy::modernize
60 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H