clang-tools 10.0.0

HeaderGuardCheck.h
Go to the documentation of this file.
1 //===--- HeaderGuardCheck.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_LLVM_HEADERGUARDCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_HEADERGUARDCHECK_H
11
12 #include "../utils/HeaderGuard.h"
13
14 namespace clang {
15 namespace tidy {
16 namespace llvm_check {
17
18 /// Finds and fixes header guards that do not adhere to LLVM style.
19 /// For the user-facing documentation see:
20 /// http://clang.llvm.org/extra/clang-tidy/checks/llvm-header-guard.html
21 /// The check supports these options:
22 /// - `HeaderFileExtensions`: a comma-separated list of filename extensions of
23 /// header files (The filename extension should not contain "." prefix).
24 /// ",h,hh,hpp,hxx" by default.
25 /// For extension-less header files, using an empty string or leaving an
26 /// empty string between "," if there are other filename extensions.
27 class LLVMHeaderGuardCheck : public utils::HeaderGuardCheck {
28 public:
29 LLVMHeaderGuardCheck(StringRef Name, ClangTidyContext *Context);
30
31 bool shouldSuggestEndifComment(StringRef Filename) override { return false; }
32 std::string getHeaderGuard(StringRef Filename, StringRef OldGuard) override;
33 };
34
35 } // namespace llvm_check
36 } // namespace tidy
37 } // namespace clang
38
39 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_HEADERGUARDCHECK_H
clang::tidy::llvm_check::LLVMHeaderGuardCheck::getHeaderGuard
std::string getHeaderGuard(StringRef Filename, StringRef OldGuard) override
Gets the canonical header guard for a file.
Definition: HeaderGuardCheck.cpp:19
clang::tidy::utils::HeaderGuardCheck
Finds and fixes header guards.
Definition: HeaderGuard.h:26
clang::tidy::llvm_check::LLVMHeaderGuardCheck
Finds and fixes header guards that do not adhere to LLVM style.
Definition: HeaderGuardCheck.h:27
Filename
std::string Filename
Filename as a string.
Definition: IncludeOrderCheck.cpp:39
clang::tidy::llvm_check::LLVMHeaderGuardCheck::LLVMHeaderGuardCheck
LLVMHeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
Definition: HeaderGuardCheck.cpp:15
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:77
clang::tidy::llvm_check::LLVMHeaderGuardCheck::shouldSuggestEndifComment
bool shouldSuggestEndifComment(StringRef Filename) override
Returns true if the check should suggest inserting a trailing comment on the #endif of the header gua...
Definition: HeaderGuardCheck.h:31