clang: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_AST_LEXICALLYORDEREDRECURSIVEASTVISITOR_H

15#define LLVM_CLANG_AST_LEXICALLYORDEREDRECURSIVEASTVISITOR_H

16

20#include "llvm/Support/SaveAndRestore.h"

21

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58template

62

63public:

65

67

68

69

70 bool Result = BaseType::TraverseObjCImplementationDecl(D);

71 return TraverseAdditionalLexicallyNestedDeclarations() ? Result : false;

72 }

73

75 bool Result = BaseType::TraverseObjCCategoryImplDecl(D);

76 return TraverseAdditionalLexicallyNestedDeclarations() ? Result : false;

77 }

78

80 if (!DC)

81 return true;

82

84 Decl *Child = *I;

86 ++I;

87 continue;

88 }

89 if (!isa(Child) &&

90 !isa(Child)) {

92 return false;

93 ++I;

94 continue;

95 }

96

97

98 LexicallyNestedDeclarations.clear();

99 for (++I; I != E; ++I) {

100 Decl *Sibling = *I;

102 Child->getEndLoc()))

103 break;

105 LexicallyNestedDeclarations.push_back(Sibling);

106 }

108 return false;

109 }

110 return true;

111 }

112

114

117 bool Swap;

118

119

121 case OO_Arrow:

122 case OO_Call:

123 case OO_Subscript:

124 Swap = true;

125 break;

126 case OO_PlusPlus:

127 case OO_MinusMinus:

128

129 Swap = Children.size() != 2;

130 break;

131 default:

133 break;

134 }

135 if (Swap && Children.size() > 1)

136 std::swap(Children[0], Children[1]);

137 return Children;

138 }

139

140private:

141 bool TraverseAdditionalLexicallyNestedDeclarations() {

142

143

144

145

146

148 "post-order traversal is not supported for lexically ordered "

149 "recursive ast visitor");

150 for (Decl *D : LexicallyNestedDeclarations) {

152 return false;

153 }

154 return true;

155 }

156

157 const SourceManager &SM;

159};

160

161}

162

163#endif

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the SourceManager interface.

A call to an overloaded operator written using operator syntax.

bool isInfixBinaryOp() const

Is this written as an infix binary operator?

OverloadedOperatorKind getOperator() const

Returns the kind of overloaded operator that this expression refers to.

DeclContext - This is used only as base class of specific decl types that can act as declaration cont...

decl_iterator decls_end() const

decl_iterator decls_begin() const

Decl - This represents one declaration (or definition), e.g.

SourceLocation getBeginLoc() const LLVM_READONLY

A RecursiveASTVisitor subclass that guarantees that AST traversal is performed in a lexical order (i....

bool TraverseObjCImplementationDecl(ObjCImplementationDecl *D)

LexicallyOrderedRecursiveASTVisitor(const SourceManager &SM)

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

bool TraverseDeclContextHelper(DeclContext *DC)

bool TraverseObjCCategoryImplDecl(ObjCCategoryImplDecl *D)

Stmt::child_range getStmtChildren(Stmt *S)

ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.

ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...

A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...

bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child)

bool TraverseDecl(Decl *D)

Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...

bool shouldTraversePostOrder() const

Return whether this visitor should traverse post-order.

Derived & getDerived()

Return a reference to the derived class.

This class handles loading and caching of source files into memory.

bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const

Determines the order of 2 source locations in the translation unit.

Stmt - This represents one statement.

llvm::iterator_range< child_iterator > child_range

The JSON file list parser is used to communicate input to InstallAPI.

@ Result

The result type of a method or function.