#include "clang/Sema/SemaHLSL.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/ParsedAttr.h"
#include "clang/Sema/Sema.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/TargetParser/Triple.h"
#include <iterator>
usingnamespaceclang;
SemaHLSL::SemaHLSL(Sema &S) : … { … }
Decl *SemaHLSL::ActOnStartBuffer(Scope *BufferScope, bool CBuffer,
SourceLocation KwLoc, IdentifierInfo *Ident,
SourceLocation IdentLoc,
SourceLocation LBrace) { … }
static unsigned calculateLegacyCbufferSize(const ASTContext &Context,
QualType T) { … }
void SemaHLSL::ActOnFinishBuffer(Decl *Dcl, SourceLocation RBrace) { … }
HLSLNumThreadsAttr *SemaHLSL::mergeNumThreadsAttr(Decl *D,
const AttributeCommonInfo &AL,
int X, int Y, int Z) { … }
HLSLWaveSizeAttr *SemaHLSL::mergeWaveSizeAttr(Decl *D,
const AttributeCommonInfo &AL,
int Min, int Max, int Preferred,
int SpelledArgsCount) { … }
HLSLShaderAttr *
SemaHLSL::mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL,
llvm::Triple::EnvironmentType ShaderType) { … }
HLSLParamModifierAttr *
SemaHLSL::mergeParamModifierAttr(Decl *D, const AttributeCommonInfo &AL,
HLSLParamModifierAttr::Spelling Spelling) { … }
void SemaHLSL::ActOnTopLevelFunction(FunctionDecl *FD) { … }
void SemaHLSL::CheckEntryPoint(FunctionDecl *FD) { … }
void SemaHLSL::CheckSemanticAnnotation(
FunctionDecl *EntryPoint, const Decl *Param,
const HLSLAnnotationAttr *AnnotationAttr) { … }
void SemaHLSL::DiagnoseAttrStageMismatch(
const Attr *A, llvm::Triple::EnvironmentType Stage,
std::initializer_list<llvm::Triple::EnvironmentType> AllowedStages) { … }
void SemaHLSL::handleNumThreadsAttr(Decl *D, const ParsedAttr &AL) { … }
static bool isValidWaveSizeValue(unsigned Value) { … }
void SemaHLSL::handleWaveSizeAttr(Decl *D, const ParsedAttr &AL) { … }
static bool isLegalTypeForHLSLSV_DispatchThreadID(QualType T) { … }
void SemaHLSL::handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL) { … }
void SemaHLSL::handlePackOffsetAttr(Decl *D, const ParsedAttr &AL) { … }
void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { … }
void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) { … }
bool SemaHLSL::handleResourceTypeAttr(const ParsedAttr &AL) { … }
QualType SemaHLSL::ProcessResourceTypeAttributes(QualType CurrentType) { … }
SourceLocation
SemaHLSL::TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT) { … }
struct RegisterBindingFlags { … };
static bool isDeclaredWithinCOrTBuffer(const Decl *TheDecl) { … }
static CXXRecordDecl *getRecordDeclFromVarDecl(VarDecl *VD) { … }
static void updateResourceClassFlagsFromDeclResourceClass(
RegisterBindingFlags &Flags, llvm::hlsl::ResourceClass DeclResourceClass) { … }
template <typename T>
static const T *getSpecifiedHLSLAttrFromRecordDecl(RecordDecl *TheRecordDecl) { … }
template <typename T>
static const T *getSpecifiedHLSLAttrFromVarDecl(VarDecl *VD) { … }
static void updateFlagsFromType(QualType TheQualTy,
RegisterBindingFlags &Flags);
static void updateResourceClassFlagsFromRecordDecl(RegisterBindingFlags &Flags,
const RecordDecl *RD) { … }
static void updateFlagsFromType(QualType TheQualTy,
RegisterBindingFlags &Flags) { … }
static RegisterBindingFlags HLSLFillRegisterBindingFlags(Sema &S,
Decl *TheDecl) { … }
enum class RegisterType { … };
static RegisterType getRegisterType(StringRef Slot) { … }
static void ValidateMultipleRegisterAnnotations(Sema &S, Decl *TheDecl,
RegisterType regType) { … }
static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
Decl *TheDecl, RegisterType regType) { … }
void SemaHLSL::handleResourceBindingAttr(Decl *TheDecl, const ParsedAttr &AL) { … }
void SemaHLSL::handleParamModifierAttr(Decl *D, const ParsedAttr &AL) { … }
namespace {
class DiagnoseHLSLAvailability
: public RecursiveASTVisitor<DiagnoseHLSLAvailability> { … };
void DiagnoseHLSLAvailability::HandleFunctionOrMethodRef(FunctionDecl *FD,
Expr *RefExpr) { … }
void DiagnoseHLSLAvailability::RunOnTranslationUnit(
const TranslationUnitDecl *TU) { … }
void DiagnoseHLSLAvailability::RunOnFunction(const FunctionDecl *FD) { … }
bool DiagnoseHLSLAvailability::HasMatchingEnvironmentOrNone(
const AvailabilityAttr *AA) { … }
const AvailabilityAttr *
DiagnoseHLSLAvailability::FindAvailabilityAttr(const Decl *D) { … }
void DiagnoseHLSLAvailability::CheckDeclAvailability(NamedDecl *D,
const AvailabilityAttr *AA,
SourceRange Range) { … }
}
void SemaHLSL::DiagnoseAvailabilityViolations(TranslationUnitDecl *TU) { … }
bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { … }
bool CheckArgsTypesAreCorrect(
Sema *S, CallExpr *TheCall, QualType ExpectedType,
llvm::function_ref<bool(clang::QualType PassedType)> Check) { … }
bool CheckAllArgsHaveFloatRepresentation(Sema *S, CallExpr *TheCall) { … }
bool CheckFloatOrHalfRepresentations(Sema *S, CallExpr *TheCall) { … }
bool CheckNoDoubleVectors(Sema *S, CallExpr *TheCall) { … }
bool CheckUnsignedIntRepresentation(Sema *S, CallExpr *TheCall) { … }
void SetElementTypeAsReturnType(Sema *S, CallExpr *TheCall,
QualType ReturnType) { … }
bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { … }
static void BuildFlattenedTypeList(QualType BaseTy,
llvm::SmallVectorImpl<QualType> &List) { … }
bool SemaHLSL::IsScalarizedLayoutCompatible(QualType T1, QualType T2) const { … }
bool SemaHLSL::CheckCompatibleParameterABI(FunctionDecl *New,
FunctionDecl *Old) { … }
ExprResult SemaHLSL::ActOnOutParamExpr(ParmVarDecl *Param, Expr *Arg) { … }
QualType SemaHLSL::getInoutParameterType(QualType Ty) { … }