class LexicallyOrderedRecursiveASTVisitor

Declaration

template <typename Derived>
class LexicallyOrderedRecursiveASTVisitor { /* full declaration omitted */ };

Description

A RecursiveASTVisitor subclass that guarantees that AST traversal is performed in a lexical order (i.e. the order in which declarations are written in the source). RecursiveASTVisitor doesn't guarantee lexical ordering because there are some declarations, like Objective-C @implementationdeclarations that might be represented in the AST differently to how they were written in the source. In particular, Objective-C @implementationdeclarations may contain non-Objective-C declarations, like functions: @implementationMyClass - (void) method { } void normalFunction() { } @end Clang's AST stores these declarations outside of the @implementationdeclaration, so the example above would be represented using the following AST: |-ObjCImplementationDecl ... MyClass | `-ObjCMethodDecl ... method | ... `-FunctionDecl ... normalFunction ... This class ensures that these declarations are traversed before the corresponding TraverseDecl for the @implementationreturns. This ensures that the lexical parent relationship between these declarations and the@implementationis preserved while traversing the AST. Note that the current implementation doesn't mix these declarations with the declarations contained in the @implementation, so the traversal of all of the declarations in the @implementationstill doesn't follow the lexical order.

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:59

Templates

Derived

Member Variables

private const clang::SourceManager& SM
private llvm::SmallVector<Decl*, 8> LexicallyNestedDeclarations

Method Overview

Methods

LexicallyOrderedRecursiveASTVisitor<Derived>(
    const clang::SourceManager& SM)

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:64

Parameters

const clang::SourceManager& SM

bool TraverseAdditionalLexicallyNestedDeclarations()

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:141

bool TraverseDeclContextHelper(
    clang::DeclContext* DC)

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:79

Parameters

clang::DeclContext* DC

bool TraverseObjCCategoryImplDecl(
    clang::ObjCCategoryImplDecl* D)

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:74

Parameters

clang::ObjCCategoryImplDecl* D

bool TraverseObjCImplementationDecl(
    clang::ObjCImplementationDecl* D)

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:66

Parameters

clang::ObjCImplementationDecl* D

Stmt::child_range getStmtChildren(clang::Stmt* S)

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:113

Parameters

clang::Stmt* S

SmallVector<clang::Stmt*, 8> getStmtChildren(
    clang::CXXOperatorCallExpr* CE)

Declared at: clang/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:115

Parameters

clang::CXXOperatorCallExpr* CE