clang-tools  7.0.0svn
Public Member Functions | Friends | List of all members
clang::tidy::utils::IncludeInserter Class Reference

Produces fixes to insert specified includes to source files, if not yet present. More...

#include <IncludeInserter.h>

Public Member Functions

 IncludeInserter (const SourceManager &SourceMgr, const LangOptions &LangOpts, IncludeSorter::IncludeStyle Style)
 ~IncludeInserter ()
std::unique_ptr< PPCallbacksCreatePPCallbacks ()
 Create PPCallbacks for registration with the compiler's preprocessor. More...
llvm::Optional< FixItHint > CreateIncludeInsertion (FileID FileID, llvm::StringRef Header, bool IsAngled)
 Creates a Header inclusion directive fixit. More...


class IncludeInserterCallback

Detailed Description

Produces fixes to insert specified includes to source files, if not yet present.

IncludeInserter can be used by ClangTidyCheck in the following fashion:

class MyCheck : public ClangTidyCheck {
void registerPPCallbacks(CompilerInstance& Compiler) override {
Inserter.reset(new IncludeInserter(&Compiler.getSourceManager(),
void registerMatchers(ast_matchers::MatchFinder* Finder) override { ... }
void check(
const ast_matchers::MatchFinder::MatchResult& Result) override {
Result.SourceManager->getMainFileID(), "path/to/Header.h",
std::unique_ptr<IncludeInserter> Inserter;

Definition at line 55 of file IncludeInserter.h.

Constructor & Destructor Documentation

◆ IncludeInserter()

clang::tidy::utils::IncludeInserter::IncludeInserter ( const SourceManager &  SourceMgr,
const LangOptions &  LangOpts,
IncludeSorter::IncludeStyle  Style 

Definition at line 38 of file IncludeInserter.cpp.

◆ ~IncludeInserter()

clang::tidy::utils::IncludeInserter::~IncludeInserter ( )

Definition at line 43 of file IncludeInserter.cpp.

Member Function Documentation

◆ CreateIncludeInsertion()

llvm::Optional< FixItHint > clang::tidy::utils::IncludeInserter::CreateIncludeInsertion ( FileID  FileID,
llvm::StringRef  Header,
bool  IsAngled 

Creates a Header inclusion directive fixit.

Returns llvm::None on error or if inclusion directive already exists.

Definition at line 50 of file IncludeInserter.cpp.

References FileName, and IsAngled.

◆ CreatePPCallbacks()

std::unique_ptr< PPCallbacks > clang::tidy::utils::IncludeInserter::CreatePPCallbacks ( )

Create PPCallbacks for registration with the compiler's preprocessor.

Definition at line 45 of file IncludeInserter.cpp.

Friends And Related Function Documentation

◆ IncludeInserterCallback

friend class IncludeInserterCallback

Definition at line 78 of file IncludeInserter.h.

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