1 //===- SemaHLSL.cpp - Semantic Analysis for HLSL constructs ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // This implements Semantic Analysis for HLSL constructs.
9 //===----------------------------------------------------------------------===//
10
11 #include "clang/Sema/Sema.h"
12
13 using namespace clang;
14
ActOnStartHLSLBuffer(Scope * BufferScope,bool CBuffer,SourceLocation KwLoc,IdentifierInfo * Ident,SourceLocation IdentLoc,SourceLocation LBrace)15 Decl *Sema::ActOnStartHLSLBuffer(Scope *BufferScope, bool CBuffer,
16 SourceLocation KwLoc, IdentifierInfo *Ident,
17 SourceLocation IdentLoc,
18 SourceLocation LBrace) {
19 // For anonymous namespace, take the location of the left brace.
20 DeclContext *LexicalParent = getCurLexicalContext();
21 HLSLBufferDecl *Result = HLSLBufferDecl::Create(
22 Context, LexicalParent, CBuffer, KwLoc, Ident, IdentLoc, LBrace);
23
24 PushOnScopeChains(Result, BufferScope);
25 PushDeclContext(BufferScope, Result);
26
27 return Result;
28 }
29
ActOnFinishHLSLBuffer(Decl * Dcl,SourceLocation RBrace)30 void Sema::ActOnFinishHLSLBuffer(Decl *Dcl, SourceLocation RBrace) {
31 auto *BufDecl = cast<HLSLBufferDecl>(Dcl);
32 BufDecl->setRBraceLoc(RBrace);
33 PopDeclContext();
34 }
35