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

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CLANG_SEMA_ATTR_H

14#define LLVM_CLANG_SEMA_ATTR_H

15

27#include "llvm/Support/Casting.h"

28

30

31

32

33

35 return (D->getFunctionType() != nullptr) || llvm::isa(D);

36}

37

38

39

43

44

45

51

52

53

54

60

61

62

63

67 if (const auto *BD = dyn_cast(D))

68 return BD->getNumParams();

70}

71

73 unsigned Idx) {

74 if (const auto *FD = dyn_cast(D))

75 return FD->getParamDecl(Idx);

76 if (const auto *MD = dyn_cast(D))

77 return MD->getParamDecl(Idx);

78 if (const auto *BD = dyn_cast(D))

79 return BD->getParamDecl(Idx);

80 return nullptr;

81}

82

86 if (const auto *BD = dyn_cast(D))

87 return BD->getParamDecl(Idx)->getType();

88

90}

91

94 return PVD->getSourceRange();

96}

97

100 return FnTy->getReturnType();

102}

103

105 if (const auto *FD = dyn_cast(D))

106 return FD->getReturnTypeSourceRange();

107 if (const auto *MD = dyn_cast(D))

108 return MD->getReturnTypeSourceRange();

110}

111

115 if (const auto *BD = dyn_cast(D))

116 return BD->isVariadic();

118}

119

121 if (const auto *MethodDecl = dyn_cast(D))

122 return MethodDecl->isInstance();

123 return false;

124}

125

127 if (const auto *MethodDecl = dyn_cast(D))

128 return MethodDecl->isImplicitObjectMemberFunction();

129 return false;

130}

131

132

133

134template

136 if (const auto *A = D->getAttr()) {

137 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)

138 << AL << A

140 S.Diag(A->getLocation(), diag::note_conflicting_attribute);

141 return true;

142 }

143 return false;

144}

145

146template

148 if (const auto *A = D->getAttr()) {

149 S.Diag(AL.getLocation(), diag::err_attributes_are_not_compatible)

150 << &AL << A

152 Diag(A->getLocation(), diag::note_conflicting_attribute);

153 return true;

154 }

155 return false;

156}

157

158template <typename... DiagnosticArgs>

159const SemaBase::SemaDiagnosticBuilder &

163

164template <typename T, typename... DiagnosticArgs>

165const SemaBase::SemaDiagnosticBuilder &

167 DiagnosticArgs &&...ExtraArgs) {

169 std::forward(ExtraArgs)...);

170}

171

172

173

174template

179

180

181

182

183

184template <typename AttrType, typename... DiagnosticArgs>

187 bool PassesCheck, unsigned DiagID,

188 DiagnosticArgs &&...ExtraArgs) {

189 if (!PassesCheck) {

191 appendDiagnostics(DB, std::forward(ExtraArgs)...);

192 return;

193 }

195}

196

197}

198#endif

Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....

static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)

Produce a diagnostic highlighting some portion of a literal.

Defines the clang::SourceLocation class and associated facilities.

C Language Family Type Representation.

Attr - This represents one attribute.

SourceLocation getLocation() const

bool isRegularKeywordAttribute() const

SourceLocation getLoc() const

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

const FunctionType * getFunctionType(bool BlocksToo=true) const

Looks through the Decl's underlying type to extract a FunctionType when possible.

SourceLocation getBeginLoc() const LLVM_READONLY

FunctionType - C99 6.7.5.3 - Function Declarators.

Represents a parameter to a function.

ParsedAttr - Represents a syntactic attribute.

A (possibly-)qualified type.

A generic diagnostic builder for errors which may or may not be deferred.

ASTContext & getASTContext() const

SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)

Emit a diagnostic.

A trivial tuple used to represent a source range.

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

bool isa(CodeGen::Address addr)

const SemaBase::SemaDiagnosticBuilder & appendDiagnostics(const SemaBase::SemaDiagnosticBuilder &Bldr)

Definition Attr.h:160

void handleSimpleAttributeOrDiagnose(SemaBase &S, Decl *D, const AttributeCommonInfo &CI, bool PassesCheck, unsigned DiagID, DiagnosticArgs &&...ExtraArgs)

Add an attribute AttrType to declaration D, provided that PassesCheck is true.

Definition Attr.h:185

bool hasDeclarator(const Decl *D)

Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...

Definition Attr.h:46

QualType getFunctionOrMethodResultType(const Decl *D)

Definition Attr.h:98

bool isInstanceMethod(const Decl *D)

Definition Attr.h:120

const ParmVarDecl * getFunctionOrMethodParam(const Decl *D, unsigned Idx)

Definition Attr.h:72

bool checkAttrMutualExclusion(SemaBase &S, Decl *D, const ParsedAttr &AL)

Diagnose mutually exclusive attributes when present on a given declaration.

Definition Attr.h:135

SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)

Definition Attr.h:104

bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D)

Return true if the given decl has function type (function or function-typed variable) or an Objective...

Definition Attr.h:40

QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)

Definition Attr.h:83

const FunctionProtoType * T

bool isFunctionOrMethodVariadic(const Decl *D)

Definition Attr.h:112

bool isFuncOrMethodForAttrSubject(const Decl *D)

isFuncOrMethodForAttrSubject - Return true if the given decl has function type (function or function-...

Definition Attr.h:34

void handleSimpleAttribute(SemaBase &S, Decl *D, const AttributeCommonInfo &CI)

Applies the given attribute to the Decl without performing any additional semantic checking.

Definition Attr.h:175

bool hasImplicitObjectParameter(const Decl *D)

Definition Attr.h:126

bool hasFunctionProto(const Decl *D)

hasFunctionProto - Return true if the given decl has a argument information.

Definition Attr.h:55

unsigned getFunctionOrMethodNumParams(const Decl *D)

getFunctionOrMethodNumParams - Return number of function or method parameters.

Definition Attr.h:64

U cast(CodeGen::Address addr)

SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)

Definition Attr.h:92