clang-tools 10.0.0

Enumerations | Functions
clang::tidy::utils::fixit Namespace Reference

## Enumerations
enum | QualifierPolicy { QualifierPolicy::Left, QualifierPolicy::Right }
| This enum defines where the qualifier shall be preferably added. More...
enum | QualifierTarget { QualifierTarget::Pointee, QualifierTarget::Value }
| This enum defines which entity is the target for adding the qualifier. More...

## Functions
FixItHint | changeVarDeclToReference (const VarDecl &Var, ASTContext &Context)
| Creates fix to make `VarDecl` a reference by adding `&`. More...
static bool | isValueType (const Type *T)
static bool | isValueType (QualType QT)
static bool | isMemberOrFunctionPointer (QualType QT)
static bool | locDangerous (SourceLocation S)
static Optional< SourceLocation > | skipLParensBackwards (SourceLocation Start, const ASTContext &Context)
static Optional< FixItHint > | fixIfNotDangerous (SourceLocation Loc, StringRef Text)
static std::string | buildQualifier (DeclSpec::TQ Qualifier, bool WhitespaceBefore=false)
static Optional< FixItHint > | changeValue (const VarDecl &Var, DeclSpec::TQ Qualifier, QualifierTarget QualTarget, QualifierPolicy QualPolicy, const ASTContext &Context)
static Optional< FixItHint > | changePointerItself (const VarDecl &Var, DeclSpec::TQ Qualifier, const ASTContext &Context)
static Optional< FixItHint > | changePointer (const VarDecl &Var, DeclSpec::TQ Qualifier, const Type *Pointee, QualifierTarget QualTarget, QualifierPolicy QualPolicy, const ASTContext &Context)
static Optional< FixItHint > | changeReferencee (const VarDecl &Var, DeclSpec::TQ Qualifier, QualType Pointee, QualifierTarget QualTarget, QualifierPolicy QualPolicy, const ASTContext &Context)
Optional< FixItHint > | addQualifierToVarDecl (const VarDecl &Var, const ASTContext &Context, DeclSpec::TQ Qualifier, QualifierTarget CT=QualifierTarget::Pointee, QualifierPolicy CP=QualifierPolicy::Left)
| Creates fix to qualify `VarDecl` with the specified `Qualifier`. More...
FixItHint | changeVarDeclToConst (const VarDecl &Var)
| Creates fix to make `VarDecl` const qualified. More...

## Enumeration Type Documentation

## ◆ QualifierPolicy

enum clang::tidy::utils::fixit::QualifierPolicy
| strong

This enum defines where the qualifier shall be preferably added.

Enumerator
Left |
Right |

Definition at line 28 of file FixItHintUtils.h.

## ◆ QualifierTarget

enum clang::tidy::utils::fixit::QualifierTarget
| strong

This enum defines which entity is the target for adding the qualifier.

This makes only a difference for pointer-types. Other types behave identical for either value of `ConstTarget`.

Enumerator
Pointee |
Value | Transforming a pointer attaches to the pointee and not the pointer itself. For references and normal values this option has no effect. `int * p =` -> `const int * p = &i` or `int const` p = &i.

Definition at line 36 of file FixItHintUtils.h.

## Function Documentation

## ◆ addQualifierToVarDecl()

Optional< FixItHint > clang::tidy::utils::fixit::addQualifierToVarDecl | ( | const VarDecl & | Var,
|  | const ASTContext & | Context,
|  | DeclSpec::TQ | Qualifier,
|  | QualifierTarget | CT = `QualifierTarget::Pointee`,
|  | QualifierPolicy | CP = `QualifierPolicy::Left`
| ) |  |

Creates fix to qualify `VarDecl` with the specified `Qualifier`.

Requires that `Var` is isolated in written code like in `int foo = 42;`.

Definition at line 184 of file FixItHintUtils.cpp.

## ◆ buildQualifier()

static std::string clang::tidy::utils::fixit::buildQualifier | ( | DeclSpec::TQ | Qualifier,
|  | bool | WhitespaceBefore = `false`
| ) |  |
| static

Definition at line 74 of file FixItHintUtils.cpp.

## ◆ changePointer()

static Optional<FixItHint> clang::tidy::utils::fixit::changePointer | ( | const VarDecl & | Var,
|  | DeclSpec::TQ | Qualifier,
|  | const Type * | Pointee,
|  | QualifierTarget | QualTarget,
|  | QualifierPolicy | QualPolicy,
|  | const ASTContext & | Context
| ) |  |
| static

Definition at line 115 of file FixItHintUtils.cpp.

## ◆ changePointerItself()

static Optional<FixItHint> clang::tidy::utils::fixit::changePointerItself | ( | const VarDecl & | Var,
|  | DeclSpec::TQ | Qualifier,
|  | const ASTContext & | Context
| ) |  |
| static

Definition at line 101 of file FixItHintUtils.cpp.

## ◆ changeReferencee()

static Optional<FixItHint> clang::tidy::utils::fixit::changeReferencee | ( | const VarDecl & | Var,
|  | DeclSpec::TQ | Qualifier,
|  | QualType | Pointee,
|  | QualifierTarget | QualTarget,
|  | QualifierPolicy | QualPolicy,
|  | const ASTContext & | Context
| ) |  |
| static

Definition at line 166 of file FixItHintUtils.cpp.

## ◆ changeValue()

static Optional<FixItHint> clang::tidy::utils::fixit::changeValue | ( | const VarDecl & | Var,
|  | DeclSpec::TQ | Qualifier,
|  | QualifierTarget | QualTarget,
|  | QualifierPolicy | QualPolicy,
|  | const ASTContext & | Context
| ) |  |
| static

Definition at line 81 of file FixItHintUtils.cpp.

## ◆ changeVarDeclToConst()

FixItHint clang::tidy::utils::fixit::changeVarDeclToConst | ( | const VarDecl & | Var | ) |

Creates fix to make `VarDecl` const qualified.

## ◆ changeVarDeclToReference()

FixItHint clang::tidy::utils::fixit::changeVarDeclToReference | ( | const VarDecl & | Var,
|  | ASTContext & | Context
| ) |  |

Creates fix to make `VarDecl` a reference by adding `&`.

Definition at line 19 of file FixItHintUtils.cpp.

## ◆ fixIfNotDangerous()

static Optional<FixItHint> clang::tidy::utils::fixit::fixIfNotDangerous | ( | SourceLocation | Loc,
|  | StringRef | Text
| ) |  |
| static

Definition at line 65 of file FixItHintUtils.cpp.

References locDangerous().

## ◆ isMemberOrFunctionPointer()

static bool clang::tidy::utils::fixit::isMemberOrFunctionPointer | ( | QualType | QT | ) |
| static

Definition at line 35 of file FixItHintUtils.cpp.

## ◆ isValueType() [1/2]

static bool clang::tidy::utils::fixit::isValueType | ( | const Type * | T | ) |
| static

Definition at line 30 of file FixItHintUtils.cpp.

Referenced by isValueType().

## ◆ isValueType() [2/2]

static bool clang::tidy::utils::fixit::isValueType | ( | QualType | QT | ) |
| static

Definition at line 34 of file FixItHintUtils.cpp.

References isValueType().

## ◆ locDangerous()

static bool clang::tidy::utils::fixit::locDangerous | ( | SourceLocation | S | ) |
| static

Definition at line 40 of file FixItHintUtils.cpp.

Referenced by fixIfNotDangerous().

## ◆ skipLParensBackwards()

static Optional<SourceLocation> clang::tidy::utils::fixit::skipLParensBackwards | ( | SourceLocation | Start,
|  | const ASTContext & | Context
| ) |  |
| static

Definition at line 45 of file FixItHintUtils.cpp.