clang-tools
15.0.0git
llvm-project
clang-tools-extra
clang-tidy
utils
FixItHintUtils.h
Go to the documentation of this file.
1
//===--- FixItHintUtils.h - clang-tidy---------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
11
12
#include "clang/AST/ASTContext.h"
13
#include "clang/AST/Decl.h"
14
#include "clang/Sema/DeclSpec.h"
15
16
namespace
clang
{
17
namespace
tidy {
18
namespace
utils {
19
namespace
fixit {
20
21
/// Creates fix to make ``VarDecl`` a reference by adding ``&``.
22
FixItHint
changeVarDeclToReference
(
const
VarDecl &Var, ASTContext &Context);
23
24
/// This enum defines where the qualifier shall be preferably added.
25
enum class
QualifierPolicy
{
26
Left
,
// Add the qualifier always to the left side, if that is possible.
27
Right
,
// Add the qualifier always to the right side.
28
};
29
30
/// This enum defines which entity is the target for adding the qualifier. This
31
/// makes only a difference for pointer-types. Other types behave identical
32
/// for either value of \c ConstTarget.
33
enum class
QualifierTarget
{
34
Pointee
,
/// Transforming a pointer attaches to the pointee and not the
35
/// pointer itself. For references and normal values this option has
36
/// no effect. `int * p = &i;` -> `const int * p = &i` or `int const
37
/// * p = &i`.
38
Value
,
/// Transforming pointers will consider the pointer itself.
39
/// `int * p = &i;` -> `int * const = &i`
40
};
41
42
/// \brief Creates fix to qualify ``VarDecl`` with the specified \c Qualifier.
43
/// Requires that `Var` is isolated in written code like in `int foo = 42;`.
44
Optional<FixItHint>
45
addQualifierToVarDecl
(
const
VarDecl &Var,
const
ASTContext &Context,
46
DeclSpec::TQ Qualifier,
47
QualifierTarget
CT =
QualifierTarget::Pointee
,
48
QualifierPolicy
CP =
QualifierPolicy::Left
);
49
}
// namespace fixit
50
}
// namespace utils
51
}
// namespace tidy
52
}
// namespace clang
53
54
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
clang::tidy::utils::fixit::QualifierTarget
QualifierTarget
This enum defines which entity is the target for adding the qualifier.
Definition:
FixItHintUtils.h:33
clang::tidy::utils::fixit::addQualifierToVarDecl
Optional< FixItHint > addQualifierToVarDecl(const VarDecl &Var, const ASTContext &Context, DeclSpec::TQ Qualifier, QualifierTarget QualTarget, QualifierPolicy QualPolicy)
Creates fix to qualify VarDecl with the specified Qualifier.
Definition:
FixItHintUtils.cpp:184
clang::tidy::utils::fixit::QualifierPolicy::Right
@ Right
clang::tidy::utils::fixit::QualifierTarget::Pointee
@ Pointee
clang::tidy::utils::fixit::changeVarDeclToReference
FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context)
Creates fix to make VarDecl a reference by adding &.
Definition:
FixItHintUtils.cpp:19
clang::tidy::utils::fixit::QualifierPolicy::Left
@ Left
clang::tidy::utils::fixit::QualifierTarget::Value
@ Value
Transforming a pointer attaches to the pointee and not the pointer itself.
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
clang::tidy::utils::fixit::QualifierPolicy
QualifierPolicy
This enum defines where the qualifier shall be preferably added.
Definition:
FixItHintUtils.h:25
Generated on Mon Jul 4 2022 06:42:39 for clang-tools by
1.8.17