Debian Codegraph @

llvm-project/clang-tools-extra/clang-tidy/utils/ASTUtils.h

raw
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