clang-tools 22.0.0git
clang::tidy::utils::HeaderGuardCheck Class Referenceabstract

Finds and fixes header guards. More...

#include <HeaderGuard.h>

Inheritance diagram for clang::tidy::utils::HeaderGuardCheck:
[legend]

Public Member Functions

 HeaderGuardCheck (StringRef Name, ClangTidyContext *Context)
void registerPPCallbacks (const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
std::string sanitizeHeaderGuard (StringRef Guard)
 Ensure that the provided header guard is a non-reserved identifier.
virtual std::string formatEndIf (StringRef HeaderGuard)
 Returns true if the check should suggest inserting a trailing comment / on the #endif of the header guard.
virtual std::string getHeaderGuard (StringRef Filename, StringRef OldGuard=StringRef())=0
 Gets the canonical header guard for a file.

Detailed Description

Finds and fixes header guards.

Definition at line 18 of file HeaderGuard.h.

Constructor & Destructor Documentation

◆ HeaderGuardCheck()

clang::tidy::utils::HeaderGuardCheck::HeaderGuardCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Member Function Documentation

◆ formatEndIf()

std::string clang::tidy::utils::HeaderGuardCheck::formatEndIf ( StringRef HeaderGuard)
virtual

Returns true if the check should suggest inserting a trailing comment / on the #endif of the header guard.

It will use the same name as / returned by HeaderGuardCheck::getHeaderGuard. virtual bool shouldSuggestEndifComment(StringRef Filename); / Returns true if the check should suggest changing an existing header / guard to the string returned by HeaderGuardCheck::getHeaderGuard. virtual bool shouldFixHeaderGuard(StringRef Filename); / Returns true if the check should add a header guard to the file / if it has none. virtual bool shouldSuggestToAddHeaderGuard(StringRef Filename); / Returns a replacement for the #endif line with a comment mentioning / HeaderGuard. The replacement should start with endif.

Definition at line 293 of file HeaderGuard.cpp.

◆ getHeaderGuard()

virtual std::string clang::tidy::utils::HeaderGuardCheck::getHeaderGuard ( StringRef Filename,
StringRef OldGuard = StringRef() )
pure virtual

Gets the canonical header guard for a file.

Implemented in clang::tidy::llvm_check::LLVMHeaderGuardCheck.

◆ registerPPCallbacks()

void clang::tidy::utils::HeaderGuardCheck::registerPPCallbacks ( const SourceManager & SM,
Preprocessor * PP,
Preprocessor * ModuleExpanderPP )
override

Definition at line 272 of file HeaderGuard.cpp.

◆ sanitizeHeaderGuard()

std::string clang::tidy::utils::HeaderGuardCheck::sanitizeHeaderGuard ( StringRef Guard)

Ensure that the provided header guard is a non-reserved identifier.

Definition at line 278 of file HeaderGuard.cpp.


The documentation for this class was generated from the following files: