clang 23.0.0git
ParseDecl.cpp File Reference
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/PrettyDeclStackTrace.h"
#include "clang/Basic/AddressSpaces.h"
#include "clang/Basic/AttributeCommonInfo.h"
#include "clang/Basic/Attributes.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/ParsedAttr.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaCUDA.h"
#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenMP.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringSwitch.h"
#include <optional>
#include "clang/Parse/AttrParserStringSwitches.inc"
#include "clang/Basic/OpenCLImageTypes.def"
#include "clang/Basic/TransformTypeTraits.def"
#include "clang/Basic/HLSLIntangibleTypes.def"

Go to the source code of this file.

Macros

#define CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST
#define CLANG_ATTR_LATE_PARSED_LIST
#define CLANG_ATTR_IDENTIFIER_ARG_LIST
#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
#define CLANG_ATTR_ACCEPTS_EXPR_PACK
#define CLANG_ATTR_TYPE_ARG_LIST
#define CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
#define CLANG_ATTR_ARG_CONTEXT_LIST
#define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
#define IMAGE_WRITE_TYPE(Type, Id, Ext)
#define IMAGE_READ_TYPE(ImgType, Id, Ext)
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define GENERIC_IMAGE_TYPE(ImgType, Id)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define GENERIC_IMAGE_TYPE(ImgType, Id)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define GENERIC_IMAGE_TYPE(ImgType, Id)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)

Functions

static StringRef normalizeAttrName (StringRef Name)
 Normalizes an attribute name by dropping prefixed and suffixed __.
static bool IsAttributeLateParsedExperimentalExt (const IdentifierInfo &II)
 returns true iff attribute is annotated with LateAttrParseExperimentalExt in Attr.td.
static bool IsAttributeLateParsedStandard (const IdentifierInfo &II)
 returns true iff attribute is annotated with LateAttrParseStandard in Attr.td.
static bool FindLocsWithCommonFileID (Preprocessor &PP, SourceLocation StartLoc, SourceLocation EndLoc)
 Check if the a start and end source location expand to the same macro.
static bool attributeHasIdentifierArg (const llvm::Triple &T, const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute has an identifier argument.
static ParsedAttributeArgumentsProperties attributeStringLiteralListArg (const llvm::Triple &T, const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute has string arguments.
static bool attributeHasVariadicIdentifierArg (const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute has a variadic identifier argument.
static bool attributeTreatsKeywordThisAsIdentifier (const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute treats kw_this as an identifier.
static bool attributeAcceptsExprPack (const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine if an attribute accepts parameter packs.
static bool attributeIsTypeArgAttr (const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute parses a type argument.
static bool attributeHasStrictIdentifierArgs (const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute takes a strict identifier argument.
static bool attributeParsedArgsUnevaluated (const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
 Determine whether the given attribute requires parsing its arguments in an unevaluated context or not.
static bool VersionNumberSeparator (const char Separator)
static bool isValidAfterIdentifierInDeclarator (const Token &T)
 isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after the identifier in a declarator which immediately follows the declspec.
static void DiagnoseCountAttributedTypeInUnnamedAnon (ParsingDeclSpec &DS, Parser &P)
static bool isPtrOperatorToken (tok::TokenKind Kind, const LangOptions &Lang, DeclaratorContext TheContext)
static bool isPipeDeclarator (const Declarator &D)
static SourceLocation getMissingDeclaratorIdLoc (Declarator &D, SourceLocation Loc)

Macro Definition Documentation

◆ CLANG_ATTR_ACCEPTS_EXPR_PACK

#define CLANG_ATTR_ACCEPTS_EXPR_PACK

◆ CLANG_ATTR_ARG_CONTEXT_LIST

#define CLANG_ATTR_ARG_CONTEXT_LIST

◆ CLANG_ATTR_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_IDENTIFIER_ARG_LIST

◆ CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST

#define CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST

◆ CLANG_ATTR_LATE_PARSED_LIST

#define CLANG_ATTR_LATE_PARSED_LIST

◆ CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST

◆ CLANG_ATTR_STRING_LITERAL_ARG_LIST

#define CLANG_ATTR_STRING_LITERAL_ARG_LIST

◆ CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST

◆ CLANG_ATTR_TYPE_ARG_LIST

#define CLANG_ATTR_TYPE_ARG_LIST

◆ CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST

◆ GENERIC_IMAGE_TYPE [1/3]

#define GENERIC_IMAGE_TYPE ( ImgType,
Id )
Value:
case tok::kw_##ImgType##_t:

◆ GENERIC_IMAGE_TYPE [2/3]

#define GENERIC_IMAGE_TYPE ( ImgType,
Id )
Value:
case tok::kw_##ImgType##_t:

◆ GENERIC_IMAGE_TYPE [3/3]

#define GENERIC_IMAGE_TYPE ( ImgType,
Id )
Value:
case tok::kw_##ImgType##_t:

◆ HLSL_INTANGIBLE_TYPE [1/4]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case tok::kw_##Name: \
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##Name, Loc, PrevSpec, \
DiagID, Policy); \
break;
static bool isInvalid(LocType Loc, bool *Invalid)

◆ HLSL_INTANGIBLE_TYPE [2/4]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case tok::kw_##Name:

◆ HLSL_INTANGIBLE_TYPE [3/4]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case tok::kw_##Name:

◆ HLSL_INTANGIBLE_TYPE [4/4]

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case tok::kw_##Name:

◆ IMAGE_READ_TYPE

#define IMAGE_READ_TYPE ( ImgType,
Id,
Ext )
Value:
case tok::kw_##ImgType##_t: \
if (!handleOpenCLImageKW(Ext, DeclSpec::TST_##ImgType##_t)) \
goto DoneWithDeclSpec; \
break;

◆ IMAGE_READ_WRITE_TYPE

#define IMAGE_READ_WRITE_TYPE ( Type,
Id,
Ext )

◆ IMAGE_WRITE_TYPE

#define IMAGE_WRITE_TYPE ( Type,
Id,
Ext )

◆ TRANSFORM_TYPE_TRAIT_DEF

#define TRANSFORM_TYPE_TRAIT_DEF ( _,
Trait )
Value:
case tok::kw___##Trait:

Function Documentation

◆ attributeAcceptsExprPack()

bool attributeAcceptsExprPack ( const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine if an attribute accepts parameter packs.

Definition at line 327 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeHasIdentifierArg()

bool attributeHasIdentifierArg ( const llvm::Triple & T,
const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute has an identifier argument.

Definition at line 281 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeHasStrictIdentifierArgs()

bool attributeHasStrictIdentifierArgs ( const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute takes a strict identifier argument.

Definition at line 349 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeHasVariadicIdentifierArg()

bool attributeHasVariadicIdentifierArg ( const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute has a variadic identifier argument.

Definition at line 305 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeIsTypeArgAttr()

bool attributeIsTypeArgAttr ( const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute parses a type argument.

Definition at line 338 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeParsedArgsUnevaluated()

bool attributeParsedArgsUnevaluated ( const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute requires parsing its arguments in an unevaluated context or not.

Definition at line 361 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeStringLiteralListArg()

ParsedAttributeArgumentsProperties attributeStringLiteralListArg ( const llvm::Triple & T,
const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute has string arguments.

Definition at line 294 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ attributeTreatsKeywordThisAsIdentifier()

bool attributeTreatsKeywordThisAsIdentifier ( const IdentifierInfo & II,
ParsedAttr::Syntax Syntax,
IdentifierInfo * ScopeName )
static

Determine whether the given attribute treats kw_this as an identifier.

Definition at line 316 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ DiagnoseCountAttributedTypeInUnnamedAnon()

void DiagnoseCountAttributedTypeInUnnamedAnon ( ParsingDeclSpec & DS,
Parser & P )
static

◆ FindLocsWithCommonFileID()

bool FindLocsWithCommonFileID ( Preprocessor & PP,
SourceLocation StartLoc,
SourceLocation EndLoc )
static

◆ getMissingDeclaratorIdLoc()

◆ IsAttributeLateParsedExperimentalExt()

bool IsAttributeLateParsedExperimentalExt ( const IdentifierInfo & II)
static

returns true iff attribute is annotated with LateAttrParseExperimentalExt in Attr.td.

Definition at line 92 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ IsAttributeLateParsedStandard()

bool IsAttributeLateParsedStandard ( const IdentifierInfo & II)
static

returns true iff attribute is annotated with LateAttrParseStandard in Attr.td.

Definition at line 102 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

◆ isPipeDeclarator()

◆ isPtrOperatorToken()

bool isPtrOperatorToken ( tok::TokenKind Kind,
const LangOptions & Lang,
DeclaratorContext TheContext )
static

Definition at line 6353 of file ParseDecl.cpp.

References clang::ConversionId, and clang::CXXNew.

◆ isValidAfterIdentifierInDeclarator()

bool isValidAfterIdentifierInDeclarator ( const Token & T)
static

isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after the identifier in a declarator which immediately follows the declspec.

For example, these things are valid:

 int x   [             4];         // direct-declarator
 int x   (             int y);     // direct-declarator

int(int x ) // direct-declarator int x ; // simple-declaration int x = 17; // init-declarator-list int x , y; // init-declarator-list int x asm ("foo"); // init-declarator-list int x : 4; // struct-declarator int x { 5}; // C++'0x unified initializers

This is not, because 'x' does not immediately follow the declspec (though ')' happens to be valid anyway). int (x)

Definition at line 2795 of file ParseDecl.cpp.

◆ normalizeAttrName()

StringRef normalizeAttrName ( StringRef Name)
static

Normalizes an attribute name by dropping prefixed and suffixed __.

Definition at line 84 of file ParseDecl.cpp.

◆ VersionNumberSeparator()

bool VersionNumberSeparator ( const char Separator)
static

Definition at line 1104 of file ParseDecl.cpp.