clang 24.0.0git
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 ASTContext & getASTContext () const
StringRef getFilename () const
int getSize () const
NodeId getRootId () const
PreorderIterator begin () const
PreorderIterator end () const
const Node & getNode (NodeId Id) const
int findPositionInParent (NodeId Id) const
std::pair< unsigned, unsigned > getSourceRangeOffsets (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< Impl > TreeImpl

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)

◆ 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.

References clang::T, and TreeImpl.

◆ SyntaxTree() [3/3]

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

References clang::Other, and SyntaxTree().

◆ ~SyntaxTree()

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

Member Function Documentation

◆ begin()

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

Definition at line 985 of file ASTDiff.cpp.

References TreeImpl.

◆ end()

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

Definition at line 988 of file ASTDiff.cpp.

References TreeImpl.

◆ findPositionInParent()

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

Definition at line 990 of file ASTDiff.cpp.

References TreeImpl.

◆ getASTContext()

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

Definition at line 977 of file ASTDiff.cpp.

References TreeImpl.

◆ getFilename()

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

◆ getNode()

◆ getNodeValue() [1/2]

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

Definition at line 1014 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 1010 of file ASTDiff.cpp.

References TreeImpl.

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

◆ getRootId()

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

Definition at line 984 of file ASTDiff.cpp.

References TreeImpl.

◆ getSize()

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

Definition at line 983 of file ASTDiff.cpp.

References TreeImpl.

◆ getSourceRangeOffsets()

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

Member Data Documentation

◆ TreeImpl


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