clang  9.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
clang::ParsedAttr Class Referencefinal

ParsedAttr - Represents a syntactic attribute. More...

#include "clang/Sema/ParsedAttr.h"

Inheritance diagram for clang::ParsedAttr:
Inheritance graph
[legend]
Collaboration diagram for clang::ParsedAttr:
Collaboration graph
[legend]

Public Types

enum  Syntax {
  AS_GNU, AS_CXX11, AS_C2x, AS_Declspec,
  AS_Microsoft, AS_Keyword, AS_Pragma, AS_ContextSensitiveKeyword
}
 The style used to specify an attribute. More...
 
enum  Kind { IgnoredAttribute, UnknownAttribute }
 

Public Member Functions

 ParsedAttr (const ParsedAttr &)=delete
 
 ParsedAttr (ParsedAttr &&)=delete
 
ParsedAttroperator= (const ParsedAttr &)=delete
 
ParsedAttroperator= (ParsedAttr &&)=delete
 
 ~ParsedAttr ()=delete
 
void operator delete (void *)=delete
 
IdentifierInfogetName () const
 
SourceLocation getLoc () const
 
SourceRange getRange () const
 
bool hasScope () const
 
IdentifierInfogetScopeName () const
 
SourceLocation getScopeLoc () const
 
bool isGNUScope () const
 
bool hasParsedType () const
 
bool isDeclspecPropertyAttribute () const
 Is this the Microsoft __declspec(property) attribute? More...
 
bool isAlignasAttribute () const
 
bool isDeclspecAttribute () const
 
bool isMicrosoftAttribute () const
 
bool isCXX11Attribute () const
 
bool isC2xAttribute () const
 
bool isKeywordAttribute () const
 
bool isContextSensitiveKeywordAttribute () const
 
bool isInvalid () const
 
void setInvalid (bool b=true) const
 
bool hasProcessingCache () const
 
unsigned getProcessingCache () const
 
void setProcessingCache (unsigned value) const
 
bool isUsedAsTypeAttr () const
 
void setUsedAsTypeAttr (bool Used=true)
 
bool isPragmaClangAttribute () const
 True if the attribute is specified using '#pragma clang attribute'. More...
 
void setIsPragmaClangAttribute ()
 
bool isPackExpansion () const
 
SourceLocation getEllipsisLoc () const
 
Kind getKind () const
 
unsigned getNumArgs () const
 getNumArgs - Return the number of actual arguments to this attribute. More...
 
ArgsUnion getArg (unsigned Arg) const
 getArg - Return the specified argument. More...
 
bool isArgExpr (unsigned Arg) const
 
ExprgetArgAsExpr (unsigned Arg) const
 
bool isArgIdent (unsigned Arg) const
 
IdentifierLocgetArgAsIdent (unsigned Arg) const
 
const AvailabilityChangegetAvailabilityIntroduced () const
 
const AvailabilityChangegetAvailabilityDeprecated () const
 
const AvailabilityChangegetAvailabilityObsoleted () const
 
SourceLocation getStrictLoc () const
 
SourceLocation getUnavailableLoc () const
 
const ExprgetMessageExpr () const
 
const ExprgetReplacementExpr () const
 
const ParsedTypegetMatchingCType () const
 
bool getLayoutCompatible () const
 
bool getMustBeNull () const
 
const ParsedTypegetTypeArg () const
 
IdentifierInfogetPropertyDataGetter () const
 
IdentifierInfogetPropertyDataSetter () const
 
void setMacroIdentifier (IdentifierInfo *MacroName, SourceLocation Loc)
 Set the macro identifier info object that this parsed attribute was declared in if it was declared in a macro. More...
 
bool hasMacroIdentifier () const
 Returns true if this attribute was declared in a macro. More...
 
IdentifierInfogetMacroIdentifier () const
 Return the macro identifier if this attribute was declared in a macro. More...
 
SourceLocation getMacroExpansionLoc () const
 
unsigned getAttributeSpellingListIndex () const
 Get an index into the attribute spelling list defined in Attr.td. More...
 
bool isTargetSpecificAttr () const
 
bool isTypeAttr () const
 
bool isStmtAttr () const
 
bool hasCustomParsing () const
 
unsigned getMinArgs () const
 
unsigned getMaxArgs () const
 
bool hasVariadicArg () const
 
bool diagnoseAppertainsTo (class Sema &S, const Decl *D) const
 
bool appliesToDecl (const Decl *D, attr::SubjectMatchRule MatchRule) const
 
void getMatchRules (const LangOptions &LangOpts, SmallVectorImpl< std::pair< attr::SubjectMatchRule, bool >> &MatchRules) const
 
bool diagnoseLangOpts (class Sema &S) const
 
bool existsInTarget (const TargetInfo &Target) const
 
bool isKnownToGCC () const
 
bool isSupportedByPragmaAttribute () const
 
unsigned getSemanticSpelling () const
 If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration (due to having semantically-distinct spelling variations), return the value of that semantic spelling. More...
 
LangAS asOpenCLLangAS () const
 If this is an OpenCL addr space attribute returns its representation in LangAS, otherwise returns default addr space. More...
 

Static Public Member Functions

static Kind getKind (const IdentifierInfo *Name, const IdentifierInfo *Scope, Syntax SyntaxUsed)
 

Friends

class AttributeFactory
 
class AttributePool
 

Detailed Description

ParsedAttr - Represents a syntactic attribute.

For a GNU attribute, there are four forms of this construct:

1: attribute(( const )). ParmName/Args/NumArgs will all be unused. 2: attribute(( mode(byte) )). ParmName used, Args/NumArgs unused. 3: attribute(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used. 4: attribute(( aligned(16) )). ParmName is unused, Args/Num used.

Definition at line 116 of file ParsedAttr.h.

Member Enumeration Documentation

◆ Kind

Enumerator
IgnoredAttribute 
UnknownAttribute 

Definition at line 375 of file ParsedAttr.h.

◆ Syntax

The style used to specify an attribute.

Enumerator
AS_GNU 

attribute((...))

AS_CXX11 

[[...]]

AS_C2x 

[[...]]

AS_Declspec 

__declspec(...)

AS_Microsoft 

[uuid("...")] class Foo

AS_Keyword 

__ptr16, alignas(...), etc.

AS_Pragma 

#pragma ...

AS_ContextSensitiveKeyword 

Context-sensitive version of a keyword attribute.

Definition at line 139 of file ParsedAttr.h.

Constructor & Destructor Documentation

◆ ParsedAttr() [1/2]

clang::ParsedAttr::ParsedAttr ( const ParsedAttr )
delete

◆ ParsedAttr() [2/2]

clang::ParsedAttr::ParsedAttr ( ParsedAttr &&  )
delete

◆ ~ParsedAttr()

clang::ParsedAttr::~ParsedAttr ( )
delete

Member Function Documentation

◆ appliesToDecl()

bool ParsedAttr::appliesToDecl ( const Decl D,
attr::SubjectMatchRule  MatchRule 
) const

Definition at line 211 of file ParsedAttr.cpp.

Referenced by clang::Sema::AddPragmaAttributes().

◆ asOpenCLLangAS()

LangAS clang::ParsedAttr::asOpenCLLangAS ( ) const
inline

If this is an OpenCL addr space attribute returns its representation in LangAS, otherwise returns default addr space.

Definition at line 605 of file ParsedAttr.h.

References clang::Default, getKind(), clang::opencl_constant, clang::opencl_generic, clang::opencl_global, clang::opencl_local, and clang::opencl_private.

Referenced by HandleAddressSpaceTypeAttribute().

◆ diagnoseAppertainsTo()

bool ParsedAttr::diagnoseAppertainsTo ( class Sema S,
const Decl D 
) const

Definition at line 207 of file ParsedAttr.cpp.

Referenced by HandleLifetimeBoundAttr().

◆ diagnoseLangOpts()

bool ParsedAttr::diagnoseLangOpts ( class Sema S) const

Definition at line 223 of file ParsedAttr.cpp.

◆ existsInTarget()

bool ParsedAttr::existsInTarget ( const TargetInfo Target) const

Definition at line 235 of file ParsedAttr.cpp.

References ParsedAttrInfo::ExistsInTarget, and getInfo().

◆ getArg()

ArgsUnion clang::ParsedAttr::getArg ( unsigned  Arg) const
inline

getArg - Return the specified argument.

Definition at line 461 of file ParsedAttr.h.

◆ getArgAsExpr()

Expr* clang::ParsedAttr::getArgAsExpr ( unsigned  Arg) const
inline

◆ getArgAsIdent()

IdentifierLoc* clang::ParsedAttr::getArgAsIdent ( unsigned  Arg) const
inline

◆ getAttributeSpellingListIndex()

unsigned ParsedAttr::getAttributeSpellingListIndex ( ) const

Get an index into the attribute spelling list defined in Attr.td.

This index is used by an attribute to pretty print itself.

Definition at line 156 of file ParsedAttr.cpp.

References normalizeAttrScopeName().

Referenced by checkObjCKindOfType(), createSimpleAttr(), getCCTypeAttr(), HandleAddressSpaceTypeAttribute(), handleObjCGCTypeAttr(), and handleObjCOwnershipTypeAttr().

◆ getAvailabilityDeprecated()

const AvailabilityChange& clang::ParsedAttr::getAvailabilityDeprecated ( ) const
inline

Definition at line 487 of file ParsedAttr.h.

References clang::detail::DeprecatedSlot, and getKind().

◆ getAvailabilityIntroduced()

const AvailabilityChange& clang::ParsedAttr::getAvailabilityIntroduced ( ) const
inline

Definition at line 482 of file ParsedAttr.h.

References getKind(), and clang::detail::IntroducedSlot.

◆ getAvailabilityObsoleted()

const AvailabilityChange& clang::ParsedAttr::getAvailabilityObsoleted ( ) const
inline

Definition at line 492 of file ParsedAttr.h.

References getKind(), and clang::detail::ObsoletedSlot.

◆ getEllipsisLoc()

SourceLocation clang::ParsedAttr::getEllipsisLoc ( ) const
inline

Definition at line 451 of file ParsedAttr.h.

◆ getKind() [1/2]

Kind clang::ParsedAttr::getKind ( ) const
inline

◆ getKind() [2/2]

ParsedAttr::Kind ParsedAttr::getKind ( const IdentifierInfo Name,
const IdentifierInfo Scope,
Syntax  SyntaxUsed 
)
static

Definition at line 136 of file ParsedAttr.cpp.

◆ getLayoutCompatible()

bool clang::ParsedAttr::getLayoutCompatible ( ) const
inline

Definition at line 523 of file ParsedAttr.h.

References getKind().

◆ getLoc()

SourceLocation clang::ParsedAttr::getLoc ( ) const
inline

◆ getMacroExpansionLoc()

SourceLocation clang::ParsedAttr::getMacroExpansionLoc ( ) const
inline

Definition at line 567 of file ParsedAttr.h.

◆ getMacroIdentifier()

IdentifierInfo* clang::ParsedAttr::getMacroIdentifier ( ) const
inline

Return the macro identifier if this attribute was declared in a macro.

nullptr is returned if it was not declared in a macro.

Definition at line 565 of file ParsedAttr.h.

◆ getMatchingCType()

const ParsedType& clang::ParsedAttr::getMatchingCType ( ) const
inline

Definition at line 517 of file ParsedAttr.h.

References getKind().

◆ getMatchRules()

void ParsedAttr::getMatchRules ( const LangOptions LangOpts,
SmallVectorImpl< std::pair< attr::SubjectMatchRule, bool >> &  MatchRules 
) const

◆ getMaxArgs()

unsigned ParsedAttr::getMaxArgs ( ) const

Definition at line 199 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::OptArgs.

Referenced by IsBuiltInOrStandardCXX11Attribute().

◆ getMessageExpr()

const Expr* clang::ParsedAttr::getMessageExpr ( ) const
inline

Definition at line 507 of file ParsedAttr.h.

References getKind().

◆ getMinArgs()

unsigned ParsedAttr::getMinArgs ( ) const

Definition at line 197 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::NumArgs.

◆ getMustBeNull()

bool clang::ParsedAttr::getMustBeNull ( ) const
inline

Definition at line 529 of file ParsedAttr.h.

References getKind().

◆ getName()

IdentifierInfo* clang::ParsedAttr::getName ( ) const
inline

◆ getNumArgs()

unsigned clang::ParsedAttr::getNumArgs ( ) const
inline

getNumArgs - Return the number of actual arguments to this attribute.

Definition at line 458 of file ParsedAttr.h.

Referenced by getNumAttributeArgs(), HandleAddressSpaceTypeAttribute(), HandleExtVectorTypeAttr(), handleFunctionTypeAttr(), HandleNeonVectorTypeAttr(), handleObjCGCTypeAttr(), and HandleVectorSizeAttr().

◆ getProcessingCache()

unsigned clang::ParsedAttr::getProcessingCache ( ) const
inline

Definition at line 432 of file ParsedAttr.h.

◆ getPropertyDataGetter()

IdentifierInfo* clang::ParsedAttr::getPropertyDataGetter ( ) const
inline

Definition at line 540 of file ParsedAttr.h.

◆ getPropertyDataSetter()

IdentifierInfo* clang::ParsedAttr::getPropertyDataSetter ( ) const
inline

Definition at line 546 of file ParsedAttr.h.

◆ getRange()

SourceRange clang::ParsedAttr::getRange ( ) const
inline

◆ getReplacementExpr()

const Expr* clang::ParsedAttr::getReplacementExpr ( ) const
inline

Definition at line 512 of file ParsedAttr.h.

References getKind().

◆ getScopeLoc()

SourceLocation clang::ParsedAttr::getScopeLoc ( ) const
inline

Definition at line 389 of file ParsedAttr.h.

◆ getScopeName()

IdentifierInfo* clang::ParsedAttr::getScopeName ( ) const
inline

Definition at line 388 of file ParsedAttr.h.

◆ getSemanticSpelling()

unsigned ParsedAttr::getSemanticSpelling ( ) const

If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration (due to having semantically-distinct spelling variations), return the value of that semantic spelling.

If the parsed attribute does not have a semantic equivalent, or would not have a Spelling enumeration, the value UINT_MAX is returned.

Definition at line 245 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::SpellingIndexToSemanticSpelling.

Referenced by HandleOpenCLAccessAttr().

◆ getStrictLoc()

SourceLocation clang::ParsedAttr::getStrictLoc ( ) const
inline

Definition at line 497 of file ParsedAttr.h.

References getKind().

◆ getTypeArg()

const ParsedType& clang::ParsedAttr::getTypeArg ( ) const
inline

Definition at line 535 of file ParsedAttr.h.

◆ getUnavailableLoc()

SourceLocation clang::ParsedAttr::getUnavailableLoc ( ) const
inline

Definition at line 502 of file ParsedAttr.h.

References getKind().

◆ hasCustomParsing()

bool ParsedAttr::hasCustomParsing ( ) const

Definition at line 203 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::HasCustomParsing.

◆ hasMacroIdentifier()

bool clang::ParsedAttr::hasMacroIdentifier ( ) const
inline

Returns true if this attribute was declared in a macro.

Definition at line 561 of file ParsedAttr.h.

◆ hasParsedType()

bool clang::ParsedAttr::hasParsedType ( ) const
inline

Definition at line 396 of file ParsedAttr.h.

Referenced by getNumAttributeArgs().

◆ hasProcessingCache()

bool clang::ParsedAttr::hasProcessingCache ( ) const
inline

Definition at line 430 of file ParsedAttr.h.

◆ hasScope()

bool clang::ParsedAttr::hasScope ( ) const
inline

Definition at line 387 of file ParsedAttr.h.

◆ hasVariadicArg()

bool ParsedAttr::hasVariadicArg ( ) const

Definition at line 249 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::OptArgs.

◆ isAlignasAttribute()

bool clang::ParsedAttr::isAlignasAttribute ( ) const
inline

Definition at line 403 of file ParsedAttr.h.

References getKind().

◆ isArgExpr()

bool clang::ParsedAttr::isArgExpr ( unsigned  Arg) const
inline

Definition at line 466 of file ParsedAttr.h.

Referenced by getCCTypeAttr().

◆ isArgIdent()

bool clang::ParsedAttr::isArgIdent ( unsigned  Arg) const
inline

◆ isC2xAttribute()

bool clang::ParsedAttr::isC2xAttribute ( ) const
inline

Definition at line 415 of file ParsedAttr.h.

◆ isContextSensitiveKeywordAttribute()

bool clang::ParsedAttr::isContextSensitiveKeywordAttribute ( ) const
inline

Definition at line 423 of file ParsedAttr.h.

Referenced by checkNullabilityTypeSpecifier(), and distributeNullabilityTypeAttr().

◆ isCXX11Attribute()

bool clang::ParsedAttr::isCXX11Attribute ( ) const
inline

Definition at line 411 of file ParsedAttr.h.

Referenced by distributeFunctionTypeAttrFromDeclSpec().

◆ isDeclspecAttribute()

bool clang::ParsedAttr::isDeclspecAttribute ( ) const
inline

Definition at line 408 of file ParsedAttr.h.

◆ isDeclspecPropertyAttribute()

bool clang::ParsedAttr::isDeclspecPropertyAttribute ( ) const
inline

Is this the Microsoft __declspec(property) attribute?

Definition at line 399 of file ParsedAttr.h.

Referenced by getMSPropertyAttr().

◆ isGNUScope()

bool clang::ParsedAttr::isGNUScope ( ) const
inline

Definition at line 391 of file ParsedAttr.h.

References clang::IdentifierInfo::isStr().

◆ isInvalid()

bool clang::ParsedAttr::isInvalid ( ) const
inline

Definition at line 427 of file ParsedAttr.h.

Referenced by getCCTypeAttr().

◆ isKeywordAttribute()

bool clang::ParsedAttr::isKeywordAttribute ( ) const
inline

Definition at line 419 of file ParsedAttr.h.

◆ isKnownToGCC()

bool ParsedAttr::isKnownToGCC ( ) const

Definition at line 239 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::IsKnownToGCC.

◆ isMicrosoftAttribute()

bool clang::ParsedAttr::isMicrosoftAttribute ( ) const
inline

Definition at line 409 of file ParsedAttr.h.

◆ isPackExpansion()

bool clang::ParsedAttr::isPackExpansion ( ) const
inline

Definition at line 450 of file ParsedAttr.h.

References clang::SourceLocation::isValid().

◆ isPragmaClangAttribute()

bool clang::ParsedAttr::isPragmaClangAttribute ( ) const
inline

True if the attribute is specified using '#pragma clang attribute'.

Definition at line 446 of file ParsedAttr.h.

Referenced by clang::Sema::AddPragmaAttributes().

◆ isStmtAttr()

bool ParsedAttr::isStmtAttr ( ) const

Definition at line 233 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::IsStmt.

◆ isSupportedByPragmaAttribute()

bool ParsedAttr::isSupportedByPragmaAttribute ( ) const

Definition at line 241 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::IsSupportedByPragmaAttribute.

◆ isTargetSpecificAttr()

bool ParsedAttr::isTargetSpecificAttr ( ) const

Definition at line 227 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::IsTargetSpecific.

◆ isTypeAttr()

bool ParsedAttr::isTypeAttr ( ) const

Definition at line 231 of file ParsedAttr.cpp.

References getInfo(), and ParsedAttrInfo::IsType.

◆ isUsedAsTypeAttr()

bool clang::ParsedAttr::isUsedAsTypeAttr ( ) const
inline

Definition at line 442 of file ParsedAttr.h.

◆ operator delete()

void clang::ParsedAttr::operator delete ( void *  )
delete

◆ operator=() [1/2]

ParsedAttr& clang::ParsedAttr::operator= ( const ParsedAttr )
delete

◆ operator=() [2/2]

ParsedAttr& clang::ParsedAttr::operator= ( ParsedAttr &&  )
delete

◆ setInvalid()

void clang::ParsedAttr::setInvalid ( bool  b = true) const
inline

◆ setIsPragmaClangAttribute()

void clang::ParsedAttr::setIsPragmaClangAttribute ( )
inline

Definition at line 448 of file ParsedAttr.h.

Referenced by clang::Sema::ActOnPragmaAttributeAttribute().

◆ setMacroIdentifier()

void clang::ParsedAttr::setMacroIdentifier ( IdentifierInfo MacroName,
SourceLocation  Loc 
)
inline

Set the macro identifier info object that this parsed attribute was declared in if it was declared in a macro.

Also set the expansion location of the macro.

Definition at line 555 of file ParsedAttr.h.

◆ setProcessingCache()

void clang::ParsedAttr::setProcessingCache ( unsigned  value) const
inline

Definition at line 437 of file ParsedAttr.h.

◆ setUsedAsTypeAttr()

void clang::ParsedAttr::setUsedAsTypeAttr ( bool  Used = true)
inline

Definition at line 443 of file ParsedAttr.h.

References Used.

Referenced by createSimpleAttr().

Friends And Related Function Documentation

◆ AttributeFactory

friend class AttributeFactory
friend

Definition at line 234 of file ParsedAttr.h.

◆ AttributePool

friend class AttributePool
friend

Definition at line 235 of file ParsedAttr.h.


The documentation for this class was generated from the following files: