clang-tools
17.0.0git
llvm-project
clang-tools-extra
clang-tidy
utils
ASTUtils.h
Go to the documentation of this file.
1
//===---------- ASTUtils.h - clang-tidy -----------------------------------===//
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_ASTUTILS_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
11
12
#include "clang/AST/AST.h"
13
14
namespace
clang::tidy::utils
{
15
// Returns the (closest) Function declaration surrounding |Statement| or NULL.
16
const
FunctionDecl *
getSurroundingFunction
(ASTContext &Context,
17
const
Stmt &Statement);
18
// Determine whether Expr is a Binary or Ternary expression.
19
bool
isBinaryOrTernary
(
const
Expr *
E
);
20
21
/// Checks whether a macro flag is present in the given argument. Only considers
22
/// cases of single match or match in a binary OR expression. For example,
23
/// <needed-flag> or <flag> | <needed-flag> | ...
24
bool
exprHasBitFlagWithSpelling
(
const
Expr *
Flags
,
const
SourceManager &SM,
25
const
LangOptions &
LangOpts
,
26
StringRef FlagName);
27
28
// Check if the range is entirely contained within a macro argument.
29
bool
rangeIsEntirelyWithinMacroArgument
(SourceRange
Range
,
30
const
SourceManager *SM);
31
32
// Check if the range contains any locations from a macro expansion.
33
bool
rangeContainsMacroExpansion
(SourceRange
Range
,
const
SourceManager *SM);
34
35
// Can a fix-it be issued for this whole Range?
36
// FIXME: false-negative if the entire range is fully expanded from a macro.
37
bool
rangeCanBeFixed
(SourceRange
Range
,
const
SourceManager *SM);
38
39
}
// namespace clang::tidy::utils
40
41
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
Range
CharSourceRange Range
SourceRange for the file name.
Definition:
IncludeOrderCheck.cpp:37
Flags
MixFlags Flags
Definition:
EasilySwappableParametersCheck.cpp:1096
E
const Expr * E
Definition:
AvoidBindCheck.cpp:86
clang::tidy::utils::getSurroundingFunction
const FunctionDecl * getSurroundingFunction(ASTContext &Context, const Stmt &Statement)
Definition:
ASTUtils.cpp:18
clang::tidy::utils::isBinaryOrTernary
bool isBinaryOrTernary(const Expr *E)
Definition:
ASTUtils.cpp:25
clang::tidy::utils::exprHasBitFlagWithSpelling
bool exprHasBitFlagWithSpelling(const Expr *Flags, const SourceManager &SM, const LangOptions &LangOpts, StringRef FlagName)
Checks whether a macro flag is present in the given argument.
Definition:
ASTUtils.cpp:38
clang::tidy::utils
Definition:
Aliasing.cpp:14
clang::tidy::utils::rangeCanBeFixed
bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM)
Definition:
ASTUtils.cpp:86
LangOpts
const LangOptions * LangOpts
Definition:
ExtractFunction.cpp:374
clang::tidy::utils::rangeIsEntirelyWithinMacroArgument
bool rangeIsEntirelyWithinMacroArgument(SourceRange Range, const SourceManager *SM)
Definition:
ASTUtils.cpp:65
clang::tidy::utils::rangeContainsMacroExpansion
bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM)
Definition:
ASTUtils.cpp:81
Generated on Fri Jan 27 2023 11:32:09 for clang-tools by
1.8.17