[AMDGPU][AsmParser][NFC] Translate parsed MIMG instructions to MCInsts automatically.
[llvm-project.git] / clang-tools-extra / clang-tidy / utils / ASTUtils.h
blob1bba5daf2fc765ab3d6ffbe5d0e01ef361df46af
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
12 #include "clang/AST/AST.h"
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);
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);
28 // Check if the range is entirely contained within a macro argument.
29 bool rangeIsEntirelyWithinMacroArgument(SourceRange Range,
30 const SourceManager *SM);
32 // Check if the range contains any locations from a macro expansion.
33 bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM);
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);
39 // Check if statements are same
40 bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt,
41 const ASTContext &Context, bool Canonical = false);
43 } // namespace clang::tidy::utils
45 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H