clang-tools
3.9.0
Main Page
Namespaces
Classes
Files
File List
File Members
llvm.src
tools
clang
tools
extra
clang-tidy
utils
HeaderGuard.h
Go to the documentation of this file.
1
//===--- HeaderGuard.h - clang-tidy -----------------------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADERGUARD_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADERGUARD_H
12
13
#include "../ClangTidy.h"
14
15
namespace
clang {
16
namespace
tidy {
17
namespace
utils {
18
19
/// Finds and fixes header guards.
20
class
HeaderGuardCheck
:
public
ClangTidyCheck
{
21
public
:
22
HeaderGuardCheck
(StringRef
Name
,
ClangTidyContext
*Context)
23
:
ClangTidyCheck
(Name, Context) {}
24
void
registerPPCallbacks
(CompilerInstance &Compiler)
override
;
25
26
/// Returns ``true`` if the check should suggest inserting a trailing comment
27
/// on the ``#endif`` of the header guard. It will use the same name as
28
/// returned by ``HeaderGuardCheck::getHeaderGuard``.
29
virtual
bool
shouldSuggestEndifComment
(StringRef
Filename
);
30
/// Returns ``true`` if the check should suggest changing an existing header
31
/// guard to the string returned by ``HeaderGuardCheck::getHeaderGuard``.
32
virtual
bool
shouldFixHeaderGuard
(StringRef
Filename
);
33
/// Returns ``true`` if the check should add a header guard to the file
34
/// if it has none.
35
virtual
bool
shouldSuggestToAddHeaderGuard
(StringRef
Filename
);
36
/// Returns a replacement for the ``#endif`` line with a comment mentioning
37
/// \p HeaderGuard. The replacement should start with ``endif``.
38
virtual
std::string
formatEndIf
(StringRef HeaderGuard);
39
/// Gets the canonical header guard for a file.
40
virtual
std::string
getHeaderGuard
(StringRef
Filename
,
41
StringRef OldGuard = StringRef()) = 0;
42
};
43
44
}
// namespace utils
45
}
// namespace tidy
46
}
// namespace clang
47
48
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADERGUARD_H
clang::tidy::utils::HeaderGuardCheck::shouldSuggestEndifComment
virtual bool shouldSuggestEndifComment(StringRef Filename)
Returns true if the check should suggest inserting a trailing comment on the #endif of the header gua...
Definition:
HeaderGuard.cpp:276
Name
const std::string Name
Definition:
USRFinder.cpp:140
clang::tidy::utils::HeaderGuardCheck::getHeaderGuard
virtual std::string getHeaderGuard(StringRef Filename, StringRef OldGuard=StringRef())=0
Gets the canonical header guard for a file.
clang::tidy::utils::HeaderGuardCheck
Finds and fixes header guards.
Definition:
HeaderGuard.h:20
clang::tidy::utils::HeaderGuardCheck::HeaderGuardCheck
HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
Definition:
HeaderGuard.h:22
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:110
clang::tidy::utils::HeaderGuardCheck::formatEndIf
virtual std::string formatEndIf(StringRef HeaderGuard)
Returns a replacement for the #endif line with a comment mentioning HeaderGuard.
Definition:
HeaderGuard.cpp:286
Filename
std::string Filename
Filename as a string.
Definition:
IncludeOrderCheck.cpp:36
clang::tidy::utils::HeaderGuardCheck::shouldFixHeaderGuard
virtual bool shouldFixHeaderGuard(StringRef Filename)
Returns true if the check should suggest changing an existing header guard to the string returned by ...
Definition:
HeaderGuard.cpp:280
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:135
clang::tidy::utils::HeaderGuardCheck::registerPPCallbacks
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
Definition:
HeaderGuard.cpp:270
clang::tidy::utils::HeaderGuardCheck::shouldSuggestToAddHeaderGuard
virtual bool shouldSuggestToAddHeaderGuard(StringRef Filename)
Returns true if the check should add a header guard to the file if it has none.
Definition:
HeaderGuard.cpp:282
Generated on Wed Aug 31 2016 16:57:10 for clang-tools by
1.8.6