clang  6.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
clang::tooling::CodeRangeASTSelection Class Reference

An AST selection value that corresponds to a selection of a set of statements that belong to one body of code (like one function). More...

#include "clang/Tooling/Refactoring/ASTSelection.h"

Public Member Functions

 CodeRangeASTSelection (CodeRangeASTSelection &&)=default
 
CodeRangeASTSelectionoperator= (CodeRangeASTSelection &&)=default
 
ArrayRef< SelectedASTNode::ReferenceTypegetParents ()
 Returns the parent hierarchy (top to bottom) for the selected nodes. More...
 
size_t size () const
 Returns the number of selected statements. More...
 
const Stmtoperator[] (size_t I) const
 
bool isInFunctionLikeBodyOfCode () const
 Returns true when a selected code range is in a function-like body of code, like a function, method or a block. More...
 
const DeclgetFunctionLikeNearestParent () const
 Returns the nearest function-like parent declaration or null if such declaration doesn't exist. More...
 

Static Public Member Functions

static Optional< CodeRangeASTSelectioncreate (SourceRange SelectionRange, const SelectedASTNode &ASTSelection)
 

Detailed Description

An AST selection value that corresponds to a selection of a set of statements that belong to one body of code (like one function).

For example, the following selection in the source.

void function() {
// selection begin:
int x = 0;
{
// selection end
x = 1;
}
x = 2;
}

Would correspond to a code range selection of statements "int x = 0" and the entire compound statement that follows it.

A CodeRangeASTSelection value stores references to the full SelectedASTNode tree and should not outlive it.

Definition at line 95 of file ASTSelection.h.

Constructor & Destructor Documentation

◆ CodeRangeASTSelection()

clang::tooling::CodeRangeASTSelection::CodeRangeASTSelection ( CodeRangeASTSelection &&  )
default

Member Function Documentation

◆ create()

Optional< CodeRangeASTSelection > CodeRangeASTSelection::create ( SourceRange  SelectionRange,
const SelectedASTNode ASTSelection 
)
static

◆ getFunctionLikeNearestParent()

const Decl * CodeRangeASTSelection::getFunctionLikeNearestParent ( ) const

Returns the nearest function-like parent declaration or null if such declaration doesn't exist.

Definition at line 444 of file ASTSelection.cpp.

References clang::ast_type_traits::DynTypedNode::get(), isFunctionLikeDeclaration(), and Parent.

◆ getParents()

ArrayRef<SelectedASTNode::ReferenceType> clang::tooling::CodeRangeASTSelection::getParents ( )
inline

Returns the parent hierarchy (top to bottom) for the selected nodes.

Definition at line 101 of file ASTSelection.h.

◆ isInFunctionLikeBodyOfCode()

bool CodeRangeASTSelection::isInFunctionLikeBodyOfCode ( ) const

Returns true when a selected code range is in a function-like body of code, like a function, method or a block.

This function can be used to test against selected expressions that are located outside of a function, e.g. global variable initializers, default argument values, or even template arguments.

Use the getFunctionLikeNearestParent to get the function-like parent declaration.

Definition at line 422 of file ASTSelection.cpp.

References clang::ast_type_traits::DynTypedNode::get(), isFunctionLikeDeclaration(), and Parent.

◆ operator=()

CodeRangeASTSelection& clang::tooling::CodeRangeASTSelection::operator= ( CodeRangeASTSelection &&  )
default

◆ operator[]()

const Stmt* clang::tooling::CodeRangeASTSelection::operator[] ( size_t  I) const
inline

Definition at line 110 of file ASTSelection.h.

◆ size()

size_t clang::tooling::CodeRangeASTSelection::size ( ) const
inline

Returns the number of selected statements.

Definition at line 104 of file ASTSelection.h.


The documentation for this class was generated from the following files: