#include "clang/Sema/SemaHLSL.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Attrs.inc"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/Builtins.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 "clang/Sema/Template.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.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>
#include <utility>
usingnamespaceclang;
ResourceClass;
enum class RegisterType { … };
static RegisterType getRegisterType(ResourceClass RC) { … }
static RegisterType getRegisterType(StringRef Slot) { … }
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) { … }
template <CastKind Kind>
static void castVector(Sema &S, ExprResult &E, QualType &Ty, unsigned Sz) { … }
template <CastKind Kind>
static QualType castElement(Sema &S, ExprResult &E, QualType Ty) { … }
static QualType handleFloatVectorBinOpConversion(
Sema &SemaRef, ExprResult &LHS, ExprResult &RHS, QualType LHSType,
QualType RHSType, QualType LElTy, QualType RElTy, bool IsCompAssign) { … }
static QualType handleIntegerVectorBinOpConversion(
Sema &SemaRef, ExprResult &LHS, ExprResult &RHS, QualType LHSType,
QualType RHSType, QualType LElTy, QualType RElTy, bool IsCompAssign) { … }
static CastKind getScalarCastKind(ASTContext &Ctx, QualType DestTy,
QualType SrcTy) { … }
QualType SemaHLSL::handleVectorBinOpConversion(ExprResult &LHS, ExprResult &RHS,
QualType LHSType,
QualType RHSType,
bool IsCompAssign) { … }
void SemaHLSL::emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS,
BinaryOperatorKind Opc) { … }
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) { … }
bool clang::CreateHLSLAttributedResourceType(
Sema &S, QualType Wrapped, ArrayRef<const Attr *> AttrList,
QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo) { … }
bool SemaHLSL::handleResourceTypeAttr(QualType T, const ParsedAttr &AL) { … }
QualType SemaHLSL::ProcessResourceTypeAttributes(QualType CurrentType) { … }
HLSLAttributedResourceLocInfo
SemaHLSL::TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT) { … }
static CXXRecordDecl *getRecordDeclFromVarDecl(VarDecl *VD) { … }
static const HLSLAttributedResourceType *
findAttributedResourceTypeOnField(VarDecl *VD) { … }
static bool ContainsResourceForRegisterType(Sema &S, const RecordType *RT,
RegisterType RegType) { … }
static void CheckContainsResourceForRegisterType(Sema &S,
SourceLocation &ArgLoc,
Decl *D, RegisterType RegType,
bool SpecifiedSpace) { … }
static void ValidateMultipleRegisterAnnotations(Sema &S, Decl *TheDecl,
RegisterType regType) { … }
static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
Decl *D, RegisterType RegType,
bool SpecifiedSpace) { … }
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) { … }
static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { … }
static bool CheckArgsTypesAreCorrect(
Sema *S, CallExpr *TheCall, QualType ExpectedType,
llvm::function_ref<bool(clang::QualType PassedType)> Check) { … }
static bool CheckAllArgsHaveFloatRepresentation(Sema *S, CallExpr *TheCall) { … }
static bool CheckFloatOrHalfRepresentations(Sema *S, CallExpr *TheCall) { … }
static bool CheckNoDoubleVectors(Sema *S, CallExpr *TheCall) { … }
static bool CheckFloatingOrIntRepresentation(Sema *S, CallExpr *TheCall) { … }
static bool CheckUnsignedIntRepresentation(Sema *S, CallExpr *TheCall) { … }
static void SetElementTypeAsReturnType(Sema *S, CallExpr *TheCall,
QualType ReturnType) { … }
static bool CheckScalarOrVector(Sema *S, CallExpr *TheCall, QualType Scalar,
unsigned ArgIndex) { … }
static bool CheckBoolSelect(Sema *S, CallExpr *TheCall) { … }
static bool CheckVectorSelect(Sema *S, CallExpr *TheCall) { … }
bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { … }
bool SemaHLSL::IsIntangibleType(clang::QualType QT) { … }
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) { … }