clang-tools  14.0.0git
Namespaces | Classes | Typedefs | Functions
clang::tidy::utils Namespace Reference

Namespaces

 decl_ref_expr
 
 fixit
 
 lexer
 
 options
 
 type_traits
 

Classes

class  ExceptionAnalyzer
 This class analysis if a FunctionDecl can in principle throw an exception, either directly or indirectly. More...
 
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 Stmts to the CFGBlock that contains them. More...
 
class  TransformerClangTidyCheck
 A base class for defining a ClangTidy check based on a RewriteRule. More...
 
class  UsingInserter
 

Typedefs

typedef llvm::SmallSet< llvm::StringRef, 5 > FileExtensionsSet
 

Functions

static bool isAccessForVar (const Stmt *S, const VarDecl *Var)
 Return whether S is a reference to the declaration of Var. More...
 
static bool capturesByRef (const CXXRecordDecl *RD, const VarDecl *Var)
 
static bool isPtrOrReferenceForVar (const Stmt *S, const VarDecl *Var)
 Return whether Var has a pointer or reference in S. More...
 
static bool hasPtrOrReferenceInStmt (const Stmt *S, const VarDecl *Var)
 Return whether Var has a pointer or reference in S. More...
 
static bool refersToEnclosingLambdaCaptureByRef (const Decl *Func, const VarDecl *Var)
 
bool hasPtrOrReferenceInFunc (const Decl *Func, const VarDecl *Var)
 Returns whether Var has a pointer or reference in Func. More...
 
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...
 
bool rangeIsEntirelyWithinMacroArgument (SourceRange Range, const SourceManager *SM)
 
bool rangeContainsMacroExpansion (SourceRange Range, const SourceManager *SM)
 
bool rangeCanBeFixed (SourceRange Range, const SourceManager *SM)
 
static bool isBaseOf (const Type *DerivedType, const Type *BaseType)
 
static SmallVector< const Stmt *, 1 > getParentStmts (const Stmt *S, ASTContext *Context)
 
bool isExpansionLocInHeaderFile (SourceLocation Loc, const SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions)
 Checks whether expansion location of Loc is in header file. More...
 
bool isPresumedLocInHeaderFile (SourceLocation Loc, SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions)
 Checks whether presumed location of Loc is in header file. More...
 
bool isSpellingLocInHeaderFile (SourceLocation Loc, SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions)
 Checks whether spelling location of Loc is in header file. More...
 
bool parseFileExtensions (StringRef AllFileExtensions, FileExtensionsSet &FileExtensions, StringRef Delimiters)
 Parses header file extensions from a semicolon-separated list. More...
 
llvm::Optional< StringRef > getFileExtension (StringRef FileName, const FileExtensionsSet &FileExtensions)
 Decides whether a file has a header file extension. More...
 
bool isFileExtension (StringRef FileName, const FileExtensionsSet &FileExtensions)
 Decides whether a file has one of the specified file extensions. More...
 
StringRef defaultHeaderFileExtensions ()
 Returns recommended default value for the list of header file extensions. More...
 
StringRef defaultImplementationFileExtensions ()
 Returns recommended default value for the list of implementation file extensions. More...
 
StringRef defaultFileExtensionDelimiters ()
 Returns recommended default value for the list of file extension delimiters. 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 bool hasExplanation (const RewriteRule::Case &C)
 
static void verifyRule (const RewriteRule &Rule)
 
static StringRef getUnqualifiedName (StringRef QualifiedName)
 

Typedef Documentation

◆ FileExtensionsSet

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

Definition at line 22 of file FileExtensionsUtils.h.

Function Documentation

◆ AST_MATCHER_P()

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

Definition at line 24 of file NamespaceAliaser.cpp.

◆ capturesByRef()

static bool clang::tidy::utils::capturesByRef ( const CXXRecordDecl *  RD,
const VarDecl *  Var 
)
static

Definition at line 26 of file Aliasing.cpp.

References C.

Referenced by isPtrOrReferenceForVar(), and refersToEnclosingLambdaCaptureByRef().

◆ cleanPath()

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

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

Definition at line 21 of file HeaderGuard.cpp.

◆ defaultFileExtensionDelimiters()

StringRef clang::tidy::utils::defaultFileExtensionDelimiters ( )
inline

Returns recommended default value for the list of file extension delimiters.

Definition at line 48 of file FileExtensionsUtils.h.

Referenced by clang::tidy::utils::HeaderGuardCheck::HeaderGuardCheck().

◆ defaultHeaderFileExtensions()

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

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

Definition at line 38 of file FileExtensionsUtils.h.

◆ defaultImplementationFileExtensions()

StringRef clang::tidy::utils::defaultImplementationFileExtensions ( )
inline

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

Definition at line 42 of file FileExtensionsUtils.h.

◆ 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 40 of file ASTUtils.cpp.

◆ getFileExtension()

llvm::Optional< StringRef > clang::tidy::utils::getFileExtension ( StringRef  FileName,
const FileExtensionsSet FileExtensions 
)

Decides whether a file has a header file extension.

Returns the file extension, if included in the provided set.

Definition at line 57 of file FileExtensionsUtils.cpp.

References FileName.

Referenced by isFileExtension().

◆ getParentStmts()

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

◆ getSurroundingFunction()

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

Definition at line 20 of file ASTUtils.cpp.

◆ getUnqualifiedName()

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

Definition at line 22 of file UsingInserter.cpp.

◆ hasExplanation()

static bool clang::tidy::utils::hasExplanation ( const RewriteRule::Case &  C)
static

Definition at line 19 of file TransformerClangTidyCheck.cpp.

References C.

Referenced by verifyRule().

◆ hasPtrOrReferenceInFunc()

bool clang::tidy::utils::hasPtrOrReferenceInFunc ( const Decl Func,
const VarDecl *  Var 
)

Returns whether Var has a pointer or reference in Func.

Example: void f() { int n; ... int *p = }

For f() and n the function returns true because p is a pointer to n created in f().

Definition at line 94 of file Aliasing.cpp.

References hasPtrOrReferenceInStmt(), and refersToEnclosingLambdaCaptureByRef().

◆ hasPtrOrReferenceInStmt()

static bool clang::tidy::utils::hasPtrOrReferenceInStmt ( const Stmt *  S,
const VarDecl *  Var 
)
static

Return whether Var has a pointer or reference in S.

Definition at line 66 of file Aliasing.cpp.

References isPtrOrReferenceForVar().

Referenced by hasPtrOrReferenceInFunc().

◆ isAccessForVar()

static bool clang::tidy::utils::isAccessForVar ( const Stmt *  S,
const VarDecl *  Var 
)
static

Return whether S is a reference to the declaration of Var.

Definition at line 19 of file Aliasing.cpp.

Referenced by isPtrOrReferenceForVar().

◆ isBaseOf()

static bool clang::tidy::utils::isBaseOf ( const Type *  DerivedType,
const Type *  BaseType 
)
static

◆ IsBinaryOrTernary()

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

Definition at line 27 of file ASTUtils.cpp.

◆ isExpansionLocInHeaderFile()

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

Checks whether expansion location of Loc is in header file.

Definition at line 17 of file FileExtensionsUtils.cpp.

References isFileExtension(), Loc, and SM.

◆ isFileExtension()

bool clang::tidy::utils::isFileExtension ( StringRef  FileName,
const FileExtensionsSet FileExtensions 
)

◆ isPresumedLocInHeaderFile()

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

Checks whether presumed location of Loc is in header file.

Definition at line 23 of file FileExtensionsUtils.cpp.

References isFileExtension(), Loc, and SM.

◆ isPtrOrReferenceForVar()

static bool clang::tidy::utils::isPtrOrReferenceForVar ( const Stmt *  S,
const VarDecl *  Var 
)
static

Return whether Var has a pointer or reference in S.

Definition at line 34 of file Aliasing.cpp.

References capturesByRef(), ns1::ns2::D, Decl, and isAccessForVar().

Referenced by hasPtrOrReferenceInStmt().

◆ isSpellingLocInHeaderFile()

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

Checks whether spelling location of Loc is in header file.

Definition at line 29 of file FileExtensionsUtils.cpp.

References isFileExtension(), Loc, and SM.

◆ parseFileExtensions()

bool clang::tidy::utils::parseFileExtensions ( StringRef  AllFileExtensions,
FileExtensionsSet FileExtensions,
StringRef  Delimiters 
)

Parses header file extensions from a semicolon-separated list.

Definition at line 35 of file FileExtensionsUtils.cpp.

References Suffix, and Suffixes.

Referenced by clang::tidy::utils::HeaderGuardCheck::HeaderGuardCheck().

◆ rangeCanBeFixed()

bool clang::tidy::utils::rangeCanBeFixed ( SourceRange  Range,
const SourceManager *  SM 
)

◆ rangeContainsMacroExpansion()

bool clang::tidy::utils::rangeContainsMacroExpansion ( SourceRange  Range,
const SourceManager *  SM 
)

Definition at line 83 of file ASTUtils.cpp.

References Range, rangeIsEntirelyWithinMacroArgument(), and SM.

Referenced by rangeCanBeFixed().

◆ rangeIsEntirelyWithinMacroArgument()

bool clang::tidy::utils::rangeIsEntirelyWithinMacroArgument ( SourceRange  Range,
const SourceManager *  SM 
)

Definition at line 67 of file ASTUtils.cpp.

References Range, and SM.

Referenced by rangeCanBeFixed(), and rangeContainsMacroExpansion().

◆ refersToEnclosingLambdaCaptureByRef()

static bool clang::tidy::utils::refersToEnclosingLambdaCaptureByRef ( const Decl Func,
const VarDecl *  Var 
)
static

Definition at line 81 of file Aliasing.cpp.

References capturesByRef(), and clang::doc::MD().

Referenced by hasPtrOrReferenceInFunc().

◆ verifyRule()

static void clang::tidy::utils::verifyRule ( const RewriteRule &  Rule)
static