xref: /llvm-project/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h (revision c92cf315c67edaffea1c4f3a914197dce2a194f3)
1b7b28c6cSSiva Chandra Reddy //===-- InlineFunctionDeclCheck.h -------------------------------*- C++ -*-===//
2b7b28c6cSSiva Chandra Reddy //
3b7b28c6cSSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b7b28c6cSSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information.
5b7b28c6cSSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b7b28c6cSSiva Chandra Reddy //
7b7b28c6cSSiva Chandra Reddy //===----------------------------------------------------------------------===//
8b7b28c6cSSiva Chandra Reddy 
9b7b28c6cSSiva Chandra Reddy #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_INLINEFUNCTIONDECLCHECK_H
10b7b28c6cSSiva Chandra Reddy #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_INLINEFUNCTIONDECLCHECK_H
11b7b28c6cSSiva Chandra Reddy 
12b7b28c6cSSiva Chandra Reddy #include "../ClangTidyCheck.h"
135b37cddfSCarlos Galvez #include "../FileExtensionsSet.h"
14b7b28c6cSSiva Chandra Reddy 
15b7b28c6cSSiva Chandra Reddy namespace clang::tidy::llvm_libc {
16b7b28c6cSSiva Chandra Reddy 
17b7b28c6cSSiva Chandra Reddy /// Checks that explicitly and implicitly inline functions in headers files
18b7b28c6cSSiva Chandra Reddy /// are tagged with the LIBC_INLINE macro.
19b7b28c6cSSiva Chandra Reddy ///
20b7b28c6cSSiva Chandra Reddy /// For more information about the LIBC_INLINE macro, see
2154d45ddcSAlex Brachet /// https://libc.llvm.org/dev/code_style.html.
22b7b28c6cSSiva Chandra Reddy ///
23b7b28c6cSSiva Chandra Reddy /// For the user-facing documentation see:
24b7b28c6cSSiva Chandra Reddy /// http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc/inline-function-decl-check.html
25b7b28c6cSSiva Chandra Reddy class InlineFunctionDeclCheck : public ClangTidyCheck {
26b7b28c6cSSiva Chandra Reddy public:
27b7b28c6cSSiva Chandra Reddy   InlineFunctionDeclCheck(StringRef Name, ClangTidyContext *Context);
28b7b28c6cSSiva Chandra Reddy 
isLanguageVersionSupported(const LangOptions & LangOpts)29b7b28c6cSSiva Chandra Reddy   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30b7b28c6cSSiva Chandra Reddy     return LangOpts.CPlusPlus;
31b7b28c6cSSiva Chandra Reddy   }
32b7b28c6cSSiva Chandra Reddy 
33b7b28c6cSSiva Chandra Reddy   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34b7b28c6cSSiva Chandra Reddy   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35b7b28c6cSSiva Chandra Reddy 
36*c92cf315Smichaelrj-google   // Ignore implicit functions (e.g. implicit constructors or destructors)
getCheckTraversalKind()37*c92cf315Smichaelrj-google   std::optional<TraversalKind> getCheckTraversalKind() const override {
38*c92cf315Smichaelrj-google     return TK_IgnoreUnlessSpelledInSource;
39*c92cf315Smichaelrj-google   }
40*c92cf315Smichaelrj-google 
41b7b28c6cSSiva Chandra Reddy private:
425b37cddfSCarlos Galvez   FileExtensionsSet HeaderFileExtensions;
43b7b28c6cSSiva Chandra Reddy };
44b7b28c6cSSiva Chandra Reddy 
45b7b28c6cSSiva Chandra Reddy } // namespace clang::tidy::llvm_libc
46b7b28c6cSSiva Chandra Reddy 
47b7b28c6cSSiva Chandra Reddy #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_INLINEFUNCTIONDECLCHECK_H
48