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

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CLANG_AST_DECLGROUP_H

14#define LLVM_CLANG_AST_DECLGROUP_H

15

16#include "llvm/Support/TrailingObjects.h"

17#include

18#include

19

21

22class ASTContext;

24

25class DeclGroup final : private llvm::TrailingObjects<DeclGroup, Decl *> {

26

27 unsigned NumDecls = 0;

28

29private:

32

33public:

35

37

38 unsigned size() const { return NumDecls; }

39

41 assert (i < NumDecls && "Out-of-bounds access.");

42 return getTrailingObjects<Decl *>()[i];

43 }

44

46 assert (i < NumDecls && "Out-of-bounds access.");

47 return getTrailingObjects<Decl *>()[i];

48 }

49};

50

52

53

54 enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 };

55

56 Decl* D = nullptr;

57

58 Kind getKind() const {

59 return (Kind) (reinterpret_cast<uintptr_t>(D) & Mask);

60 }

61

62public:

66 : D((Decl*) (reinterpret_cast<uintptr_t>(dg) | DeclGroupKind)) {}

67

69 if (NumDecls == 0)

71 if (NumDecls == 1)

74 }

75

78

79 bool isNull() const { return D == nullptr; }

80 bool isSingleDecl() const { return getKind() == SingleDeclKind; }

81 bool isDeclGroup() const { return getKind() == DeclGroupKind; }

82

84 assert(isSingleDecl() && "Isn't a single decl");

85 return D;

86 }

89 }

90

92 assert(isDeclGroup() && "Isn't a declgroup");

94 }

97 }

98

101 return D ? &D : nullptr;

103 }

104

107 return D ? &D+1 : nullptr;

109 return &G[0] + G.size();

110 }

111

114 return D ? &D : nullptr;

116 }

117

120 return D ? &D+1 : nullptr;

122 return &G[0] + G.size();

123 }

124

128 X.D = static_cast<Decl*>(Ptr);

129 return X;

130 }

131};

132

133}

134

135namespace llvm {

136

137

138 template

140 template <>

143 return P.getAsOpaquePtr();

144 }

145

148 }

149

150 static constexpr int NumLowBitsAvailable = 0;

151 };

152

153}

154

155#endif

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

static DeclGroupRef getFromOpaquePtr(void *Ptr)

DeclGroupRef(DeclGroup *dg)

const Decl * getSingleDecl() const

Decl *const * const_iterator

const DeclGroup & getDeclGroup() const

static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)

const_iterator end() const

const_iterator begin() const

DeclGroup & getDeclGroup()

void * getAsOpaquePtr() const

bool isSingleDecl() const

static DeclGroup * Create(ASTContext &C, Decl **Decls, unsigned NumDecls)

Decl *const & operator[](unsigned i) const

Decl *& operator[](unsigned i)

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

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

@ Create

'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...

Diagnostic wrappers for TextAPI types for error reporting.

__UINTPTR_TYPE__ uintptr_t

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

static clang::DeclGroupRef getFromVoidPointer(void *P)

static void * getAsVoidPointer(clang::DeclGroupRef P)