clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Namespaces | Classes | Typedefs | Functions | Variables
clang::tidy Namespace Reference

## Namespaces
| cert
| cppcoreguidelines
| google
| lexer_utils
| llvm
| matchers
| misc
| modernize
| performance
| readability
| type_traits

## Classes
class | OptionsView
| Provides access to the `ClangTidyCheck` options via check-local names. More...
class | ClangTidyCheck
| Base class for all clang-tidy checks. More...
class | ClangTidyASTConsumerFactory
struct | ClangTidyMessage
| A message from a clang-tidy check. More...
struct | ClangTidyError
| A detected error complete with information to display diagnostic and automatic fix. More...
class | GlobList
| Read-only set of strings represented as a list of positive and negative globs. More...
struct | ClangTidyStats
| Contains displayed and ignored diagnostic counters for a ClangTidy run. More...
struct | ProfileData
| Container for clang-tidy profiling data. More...
class | ClangTidyContext
| Every `ClangTidyCheck` reports errors through a `DiagnosticsEngine` provided by this context. More...
class | ClangTidyDiagnosticConsumer
| A diagnostic consumer that turns each `Diagnostic` into a `SourceManager-independent` `ClangTidyError`. More...
class | ClangTidyCheckFactories
| A collection of `ClangTidyCheckFactory` instances. More...
class | ClangTidyModule
| A clang-tidy module groups a number of `ClangTidyChecks` and gives them a prefixed name. More...
struct | FileFilter
| Contains a list of line ranges in a single file. More...
struct | ClangTidyGlobalOptions
| Global options. More...
struct | ClangTidyOptions
| Contains options for clang-tidy. More...
class | ClangTidyOptionsProvider
| Abstract interface for retrieving various ClangTidy options. More...
class | DefaultOptionsProvider
| Implementation of the `ClangTidyOptionsProvider` interface, which returns the same options for all files. More...
class | FileOptionsProvider
| Implementation of the `ClangTidyOptionsProvider` interface, which tries to find a configuration file in the closest parent directory of each source file. More...
class | ProBoundsArrayToPointerDecayCheck
| This check flags all array to pointer decays. More...
class | ProBoundsConstantArrayIndexCheck
| This checks that all array subscriptions on static arrays and std::arrays have a constant index and are within bounds. More...
class | ProBoundsPointerArithmeticCheck
| Flags all kinds of pointer arithmetic that have result of pointer type, i.e. More...
class | ProTypeConstCastCheck
| This check flags all instances of const_cast. More...
class | ProTypeCstyleCastCheck
| This check flags all use of C-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast. More...
class | ProTypeReinterpretCastCheck
| Flags all occurrences of reinterpret_cast. More...
class | ProTypeStaticCastDowncastCheck
| Checks for usages of static_cast, where a base class is downcasted to a derived class. More...
class | ProTypeUnionAccessCheck
| This check flags all access to members of unions. More...
class | ProTypeVarargCheck
| This check flags all calls to c-style variadic functions and all use of va_arg. More...
class | AssertSideEffectCheck
| Finds `assert()` with side effect. More...
class | MacroParenthesesCheck
| Finds macros that can have unexpected behaviour due to missing parentheses. More...
class | MoveConstructorInitCheck
| The check flags user-defined move constructors that have a ctor-initializer initializing a member or base class through a copy constructor instead of a move constructor. More...
class | NoexceptMoveConstructorCheck
| The check flags user-defined move constructors and assignment operators not marked with `noexcept` or marked with `noexcept(expr)` where `expr` evaluates to `false` (but is not a `false` literal itself). More...
class | NonCopyableObjectsCheck
| The check flags dereferences and non-pointer declarations of objects that are not meant to be passed by value, such as C FILE objects. More...
class | SizeofContainerCheck
| Find usages of sizeof on expressions of STL container types. More...
class | StaticAssertCheck
| Replaces `assert()` with `static_assert()` if the condition is evaluatable at compile time. More...
class | StringIntegerAssignmentCheck
| Finds instances where an integer is assigned to a string. More...
class | ThrowByValueCatchByReferenceCheck
| checks for locations that do not throw by value More...
class | UnusedAliasDeclsCheck
| Finds unused namespace alias declarations. More...
class | UnusedParametersCheck
| Finds unused parameters and fixes them, so that `-Wunused-parameter` can be turned on. More...
class | ImplicitBoolCastCheck
| Checks for use of implicit bool casts in expressions. More...
class | UniqueptrDeleteReleaseCheck
| Flag statements of the form: delete <unique_ptr expr>="">.release() and replace them with: <unique_ptr expr>=""> = nullptr. More...
class | HeaderGuardCheck
| Finds and fixes header guards. More...
class | IncludeInserterCallback
class | IncludeInserter
class | IncludeSorter

## Typedefs
typedef llvm::Registry < ClangTidyModule > | ClangTidyModuleRegistry

## Functions
static ClangTidyModuleRegistry::Add < cert::CERTModule > | X ("cert-module","Adds lint checks corresponding to CERT secure coding guidelines.")
static void | setStaticAnalyzerCheckerOpts (const ClangTidyOptions &Opts, AnalyzerOptionsRef AnalyzerOptions)
std::vector< std::string > | getCheckNames (const ClangTidyOptions &Options)
| Fills the list of check names that are enabled when the provided filters are applied. More...
ClangTidyOptions::OptionMap | getCheckOptions (const ClangTidyOptions &Options)
| Returns the effective check-specific options. More...
ClangTidyStats | runClangTidy (std::unique_ptr< ClangTidyOptionsProvider > OptionsProvider, const tooling::CompilationDatabase &Compilations, ArrayRef< std::string > InputFiles, std::vector< ClangTidyError > *Errors, ProfileData *Profile=nullptr)
| Run a set of clang-tidy checks on a set of files. More...
void | handleErrors (const std::vector< ClangTidyError > &Errors, bool Fix)
| Displays the found `Errors` to the users. More...
void | exportReplacements (const std::vector< ClangTidyError > &Errors, raw_ostream &OS)
| Serializes replacements into YAML and writes them to the specified output stream. More...
std::error_code | parseLineFilter (StringRef LineFilter, clang::tidy::ClangTidyGlobalOptions &Options)
| Parses -line-filter option and stores it to the `Options`. More...
llvm::ErrorOr< ClangTidyOptions > | parseConfiguration (StringRef Config)
std::string | configurationAsText (const ClangTidyOptions &Options)
| Serializes configuration to a YAML-encoded string. More...
std::error_code | parseLineFilter (llvm::StringRef LineFilter, ClangTidyGlobalOptions &Options)
| Parses LineFilter from JSON and stores it to the `Options`. More...
llvm::ErrorOr< ClangTidyOptions > | parseConfiguration (llvm::StringRef Config)
| Parses configuration from JSON and returns `ClangTidyOptions` or an error. More...
| AST_MATCHER_P (CXXForRangeStmt, hasRangeBeginEndStmt, ast_matchers::internal::Matcher< DeclStmt >, InnerMatcher)
| AST_MATCHER (Stmt, isInsideOfRangeBeginEndStmt)
| AST_MATCHER_P (Expr, hasParentIgnoringImpCasts, ast_matchers::internal::Matcher< Expr >, InnerMatcher)
static bool | needsConstCast (QualType SourceType, QualType DestType)
static bool | hasSingleVariadicArgumentWithValue (const CallExpr *C, uint64_t I)
static bool | isSurroundedLeft (const Token &T)
| Is argument surrounded properly with parentheses/braces/squares/commas? More...
static bool | isSurroundedRight (const Token &T)
| Is argument surrounded properly with parentheses/braces/squares/commas? More...
static bool | isKeyword (const Token &T)
| Is given TokenKind a keyword? More...
static bool | isWarnOp (const Token &T)
| Warning is written when one of these operators are not within parentheses. More...
static ClangTidyModuleRegistry::Add < misc::MiscModule > | X ("misc-module","Adds miscellaneous lint checks.")
template<typename T >
static CharSourceRange | removeNode (const MatchFinder::MatchResult &Result, const T *PrevNode, const T *Node, const T *NextNode)
static FixItHint | removeParameter (const MatchFinder::MatchResult &Result, const FunctionDecl *Function, unsigned Index)
static FixItHint | removeArgument (const MatchFinder::MatchResult &Result, const CallExpr *Call, unsigned Index)
static void | printStats (const ClangTidyStats &Stats)
static void | printProfileData (const ProfileData &Profile, llvm::raw_ostream &OS)
static std::unique_ptr < ClangTidyOptionsProvider > | createOptionsProvider ()
static int | clangTidyMain (int argc, const char **argv)
static std::string | cleanPath (StringRef Path)
| canonicalize a path by removing ./ and ../ components. More...

## Variables
volatile int | CERTModuleAnchorSource = 0
volatile int | CppCoreGuidelinesModuleAnchorSource = 0
const internal::VariadicDynCastAllOfMatcher < Stmt, VAArgExpr > | vAArgExpr
volatile int | GoogleModuleAnchorSource = 0
volatile int | LLVMModuleAnchorSource = 0
volatile int | MiscModuleAnchorSource = 0
volatile int | ModernizeModuleAnchorSource = 0
volatile int | PerformanceModuleAnchorSource = 0
volatile int | ReadabilityModuleAnchorSource = 0
static int LLVM_ATTRIBUTE_UNUSED | CERTModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | LLVMModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | CppCoreGuidelinesModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | GoogleModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | MiscModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | ModernizeModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | PerformanceModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED | ReadabilityModuleAnchorDestination

## Typedef Documentation

typedef llvm::Registry<ClangTidyModule> clang::tidy::ClangTidyModuleRegistry

Definition at line 21 of file ClangTidyModuleRegistry.h.

## Function Documentation

clang::tidy::AST_MATCHER | ( | Stmt | ,
|  | isInsideOfRangeBeginEndStmt |
| ) |  |

Definition at line 25 of file ProBoundsArrayToPointerDecayCheck.cpp.

References Finder.

clang::tidy::AST_MATCHER_P | ( | CXXForRangeStmt | ,
|  | hasRangeBeginEndStmt | ,
|  | ast_matchers::internal::Matcher< DeclStmt > | ,
|  | InnerMatcher |
| ) |  |

Definition at line 19 of file ProBoundsArrayToPointerDecayCheck.cpp.

References Finder.

clang::tidy::AST_MATCHER_P | ( | Expr | ,
|  | hasParentIgnoringImpCasts | ,
|  | ast_matchers::internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Definition at line 31 of file ProBoundsArrayToPointerDecayCheck.cpp.

References Finder.

static int clang::tidy::clangTidyMain | ( | int | argc,
|  | const char ** | argv
| ) |  |
| static

Definition at line 266 of file ClangTidyMain.cpp.

References clang::tidy::ClangTidyOptions::CheckOptions, ClangTidyCategory(), configurationAsText(), createOptionsProvider(), DumpConfig(), EnableCheckProfile(), ExportFixes(), exportReplacements(), Fix(), FixErrors(), getCheckNames(), getCheckOptions(), handleErrors(), ListChecks(), printProfileData(), printStats(), and runClangTidy().

Referenced by main().

static std::string clang::tidy::cleanPath | ( | StringRef | Path | ) |
| static

canonicalize a path by removing ./ and ../ components.

Definition at line 22 of file HeaderGuard.cpp.

std::string clang::tidy::configurationAsText | ( | const ClangTidyOptions & | Options | ) |

Serializes configuration to a YAML-encoded string.

Definition at line 275 of file ClangTidyOptions.cpp.

Referenced by clangTidyMain().

static std::unique_ptr<ClangTidyOptionsProvider> clang::tidy::createOptionsProvider | ( |  | ) |
| static

Definition at line 220 of file ClangTidyMain.cpp.

References clang::tidy::ClangTidyOptions::AnalyzeTemporaryDtors, AnalyzeTemporaryDtors(), Checks(), clang::tidy::ClangTidyOptions::Checks, Config(), DefaultChecks, HeaderFilter(), clang::tidy::ClangTidyOptions::HeaderFilterRegex, LineFilter(), parseConfiguration(), parseLineFilter(), clang::tidy::ClangTidyOptions::SystemHeaders, SystemHeaders(), and clang::tidy::ClangTidyOptions::User.

Referenced by clangTidyMain().

void clang::tidy::exportReplacements | ( | const std::vector< ClangTidyError > & | Errors,
|  | raw_ostream & | OS
| ) |  |

Serializes replacements into YAML and writes them to the specified output stream.

Definition at line 431 of file ClangTidy.cpp.

Referenced by clangTidyMain().

std::vector< std::string > clang::tidy::getCheckNames | ( | const ClangTidyOptions & | Options | ) |

Fills the list of check names that are enabled when the provided filters are applied.

Definition at line 354 of file ClangTidy.cpp.

References Context, and clang::tidy::ClangTidyASTConsumerFactory::getCheckNames().

Referenced by clangTidyMain().

ClangTidyOptions::OptionMap clang::tidy::getCheckOptions | ( | const ClangTidyOptions & | Options | ) |

Returns the effective check-specific options.

The method configures ClangTidy with the specified `Options` and collects effective options from all created checks. The returned set of options includes default check-specific options for all keys not overridden by `Options`.

Definition at line 362 of file ClangTidy.cpp.

References Context, and clang::tidy::ClangTidyASTConsumerFactory::getCheckOptions().

Referenced by clangTidyMain().

void clang::tidy::handleErrors | ( | const std::vector< ClangTidyError > & | Errors,
|  | bool | Fix
| ) |  |

Displays the found `Errors` to the users.

If `Fix` is true, `Errors` containing fixes are automatically applied.

Definition at line 424 of file ClangTidy.cpp.

Referenced by clangTidyMain().

static bool clang::tidy::hasSingleVariadicArgumentWithValue | ( | const CallExpr * | C,
|  | uint64_t | I
| ) |  |
| static

Definition at line 33 of file ProTypeVarargCheck.cpp.

Referenced by clang::tidy::ProTypeVarargCheck::check().

static bool clang::tidy::isKeyword | ( | const Token & | T | ) |
| static

Is given TokenKind a keyword?

Definition at line 56 of file MacroParenthesesCheck.cpp.

static bool clang::tidy::isSurroundedLeft | ( | const Token & | T | ) |
| static

Is argument surrounded properly with parentheses/braces/squares/commas?

Definition at line 44 of file MacroParenthesesCheck.cpp.

static bool clang::tidy::isSurroundedRight | ( | const Token & | T | ) |
| static

Is argument surrounded properly with parentheses/braces/squares/commas?

Definition at line 50 of file MacroParenthesesCheck.cpp.

static bool clang::tidy::isWarnOp | ( | const Token & | T | ) |
| static

Warning is written when one of these operators are not within parentheses.

Definition at line 62 of file MacroParenthesesCheck.cpp.

static bool clang::tidy::needsConstCast | ( | QualType | SourceType,
|  | QualType | DestType
| ) |  |
| static

Definition at line 20 of file ProTypeCstyleCastCheck.cpp.

Referenced by clang::tidy::ProTypeCstyleCastCheck::check().

llvm::ErrorOr<ClangTidyOptions> clang::tidy::parseConfiguration | ( | llvm::StringRef | Config | ) |

Parses configuration from JSON and returns `ClangTidyOptions` or an error.

llvm::ErrorOr<ClangTidyOptions> clang::tidy::parseConfiguration | ( | StringRef | Config | ) |

Definition at line 266 of file ClangTidyOptions.cpp.

Referenced by createOptionsProvider(), and clang::tidy::FileOptionsProvider::FileOptionsProvider().

std::error_code clang::tidy::parseLineFilter | ( | llvm::StringRef | LineFilter,
|  | ClangTidyGlobalOptions & | Options
| ) |  |

Parses LineFilter from JSON and stores it to the `Options`.

std::error_code clang::tidy::parseLineFilter | ( | StringRef | LineFilter,
|  | clang::tidy::ClangTidyGlobalOptions & | Options
| ) |  |

Parses -line-filter option and stores it to the `Options`.

Definition at line 259 of file ClangTidyOptions.cpp.

References clang::tidy::ClangTidyGlobalOptions::LineFilter.

Referenced by createOptionsProvider().

static void clang::tidy::printProfileData | ( | const ProfileData & | Profile,
|  | llvm::raw_ostream & | OS
| ) |  |
| static

Definition at line 181 of file ClangTidyMain.cpp.

References Line, and clang::tidy::ProfileData::Records.

Referenced by clangTidyMain().

static void clang::tidy::printStats | ( | const ClangTidyStats & | Stats | ) |
| static

Definition at line 154 of file ClangTidyMain.cpp.

References clang::tidy::ClangTidyStats::errorsIgnored(), clang::tidy::ClangTidyStats::ErrorsIgnoredCheckFilter, clang::tidy::ClangTidyStats::ErrorsIgnoredLineFilter, clang::tidy::ClangTidyStats::ErrorsIgnoredNOLINT, and clang::tidy::ClangTidyStats::ErrorsIgnoredNonUserCode.

Referenced by clangTidyMain().

static FixItHint clang::tidy::removeArgument | ( | const MatchFinder::MatchResult & | Result,
|  | const CallExpr * | Call,
|  | unsigned | Index
| ) |  |
| static

Definition at line 51 of file UnusedParametersCheck.cpp.

References removeNode().

template<typename T >

static CharSourceRange clang::tidy::removeNode | ( | const MatchFinder::MatchResult & | Result,
|  | const T * | PrevNode,
|  | const T * | Node,
|  | const T * | NextNode
| ) |  |
| static

Definition at line 25 of file UnusedParametersCheck.cpp.

Referenced by removeArgument(), and removeParameter().

static FixItHint clang::tidy::removeParameter | ( | const MatchFinder::MatchResult & | Result,
|  | const FunctionDecl * | Function,
|  | unsigned | Index
| ) |  |
| static

Definition at line 42 of file UnusedParametersCheck.cpp.

References removeNode().

ClangTidyStats clang::tidy::runClangTidy | ( | std::unique_ptr< ClangTidyOptionsProvider > | OptionsProvider,
|  | const tooling::CompilationDatabase & | Compilations,
|  | ArrayRef< std::string > | InputFiles,
|  | std::vector< ClangTidyError > * | Errors,
|  | ProfileData * | Profile = `nullptr`
| ) |  |

Run a set of clang-tidy checks on a set of files.

Parameters

  Profile | if provided, it enables check profile collection in MatchFinder, and will contain the result of the profile.

Definition at line 371 of file ClangTidy.cpp.

References Context, clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer(), clang::tidy::ClangTidyOptions::ExtraArgs, clang::tidy::ClangTidyOptions::ExtraArgsBefore, Filename, clang::tidy::ClangTidyContext::getErrors(), clang::tidy::ClangTidyContext::getOptionsForFile(), clang::tidy::ClangTidyContext::getStats(), and clang::tidy::ClangTidyContext::setCheckProfileData().

Referenced by clangTidyMain().

static void clang::tidy::setStaticAnalyzerCheckerOpts | ( | const ClangTidyOptions & | Opts,
|  | AnalyzerOptionsRef | AnalyzerOptions
| ) |  |
| static

Definition at line 205 of file ClangTidy.cpp.

References clang::tidy::ClangTidyOptions::CheckOptions.

Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer().

static ClangTidyModuleRegistry::Add<cert::CERTModule> clang::tidy::X | ( | "cert-module" | ,
|  | "Adds lint checks corresponding to CERT secure coding guidelines." |
| ) |  |
| static

static ClangTidyModuleRegistry::Add<misc::MiscModule> clang::tidy::X | ( | "misc-module" | ,
|  | "Adds miscellaneous lint checks." |
| ) |  |
| static

## Variable Documentation

int LLVM_ATTRIBUTE_UNUSED clang::tidy::CERTModuleAnchorDestination
| static

Initial value:
=
CERTModuleAnchorSource
clang::tidy::CERTModuleAnchorSource
volatile int CERTModuleAnchorSource
Definition: CERTTidyModule.cpp:72

Definition at line 352 of file ClangTidyMain.cpp.

volatile int clang::tidy::CERTModuleAnchorSource = 0

Definition at line 72 of file CERTTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::CppCoreGuidelinesModuleAnchorDestination
| static

Initial value:
=
CppCoreGuidelinesModuleAnchorSource
clang::tidy::CppCoreGuidelinesModuleAnchorSource
volatile int CppCoreGuidelinesModuleAnchorSource
Definition: CppCoreGuidelinesTidyModule.cpp:63

Definition at line 362 of file ClangTidyMain.cpp.

volatile int clang::tidy::CppCoreGuidelinesModuleAnchorSource = 0

Definition at line 63 of file CppCoreGuidelinesTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::GoogleModuleAnchorDestination
| static

Initial value:
=
GoogleModuleAnchorSource
clang::tidy::GoogleModuleAnchorSource
volatile int GoogleModuleAnchorSource
Definition: GoogleTidyModule.cpp:93

Definition at line 367 of file ClangTidyMain.cpp.

volatile int clang::tidy::GoogleModuleAnchorSource = 0

Definition at line 93 of file GoogleTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::LLVMModuleAnchorDestination
| static

Initial value:
=
LLVMModuleAnchorSource
clang::tidy::LLVMModuleAnchorSource
volatile int LLVMModuleAnchorSource
Definition: LLVMTidyModule.cpp:41

Definition at line 357 of file ClangTidyMain.cpp.

volatile int clang::tidy::LLVMModuleAnchorSource = 0

Definition at line 41 of file LLVMTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::MiscModuleAnchorDestination
| static

Initial value:
=
MiscModuleAnchorSource
clang::tidy::MiscModuleAnchorSource
volatile int MiscModuleAnchorSource
Definition: MiscTidyModule.cpp:104

Definition at line 372 of file ClangTidyMain.cpp.

volatile int clang::tidy::MiscModuleAnchorSource = 0

Definition at line 104 of file MiscTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::ModernizeModuleAnchorDestination
| static

Initial value:
=
ModernizeModuleAnchorSource
clang::tidy::ModernizeModuleAnchorSource
volatile int ModernizeModuleAnchorSource
Definition: ModernizeTidyModule.cpp:73

Definition at line 377 of file ClangTidyMain.cpp.

volatile int clang::tidy::ModernizeModuleAnchorSource = 0

Definition at line 73 of file ModernizeTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::PerformanceModuleAnchorDestination
| static

Initial value:
=
PerformanceModuleAnchorSource
clang::tidy::PerformanceModuleAnchorSource
volatile int PerformanceModuleAnchorSource
Definition: PerformanceTidyModule.cpp:36

Definition at line 382 of file ClangTidyMain.cpp.

volatile int clang::tidy::PerformanceModuleAnchorSource = 0

Definition at line 36 of file PerformanceTidyModule.cpp.

int LLVM_ATTRIBUTE_UNUSED clang::tidy::ReadabilityModuleAnchorDestination
| static

Initial value:
=
ReadabilityModuleAnchorSource
clang::tidy::ReadabilityModuleAnchorSource
volatile int ReadabilityModuleAnchorSource
Definition: ReadabilityTidyModule.cpp:68

Definition at line 387 of file ClangTidyMain.cpp.

volatile int clang::tidy::ReadabilityModuleAnchorSource = 0

Definition at line 68 of file ReadabilityTidyModule.cpp.

const internal::VariadicDynCastAllOfMatcher<Stmt, VAArgExpr> clang::tidy::vAArgExpr

Definition at line 19 of file ProTypeVarargCheck.cpp.

Referenced by clang::tidy::ProTypeVarargCheck::registerMatchers().