1//===--- HLSLResource.cpp - Helper routines for HLSL resources -----------===//
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//
9// This file provides shared routines to help analyze HLSL resources and
10// their bindings during Sema and CodeGen.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/HLSLResource.h"
15#include "clang/AST/Decl.h"
16#include "clang/AST/DeclCXX.h"
17#include "clang/AST/Type.h"
18
19using namespace clang;
20
21namespace clang {
22namespace hlsl {
23
24void EmbeddedResourceNameBuilder::pushBaseName(llvm::StringRef N) {
25 pushName(N, Delim: FieldDelim);
26 Name.append(RHS: BaseClassDelim);
27}
28
29void EmbeddedResourceNameBuilder::pushName(llvm::StringRef N,
30 llvm::StringRef Delim) {
31 Offsets.push_back(Elt: Name.size());
32 if (!Name.empty() && !Name.ends_with(Suffix: BaseClassDelim))
33 Name.append(RHS: Delim);
34 Name.append(RHS: N);
35}
36
37void EmbeddedResourceNameBuilder::pushArrayIndex(uint64_t Index) {
38 llvm::raw_svector_ostream OS(Name);
39 Offsets.push_back(Elt: Name.size());
40 OS << ArrayIndexDelim;
41 OS << Index;
42}
43
44} // namespace hlsl
45} // namespace clang
46