clang-tools 10.0.0

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 {
15 namespace tidy {
16 namespace utils {
17 // Returns the (closest) Function declaration surrounding |Statement| or NULL.
18 const FunctionDecl *getSurroundingFunction(ASTContext &Context,
19 const Stmt &Statement);
20 // Determine whether Expr is a Binary or Ternary expression.
21 bool IsBinaryOrTernary(const Expr *E);
22
23 /// Checks whether a macro flag is present in the given argument. Only considers
24 /// cases of single match or match in a binary OR expression. For example,
25 /// <needed-flag> or <flag> | <needed-flag> | ...
26 bool exprHasBitFlagWithSpelling(const Expr *Flags, const SourceManager &SM,
27 const LangOptions &LangOpts,
28 StringRef FlagName);
29
30 // Check if the range is entirely contained within a macro argument.
31 bool rangeIsEntirelyWithinMacroArgument(SourceRange Range,
32 const SourceManager *SM);
33
34 // Check if the range contains any locations from a macro expansion.
35 bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM);
36
37 // Can a fix-it be issued for this whole Range?
38 // FIXME: false-negative if the entire range is fully expanded from a macro.
39 bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM);
40
41 } // namespace utils
42 } // namespace tidy
43 } // namespace clang
44
45 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
clang::tidy::utils::IsBinaryOrTernary
bool IsBinaryOrTernary(const Expr *E)
Definition: ASTUtils.cpp:27
clang::tidy::utils::rangeIsEntirelyWithinMacroArgument
bool rangeIsEntirelyWithinMacroArgument(SourceRange Range, const SourceManager *SM)
Definition: ASTUtils.cpp:69
Flags
std::vector< const char * > Flags
Definition: FindTargetTests.cpp:68
clang::tidy::utils::rangeContainsMacroExpansion
bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM)
Definition: ASTUtils.cpp:85
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:42
clang::tidy::utils::getSurroundingFunction
const FunctionDecl * getSurroundingFunction(ASTContext &Context, const Stmt &Statement)
Definition: ASTUtils.cpp:20
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
Range
CharSourceRange Range
SourceRange for the file name.
Definition: IncludeOrderCheck.cpp:38
clang::tidy::utils::rangeCanBeFixed
bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM)
Definition: ASTUtils.cpp:90
E
const Expr * E
Definition: AvoidBindCheck.cpp:82