clang: include/clang/Sema/IdentifierResolver.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_SEMA_IDENTIFIERRESOLVER_H

15#define LLVM_CLANG_SEMA_IDENTIFIERRESOLVER_H

16

18#include "llvm/ADT/SmallVector.h"

19#include

20#include

21#include

22#include

23

25

27class DeclarationName;

28class DeclContext;

29class IdentifierInfo;

30class LangOptions;

31class NamedDecl;

32class Preprocessor;

33class Scope;

34

35

36

37

39

40

41

42

43 class IdDeclInfo {

44 public:

46

47 DeclsTy::iterator decls_begin() { return Decls.begin(); }

48 DeclsTy::iterator decls_end() { return Decls.end(); }

49

50 void AddDecl(NamedDecl *D) { Decls.push_back(D); }

51

52

53

55

56

57 void InsertDecl(DeclsTy::iterator Pos, NamedDecl *D) {

58 Decls.insert(Pos, D);

59 }

60

61 private:

62 DeclsTy Decls;

63 };

64

65public:

66

67

68

70 public:

72

78

79

80

81

82

84 using BaseIter = IdDeclInfo::DeclsTy::iterator;

85

86

89 assert((Ptr & 0x1) == 0 && "Invalid Ptr!");

90 }

91

92

93

96 }

97

99

101 assert(isIterator() && "Ptr not an iterator!");

102 return reinterpret_cast<BaseIter>(Ptr & ~0x1);

103 }

104

106

107 public:

109

113 else

115 }

116

118 return Ptr == RHS.Ptr;

119 }

121 return Ptr != RHS.Ptr;

122 }

123

124

128 else

130 return *this;

131 }

132 };

133

136

139

140

142

143

145

146

148

149

150

151

152

153

154

155

156

157

158

160 bool AllowInlineNamespace = false) const;

161

162

164

165

166

168

169

170

172

173

174

175

176

177

178

179

180

182

183private:

186

187 class IdDeclInfoMap;

188 IdDeclInfoMap *IdDeclInfos;

189

192

193

194 static inline bool isDeclPtr(void *Ptr) {

195 return (reinterpret_cast<uintptr_t>(Ptr) & 0x1) == 0;

196 }

197

198

199 static inline IdDeclInfo *toIdDeclInfo(void *Ptr) {

200 assert((reinterpret_cast<uintptr_t>(Ptr) & 0x1) == 1

201 && "Ptr not a IdDeclInfo* !");

202 return reinterpret_cast<IdDeclInfo*>(

203 reinterpret_cast<uintptr_t>(Ptr) & ~0x1);

204 }

205};

206

207}

208

209#endif

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

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

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

The name of a declaration.

One of these records is kept for each identifier that is lexed.

iterator - Iterate over the decls of a specified declaration name.

bool operator==(const iterator &RHS) const

std::ptrdiff_t difference_type

IdDeclInfo::DeclsTy::iterator BaseIter

uintptr_t Ptr

Ptr - There are 2 forms that 'Ptr' represents: 1) A single NamedDecl.

iterator(BaseIter I)

A IdDeclInfo::DeclsTy::iterator that walks or not the parent declaration contexts depending on 'LookI...

iterator(NamedDecl *D)

A single NamedDecl. (Ptr & 0x1 == 0)

NamedDecl * operator*() const

std::input_iterator_tag iterator_category

bool operator!=(const iterator &RHS) const

BaseIter getIterator() const

IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.

iterator begin(DeclarationName Name)

Returns an iterator over decls with the name 'Name'.

void RemoveDecl(NamedDecl *D)

RemoveDecl - Unlink the decl from its shadowed decl chain.

IdentifierResolver & operator=(const IdentifierResolver &)=delete

IdentifierResolver(const IdentifierResolver &)=delete

void InsertDeclAfter(iterator Pos, NamedDecl *D)

Insert the given declaration after the given iterator position.

bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)

Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...

iterator end()

Returns the end iterator.

void AddDecl(NamedDecl *D)

AddDecl - Link the decl to its shadowed decl chain.

llvm::iterator_range< iterator > decls(DeclarationName Name)

Returns a range of decls with the name 'Name'.

bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const

isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

This represents a decl that may have a name.

Engages in a tight little dance with the lexer to efficiently preprocess tokens.

Scope - A scope is a transient data structure that is used while parsing the program.

@ Decl

The l-value was an access to a declared entity or something equivalently strong, like the address of ...

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

__UINTPTR_TYPE__ uintptr_t

An unsigned integer type with the property that any valid pointer to void can be converted to this ty...