clang 20.0.0git
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
clang::diff::SyntaxTree Class Reference

SyntaxTree objects represent subtrees of the AST. More...

#include "clang/Tooling/ASTDiff/ASTDiff.h"

Classes

class  Impl
 Represents the AST of a TranslationUnit. More...
 

Public Types

using PreorderIterator = NodeId
 

Public Member Functions

 SyntaxTree (ASTContext &AST)
 Constructs a tree from a translation unit.
 
template<class T >
 SyntaxTree (T *Node, ASTContext &AST)
 Constructs a tree from any AST node.
 
 SyntaxTree (SyntaxTree &&Other)=default
 
 ~SyntaxTree ()
 
const ASTContextgetASTContext () const
 
StringRef getFilename () const
 
int getSize () const
 
NodeId getRootId () const
 
PreorderIterator begin () const
 
PreorderIterator end () const
 
const NodegetNode (NodeId Id) const
 
int findPositionInParent (NodeId Id) const
 
std::pair< unsigned, unsignedgetSourceRangeOffsets (const Node &N) const
 
std::string getNodeValue (NodeId Id) const
 Serialize the node attributes to a string representation.
 
std::string getNodeValue (const Node &Node) const
 

Public Attributes

std::unique_ptr< ImplTreeImpl
 

Detailed Description

SyntaxTree objects represent subtrees of the AST.

They can be constructed from any Decl or Stmt.

Definition at line 54 of file ASTDiff.h.

Member Typedef Documentation

◆ PreorderIterator

Definition at line 70 of file ASTDiff.h.

Constructor & Destructor Documentation

◆ SyntaxTree() [1/3]

clang::diff::SyntaxTree::SyntaxTree ( ASTContext AST)

Constructs a tree from a translation unit.

Definition at line 969 of file ASTDiff.cpp.

◆ SyntaxTree() [2/3]

template<class T >
clang::diff::SyntaxTree::SyntaxTree ( T Node,
ASTContext AST 
)
inline

Constructs a tree from any AST node.

Definition at line 60 of file ASTDiff.h.

◆ SyntaxTree() [3/3]

clang::diff::SyntaxTree::SyntaxTree ( SyntaxTree &&  Other)
default

◆ ~SyntaxTree()

clang::diff::SyntaxTree::~SyntaxTree ( )
default

Member Function Documentation

◆ begin()

SyntaxTree::PreorderIterator clang::diff::SyntaxTree::begin ( ) const

Definition at line 983 of file ASTDiff.cpp.

References TreeImpl.

◆ end()

SyntaxTree::PreorderIterator clang::diff::SyntaxTree::end ( ) const

Definition at line 986 of file ASTDiff.cpp.

References TreeImpl.

◆ findPositionInParent()

int clang::diff::SyntaxTree::findPositionInParent ( NodeId  Id) const

Definition at line 988 of file ASTDiff.cpp.

References Id, and TreeImpl.

◆ getASTContext()

const ASTContext & clang::diff::SyntaxTree::getASTContext ( ) const

Definition at line 975 of file ASTDiff.cpp.

References TreeImpl.

◆ getFilename()

StringRef clang::diff::SyntaxTree::getFilename ( ) const

◆ getNode()

const Node & clang::diff::SyntaxTree::getNode ( NodeId  Id) const

◆ getNodeValue() [1/2]

std::string clang::diff::SyntaxTree::getNodeValue ( const Node Node) const

Definition at line 1012 of file ASTDiff.cpp.

References TreeImpl.

◆ getNodeValue() [2/2]

std::string clang::diff::SyntaxTree::getNodeValue ( NodeId  Id) const

Serialize the node attributes to a string representation.

This should uniquely distinguish nodes of the same kind. Note that this function just returns a representation of the node value, not considering descendants.

Definition at line 1008 of file ASTDiff.cpp.

References Id, and TreeImpl.

Referenced by clang::diff::SyntaxTree::Impl::getNodeValue().

◆ getRootId()

NodeId clang::diff::SyntaxTree::getRootId ( ) const

Definition at line 982 of file ASTDiff.cpp.

References TreeImpl.

◆ getSize()

int clang::diff::SyntaxTree::getSize ( ) const

Definition at line 981 of file ASTDiff.cpp.

References TreeImpl.

◆ getSourceRangeOffsets()

std::pair< unsigned, unsigned > clang::diff::SyntaxTree::getSourceRangeOffsets ( const Node N) const

Member Data Documentation

◆ TreeImpl

std::unique_ptr<Impl> clang::diff::SyntaxTree::TreeImpl

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