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