clang-tools 8.0.0

ASTUtils.h
Go to the documentation of this file.
1 //===---------- ASTUtils.h - clang-tidy -----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
12
13 #include "clang/AST/AST.h"
14
15 namespace clang {
16 namespace tidy {
17 namespace utils {
18 // Returns the (closest) Function declaration surrounding |Statement| or NULL.
19 const FunctionDecl *getSurroundingFunction(ASTContext &Context,
20 const Stmt &Statement);
21 // Determine whether Expr is a Binary or Ternary expression.
22 bool IsBinaryOrTernary(const Expr *E);
23
24 /// Checks whether a macro flag is present in the given argument. Only considers
25 /// cases of single match or match in a binary OR expression. For example,
26 /// <needed-flag> or <flag> | <needed-flag> | ...
27 bool exprHasBitFlagWithSpelling(const Expr *Flags, const SourceManager &SM,
28 const LangOptions &LangOpts,
29 StringRef FlagName);
30
31 // Check if the range is entirely contained within a macro argument.
32 bool rangeIsEntirelyWithinMacroArgument(SourceRange Range,
33 const SourceManager *SM);
34
35 // Check if the range contains any locations from a macro expansion.
36 bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM);
37
38 // Can a fix-it be issued for this whole Range?
39 // FIXME: false-negative if the entire range is fully expanded from a macro.
40 bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM);
41
42 } // namespace utils
43 } // namespace tidy
44 } // namespace clang
45
46 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
clang::tidy::utils::IsBinaryOrTernary
bool IsBinaryOrTernary(const Expr *E)
Definition: ASTUtils.cpp:28
clang::tidy::utils::rangeIsEntirelyWithinMacroArgument
bool rangeIsEntirelyWithinMacroArgument(SourceRange Range, const SourceManager *SM)
Definition: ASTUtils.cpp:70
clang::tidy::utils::rangeContainsMacroExpansion
bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM)
Definition: ASTUtils.cpp:86
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:43
clang::tidy::utils::getSurroundingFunction
const FunctionDecl * getSurroundingFunction(ASTContext &Context, const Stmt &Statement)
Definition: ASTUtils.cpp:21
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
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:91