19 #include "llvm/ADT/SmallString.h" 20 #include "llvm/ADT/SmallVector.h" 21 #include "llvm/ADT/StringRef.h" 22 #include "llvm/Support/ManagedStatic.h" 27 using namespace clang;
35 Result->Ident = Ident;
39 size_t ParsedAttr::allocated_size()
const {
41 else if (IsTypeTagForDatatype)
45 else if (HasParsedType)
56 FreeLists.resize(InlineFreeListsCapacity);
62 assert((size %
sizeof(
void*)) == 0);
63 return ((size -
sizeof(
ParsedAttr)) /
sizeof(
void *));
66 void *AttributeFactory::allocate(
size_t size) {
69 if (index < FreeLists.size() && !FreeLists[index].empty()) {
71 FreeLists[index].pop_back();
80 size_t size =
Attr->allocated_size();
84 if (freeListIndex >= FreeLists.size())
85 FreeLists.resize(freeListIndex + 1);
93 FreeLists[freeListIndex].push_back(
Attr);
102 Attrs.insert(Attrs.end(), pool.Attrs.begin(), pool.Attrs.end());
108 #include "clang/Sema/AttrParsedAttrImpl.inc" 114 if ((
size_t)A.
getParsedKind() < llvm::array_lengthof(AttrInfoMap))
121 return IgnoredParsedAttrInfo;
125 static llvm::ManagedStatic<std::list<std::unique_ptr<ParsedAttrInfo>>>
127 if (PluginAttrInstances->empty())
128 for (
auto It : ParsedAttrInfoRegistry::entries())
129 PluginAttrInstances->emplace_back(It.instantiate());
137 for (
auto &Ptr : *PluginAttrInstances)
138 for (
auto &S : Ptr->Spellings)
139 if (S.Syntax == SyntaxUsed && S.NormalizedFullName == FullName)
145 return DefaultParsedAttrInfo;
164 return checkAttributeMatchRuleAppliesTo(D, MatchRule);
Defines the clang::ASTContext interface.
static const ParsedAttrInfo & get(const AttributeCommonInfo &A)
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const
static size_t getFreeListIndexForSize(size_t size)
virtual unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const
Convert the spelling index of Attr to a semantic spelling enum value.
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
Decl - This represents one declaration (or definition), e.g.
Syntax
The style used to specify an attribute.
virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const
Check if this attribute appertains to D, and issue a diagnostic if not.
unsigned IsTargetSpecific
True if this attribute is only available for certain targets.
One of these records is kept for each identifier that is lexed.
SubjectMatchRule
A list of all the recognized kinds of attributes.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned NumArgs
The number of required arguments of this attribute.
void getMatchRules(const LangOptions &LangOpts, SmallVectorImpl< std::pair< attr::SubjectMatchRule, bool >> &MatchRules) const
bool isKnownToGCC() const
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
llvm::Registry< ParsedAttrInfo > ParsedAttrInfoRegistry
__ptr16, alignas(...), etc.
bool existsInTarget(const TargetInfo &Target) const
unsigned getMinArgs() const
bool hasVariadicArg() const
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
bool isTargetSpecificAttr() const
bool hasCustomParsing() const
virtual void getPragmaAttributeMatchRules(llvm::SmallVectorImpl< std::pair< attr::SubjectMatchRule, bool >> &Rules, const LangOptions &LangOpts) const
Populate Rules with the match rules of this attribute.
Sema - This implements semantic analysis and AST building for C.
unsigned IsSupportedByPragmaAttribute
True if this attribute is supported by #pragma clang attribute.
unsigned HasCustomParsing
True if the parsing does not match the semantic content.
Exposes information about the current target.
unsigned IsKnownToGCC
True if this attribute has any spellings that are known to gcc.
virtual bool existsInTarget(const TargetInfo &Target) const
Check if this attribute is allowed when compiling for the given target.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Wraps an identifier and optional source location for the identifier.
unsigned OptArgs
The number of optional arguments of this attributes.
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
const ParsedAttrInfo & getInfo() const
Encodes a location in the source.
unsigned IsType
True if this attribute applies to types.
ParsedAttr - Represents a syntactic attribute.
bool diagnoseLangOpts(class Sema &S) const
unsigned IsStmt
True if this attribute applies to statements.
Describes the trailing object for Availability attribute in ParsedAttr.
Dataflow Directional Tag Classes.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const
Check if this attribute is allowed by the language we are compiling, and issue a diagnostic if not.
unsigned getMaxArgs() const
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
std::string getNormalizedFullName() const
Gets the normalized full name, which consists of both scope and name and with surrounding underscores...
bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const
Defines the clang::TargetInfo interface.
bool isSupportedByPragmaAttribute() const
Context-sensitive version of a keyword attribute.
Kind getParsedKind() const
Attr - This represents one attribute.