clang  6.0.0svn
Public Types | Public Member Functions | List of all members
clang::StmtSequence Class Reference

Identifies a list of statements. More...

#include "clang/Analysis/CloneDetection.h"

Public Types

typedef const Stmt *const * iterator
 

Public Member Functions

 StmtSequence (const CompoundStmt *Stmt, const Decl *D, unsigned StartIndex, unsigned EndIndex)
 Constructs a StmtSequence holding multiple statements. More...
 
 StmtSequence (const Stmt *Stmt, const Decl *D)
 Constructs a StmtSequence holding a single statement. More...
 
 StmtSequence ()
 Constructs an empty StmtSequence. More...
 
iterator begin () const
 Returns an iterator pointing to the first statement in this sequence. More...
 
iterator end () const
 Returns an iterator pointing behind the last statement in this sequence. More...
 
const Stmtfront () const
 Returns the first statement in this sequence. More...
 
const Stmtback () const
 Returns the last statement in this sequence. More...
 
unsigned size () const
 Returns the number of statements this object holds. More...
 
bool empty () const
 Returns true if and only if this StmtSequence contains no statements. More...
 
ASTContextgetASTContext () const
 Returns the related ASTContext for the stored Stmts. More...
 
const DeclgetContainingDecl () const
 Returns the declaration that contains the stored Stmts. More...
 
bool holdsSequence () const
 Returns true if this objects holds a list of statements. More...
 
SourceLocation getStartLoc () const
 Returns the start sourcelocation of the first statement in this sequence. More...
 
SourceLocation getEndLoc () const
 Returns the end sourcelocation of the last statement in this sequence. More...
 
SourceRange getSourceRange () const
 Returns the source range of the whole sequence - from the beginning of the first statement to the end of the last statement. More...
 
bool operator== (const StmtSequence &Other) const
 
bool operator!= (const StmtSequence &Other) const
 
bool contains (const StmtSequence &Other) const
 Returns true if and only if this sequence covers a source range that contains the source range of the given sequence Other. More...
 

Detailed Description

Identifies a list of statements.

Can either identify a single arbitrary Stmt object, a continuous sequence of child statements inside a CompoundStmt or no statements at all.

Definition at line 34 of file CloneDetection.h.

Member Typedef Documentation

◆ iterator

typedef const Stmt* const* clang::StmtSequence::iterator

Definition at line 74 of file CloneDetection.h.

Constructor & Destructor Documentation

◆ StmtSequence() [1/3]

StmtSequence::StmtSequence ( const CompoundStmt Stmt,
const Decl D,
unsigned  StartIndex,
unsigned  EndIndex 
)

Constructs a StmtSequence holding multiple statements.

The resulting StmtSequence identifies a continuous sequence of statements in the body of the given CompoundStmt. Which statements of the body should be identified needs to be specified by providing a start and end index that describe a non-empty sub-array in the body of the given CompoundStmt.

Parameters
StmtA CompoundStmt that contains all statements in its body.
DThe Decl containing this Stmt.
StartIndexThe inclusive start index in the children array of Stmt
EndIndexThe exclusive end index in the children array of Stmt.

Definition at line 23 of file CloneDetection.cpp.

◆ StmtSequence() [2/3]

StmtSequence::StmtSequence ( const Stmt Stmt,
const Decl D 
)

Constructs a StmtSequence holding a single statement.

Parameters
StmtAn arbitrary Stmt.
DThe Decl containing this Stmt.

Definition at line 31 of file CloneDetection.cpp.

◆ StmtSequence() [3/3]

StmtSequence::StmtSequence ( )

Constructs an empty StmtSequence.

Definition at line 34 of file CloneDetection.cpp.

Referenced by clang::CloneDetector::analyzeCodeBody(), and CollectStmtSequenceData().

Member Function Documentation

◆ back()

const Stmt* clang::StmtSequence::back ( ) const
inline

Returns the last statement in this sequence.

This method should only be called on a non-empty StmtSequence object.

Definition at line 93 of file CloneDetection.h.

References begin(), empty(), and size().

Referenced by getEndLoc().

◆ begin()

StmtSequence::iterator StmtSequence::begin ( ) const

Returns an iterator pointing to the first statement in this sequence.

Definition at line 59 of file CloneDetection.cpp.

References holdsSequence().

Referenced by back(), and front().

◆ contains()

bool StmtSequence::contains ( const StmtSequence Other) const

Returns true if and only if this sequence covers a source range that contains the source range of the given sequence Other.

This method should only be called on a non-empty StmtSequence object and passed a non-empty StmtSequence object.

Definition at line 37 of file CloneDetection.cpp.

References getASTContext(), getEndLoc(), clang::ASTContext::getSourceManager(), getStartLoc(), clang::SourceManager::isBeforeInTranslationUnit(), and SM.

Referenced by containsAnyInGroup(), and operator!=().

◆ empty()

bool clang::StmtSequence::empty ( ) const
inline

Returns true if and only if this StmtSequence contains no statements.

Definition at line 108 of file CloneDetection.h.

References getASTContext(), and size().

Referenced by back(), clang::MinComplexityConstraint::calculateStmtComplexity(), and front().

◆ end()

StmtSequence::iterator StmtSequence::end ( ) const

Returns an iterator pointing behind the last statement in this sequence.

Definition at line 67 of file CloneDetection.cpp.

References holdsSequence().

◆ front()

const Stmt* clang::StmtSequence::front ( ) const
inline

Returns the first statement in this sequence.

This method should only be called on a non-empty StmtSequence object.

Definition at line 85 of file CloneDetection.h.

References begin(), and empty().

Referenced by getStartLoc().

◆ getASTContext()

ASTContext & StmtSequence::getASTContext ( ) const

Returns the related ASTContext for the stored Stmts.

Definition at line 75 of file CloneDetection.cpp.

References clang::Decl::getASTContext().

Referenced by contains(), and empty().

◆ getContainingDecl()

const Decl* clang::StmtSequence::getContainingDecl ( ) const
inline

Returns the declaration that contains the stored Stmts.

Definition at line 114 of file CloneDetection.h.

◆ getEndLoc()

SourceLocation StmtSequence::getEndLoc ( ) const

Returns the end sourcelocation of the last statement in this sequence.

This method should only be called on a non-empty StmtSequence object.

Definition at line 84 of file CloneDetection.cpp.

References back(), and clang::Stmt::getLocEnd().

Referenced by contains(), getSourceRange(), and holdsSequence().

◆ getSourceRange()

SourceRange StmtSequence::getSourceRange ( ) const

Returns the source range of the whole sequence - from the beginning of the first statement to the end of the last statement.

Definition at line 86 of file CloneDetection.cpp.

References getEndLoc(), and getStartLoc().

Referenced by holdsSequence().

◆ getStartLoc()

SourceLocation StmtSequence::getStartLoc ( ) const

Returns the start sourcelocation of the first statement in this sequence.

This method should only be called on a non-empty StmtSequence object.

Definition at line 80 of file CloneDetection.cpp.

References front(), and clang::Stmt::getLocStart().

Referenced by contains(), getSourceRange(), and holdsSequence().

◆ holdsSequence()

bool clang::StmtSequence::holdsSequence ( ) const
inline

Returns true if this objects holds a list of statements.

Definition at line 120 of file CloneDetection.h.

References getEndLoc(), getSourceRange(), and getStartLoc().

Referenced by begin(), end(), and size().

◆ operator!=()

bool clang::StmtSequence::operator!= ( const StmtSequence Other) const
inline

Definition at line 141 of file CloneDetection.h.

References contains().

◆ operator==()

bool clang::StmtSequence::operator== ( const StmtSequence Other) const
inline

Definition at line 136 of file CloneDetection.h.

◆ size()

unsigned clang::StmtSequence::size ( ) const
inline

Returns the number of statements this object holds.

Definition at line 99 of file CloneDetection.h.

References holdsSequence().

Referenced by back(), and empty().


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