clang-tools 6.0.0

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

## Namespaces
| decl_ref_expr
| fixit
| lexer
| options
| type_traits

## Classes
class | ExprSequence
| Provides information about the evaluation order of (sub-)expressions within a `CFGBlock`. More...
class | HeaderGuardCheck
| Finds and fixes header guards. More...
class | IncludeInserter
| Produces fixes to insert specified includes to source files, if not yet present. More...
class | IncludeInserterCallback
class | IncludeSorter
| Class used by `IncludeInserterCallback` to record the names of the inclusions in a given source file being processed and generate the necessary commands to sort the inclusions according to the precedence encoded in `IncludeKinds`. More...
class | NamespaceAliaser
class | StmtToBlockMap
| Maps `Stmt`s to the `CFGBlock` that contains them. More...
class | UsingInserter

## Typedefs
typedef llvm::SmallSet< llvm::StringRef, 5 > | HeaderFileExtensionsSet

## Functions
const FunctionDecl * | getSurroundingFunction (ASTContext &Context, const Stmt &Statement)
bool | IsBinaryOrTernary (const Expr *E)
bool | exprHasBitFlagWithSpelling (const Expr *Flags, const SourceManager &SM, const LangOptions &LangOpts, StringRef FlagName)
| Checks whether a macro flag is present in the given argument. More...
static SmallVector< const Stmt *, 1 > | getParentStmts (const Stmt *S, ASTContext *Context)
bool | isExpansionLocInHeaderFile (SourceLocation Loc, const SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
| Checks whether expansion location of `Loc` is in header file. More...
bool | isPresumedLocInHeaderFile (SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
| Checks whether presumed location of `Loc` is in header file. More...
bool | isSpellingLocInHeaderFile (SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
| Checks whether spelling location of `Loc` is in header file. More...
bool | parseHeaderFileExtensions (StringRef AllHeaderFileExtensions, HeaderFileExtensionsSet &HeaderFileExtensions, char delimiter)
| Parses header file extensions from a semicolon-separated list. More...
bool | isHeaderFileExtension (StringRef FileName, const HeaderFileExtensionsSet &HeaderFileExtensions)
| Decides whether a file has a header file extension. More...
StringRef | defaultHeaderFileExtensions ()
| Returns recommended default value for the list of header file extensions. More...
static std::string | cleanPath (StringRef Path)
| canonicalize a path by removing ./ and ../ components. More...
| AST_MATCHER_P (NamespaceAliasDecl, hasTargetNamespace, ast_matchers::internal::Matcher< NamespaceDecl >, innerMatcher)
static StringRef | getUnqualifiedName (StringRef QualifiedName)

## Typedef Documentation

## ◆ HeaderFileExtensionsSet

typedef llvm::SmallSet<llvm::StringRef, 5> clang::tidy::utils::HeaderFileExtensionsSet

Definition at line 22 of file HeaderFileExtensionsUtils.h.

## Function Documentation

## ◆ AST_MATCHER_P()

clang::tidy::utils::AST_MATCHER_P | ( | NamespaceAliasDecl | ,
|  | hasTargetNamespace | ,
|  | ast_matchers::internal::Matcher< NamespaceDecl > | ,
|  | innerMatcher |
| ) |  |

Definition at line 25 of file NamespaceAliaser.cpp.

## ◆ cleanPath()

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

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

Definition at line 22 of file HeaderGuard.cpp.

References Path.

## ◆ defaultHeaderFileExtensions()

StringRef clang::tidy::utils::defaultHeaderFileExtensions | ( |  | ) |
| inline

Returns recommended default value for the list of header file extensions.

Definition at line 41 of file HeaderFileExtensionsUtils.h.

References isHeaderFileExtension(), and parseHeaderFileExtensions().

## ◆ exprHasBitFlagWithSpelling()

bool clang::tidy::utils::exprHasBitFlagWithSpelling | ( | const Expr * | Flags,
|  | const SourceManager & | SM,
|  | const LangOptions & | LangOpts,
|  | StringRef | FlagName
| ) |  |

Checks whether a macro flag is present in the given argument.

Only considers cases of single match or match in a binary OR expression. For example, <needed-flag> or <flag> | <needed-flag> | ...

Definition at line 43 of file ASTUtils.cpp.

Referenced by clang::tidy::android::CloexecCheck::insertMacroFlag().

## ◆ getParentStmts()

static SmallVector<const Stmt *, 1> clang::tidy::utils::getParentStmts | ( | const Stmt * | S,
|  | ASTContext * | Context
| ) |  |
| static

Definition at line 28 of file ExprSequence.cpp.

Referenced by clang::tidy::utils::StmtToBlockMap::blockContainingStmt(), clang::tidy::utils::ExprSequence::inSequence(), and clang::tidy::utils::ExprSequence::potentiallyAfter().

## ◆ getSurroundingFunction()

const FunctionDecl * clang::tidy::utils::getSurroundingFunction | ( | ASTContext & | Context,
|  | const Stmt & | Statement
| ) |  |

Definition at line 21 of file ASTUtils.cpp.

## ◆ getUnqualifiedName()

static StringRef clang::tidy::utils::getUnqualifiedName | ( | StringRef | QualifiedName | ) |
| static

Definition at line 23 of file UsingInserter.cpp.

## ◆ IsBinaryOrTernary()

bool clang::tidy::utils::IsBinaryOrTernary | ( | const Expr * | E | ) |

Definition at line 28 of file ASTUtils.cpp.

Referenced by clang::tidy::readability::ContainerSizeEmptyCheck::check().

## ◆ isExpansionLocInHeaderFile()

bool clang::tidy::utils::isExpansionLocInHeaderFile | ( | SourceLocation | Loc,
|  | const SourceManager & | SM,
|  | const HeaderFileExtensionsSet & | HeaderFileExtensions
| ) |  |

Checks whether expansion location of `Loc` is in header file.

Definition at line 18 of file HeaderFileExtensionsUtils.cpp.

## ◆ isHeaderFileExtension()

bool clang::tidy::utils::isHeaderFileExtension | ( | StringRef | FileName,
|  | const HeaderFileExtensionsSet & | HeaderFileExtensions
| ) |  |

Decides whether a file has a header file extension.

Definition at line 60 of file HeaderFileExtensionsUtils.cpp.

Referenced by defaultHeaderFileExtensions(), clang::tidy::utils::HeaderGuardCheck::shouldSuggestEndifComment(), and clang::tidy::utils::HeaderGuardCheck::shouldSuggestToAddHeaderGuard().

## ◆ isPresumedLocInHeaderFile()

bool clang::tidy::utils::isPresumedLocInHeaderFile | ( | SourceLocation | Loc,
|  | SourceManager & | SM,
|  | const HeaderFileExtensionsSet & | HeaderFileExtensions
| ) |  |

Checks whether presumed location of `Loc` is in header file.

Definition at line 26 of file HeaderFileExtensionsUtils.cpp.

Referenced by clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::check().

## ◆ isSpellingLocInHeaderFile()

bool clang::tidy::utils::isSpellingLocInHeaderFile | ( | SourceLocation | Loc,
|  | SourceManager & | SM,
|  | const HeaderFileExtensionsSet & | HeaderFileExtensions
| ) |  |

Checks whether spelling location of `Loc` is in header file.

Definition at line 34 of file HeaderFileExtensionsUtils.cpp.

Referenced by clang::tidy::google::readability::GlobalNamesInHeadersCheck::check().

## ◆ parseHeaderFileExtensions()

bool clang::tidy::utils::parseHeaderFileExtensions | ( | StringRef | AllHeaderFileExtensions,
|  | HeaderFileExtensionsSet & | HeaderFileExtensions,
|  | char | delimiter
| ) |  |

Parses header file extensions from a semicolon-separated list.

Definition at line 42 of file HeaderFileExtensionsUtils.cpp.

Referenced by defaultHeaderFileExtensions(), and clang::tidy::utils::HeaderGuardCheck::HeaderGuardCheck().