32 if (isa<CXXRecordDecl, RecordDecl, FunctionDecl, VarDecl>(D))
36 if (isa<HLSLBufferDecl, NamespaceDecl>(D)) {
37 P.Diag(D->
getLocation(), diag::err_invalid_declaration_in_hlsl_buffer)
44 P.Diag(D->
getLocation(), diag::err_invalid_declaration_in_hlsl_buffer)
51 assert((Tok.
is(tok::kw_cbuffer) || Tok.
is(tok::kw_tbuffer)) &&
52 "Not a cbuffer or tbuffer!");
53 bool IsCBuffer = Tok.
is(tok::kw_cbuffer);
56 if (!Tok.
is(tok::identifier)) {
57 Diag(Tok, diag::err_expected) << tok::identifier;
65 MaybeParseHLSLSemantics(Attrs,
nullptr);
69 if (T.consumeOpen()) {
70 Diag(Tok, diag::err_expected) << tok::l_brace;
78 while (Tok.
isNot(tok::r_brace) && Tok.
isNot(tok::eof)) {
84 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
88 DeclEnd = T.getCloseLocation();
96 DeclEnd = T.getCloseLocation();
112 std::string FixedArg = ArgStr.str() + Num.str();
113 P.Diag(ArgLoc, diag::err_hlsl_separate_attr_arg_and_number)
125 assert(Tok.
is(tok::colon) &&
"Not a HLSL Semantic");
129 if (Tok.
is(tok::kw_register))
131 else if (Tok.
is(tok::identifier))
147 case ParsedAttr::AT_HLSLResourceBinding: {
148 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after)) {
152 if (!Tok.
is(tok::identifier)) {
159 ArgExprs.push_back(ParseIdentifierLoc());
162 if (SlotStr.size() == 1 && Tok.
is(tok::numeric_constant))
166 if (Tok.
is(tok::comma)) {
168 if (!Tok.
is(tok::identifier)) {
175 ArgExprs.push_back(ParseIdentifierLoc());
178 if (SpaceStr.equals(
"space") && Tok.
is(tok::numeric_constant))
182 if (ExpectAndConsume(tok::r_paren, diag::err_expected)) {
188 Diag(Loc, diag::err_unknown_hlsl_semantic) << II;
190 case ParsedAttr::AT_HLSLSV_GroupIndex:
191 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
194 llvm_unreachable(
"invalid HLSL Semantic");
199 ArgExprs.size(), ParsedAttr::Form::HLSLSemantic());
static bool validateDeclsInsideHLSLBuffer(Parser::DeclGroupPtrTy DG, SourceLocation BufferLoc, bool IsCBuffer, Parser &P)
static void fixSeparateAttrArgAndNumber(StringRef ArgStr, SourceLocation ArgLoc, Token Tok, ArgsVector &ArgExprs, Parser &P, ASTContext &Ctx, Preprocessor &PP)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
@ AS_HLSLSemantic
<vardecl> : <semantic>
Kind getParsedKind() const
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Wrapper for void* pointer.
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
Parser - This implements a parser for the C family of languages.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
@ StopAtSemi
Stop skipping at semicolon.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
@ DeclScope
This is a scope that can contain a declaration.
Decl * ActOnStartHLSLBuffer(Scope *BufferScope, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *Ident, SourceLocation IdentLoc, SourceLocation LBrace)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void ActOnFinishHLSLBuffer(Decl *Dcl, SourceLocation RBrace)
Encodes a location in the source.
A trivial tuple used to represent a source range.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getEndLoc() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
bool isNot(tok::TokenKind K) const
const char * getLiteralData() const
getLiteralData - For a literal token (numeric constant, string, etc), this returns a pointer to the s...
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ Result
The result type of a method or function.
Wraps an identifier and optional source location for the identifier.
static IdentifierLoc * create(ASTContext &Ctx, SourceLocation Loc, IdentifierInfo *Ident)