51 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_ASTUTILS_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_ASTUTILS_H11 12#include "clang/AST/AST.h"13 14namespace clang::tidy::utils {15// Returns the (closest) Function declaration surrounding |Statement| or NULL.16const FunctionDecl *getSurroundingFunction(ASTContext &Context,17 const Stmt &Statement);18// Determine whether Expr is a Binary or Ternary expression.19bool isBinaryOrTernary(const Expr *E);20 21/// Checks whether a macro flag is present in the given argument. Only considers22/// cases of single match or match in a binary OR expression. For example,23/// <needed-flag> or <flag> | <needed-flag> | ...24bool 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.29bool rangeIsEntirelyWithinMacroArgument(SourceRange Range,30 const SourceManager *SM);31 32// Check if the range contains any locations from a macro expansion.33bool 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.37bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM);38 39// Check if statements are same40bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt,41 const ASTContext &Context, bool Canonical = false);42 43// Given a field of an anonymous record, find its corresponding44// IndirectFieldDecl in the outermost possible scope.45const IndirectFieldDecl *46findOutermostIndirectFieldDeclForField(const FieldDecl *FD);47 48} // namespace clang::tidy::utils49 50#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_ASTUTILS_H51