diff options
Diffstat (limited to 'clang/lib')
28 files changed, 153 insertions, 6 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4c0b2fe..995d017 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1384,6 +1384,12 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, #include "clang/Basic/OpenCLExtensionTypes.def" } + if (LangOpts.HLSL) { +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + InitBuiltinType(SingletonId, BuiltinType::Id); +#include "clang/Basic/HLSLIntangibleTypes.def" + } + if (Target.hasAArch64SVETypes() || (AuxTarget && AuxTarget->hasAArch64SVETypes())) { #define SVE_TYPE(Name, Id, SingletonId) \ @@ -2242,6 +2248,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = ALIGN; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + Width = 0; + Align = 8; + break; } break; case Type::ObjCObjectPointer: @@ -3355,6 +3366,10 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, case BuiltinType::Id: \ return; #include "clang/Basic/AArch64SVEACLETypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + return; +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::Dependent: llvm_unreachable("should never get here"); case BuiltinType::AMDGPUBufferRsrc: @@ -8552,6 +8567,8 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C, #define PPC_VECTOR_TYPE(Name, Id, Size) \ case BuiltinType::Id: #include "clang/Basic/PPCTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" #define BUILTIN_TYPE(KIND, ID) #define PLACEHOLDER_TYPE(KIND, ID) \ case BuiltinType::KIND: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 1032355..c835b72 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1151,6 +1151,10 @@ ExpectedType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) { case BuiltinType::Id: \ return Importer.getToContext().SingletonId; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + return Importer.getToContext().SingletonId; +#include "clang/Basic/HLSLIntangibleTypes.def" #define SHARED_SINGLETON_TYPE(Expansion) #define BUILTIN_TYPE(Id, SingletonId) \ case BuiltinType::Id: return Importer.getToContext().SingletonId; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 558e20e..d4b9095 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -11879,6 +11879,8 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T, #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" return GCCTypeClass::None; case BuiltinType::Dependent: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index ead5da4..aa89632 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -3428,6 +3428,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { Out << 'u' << type_name.size() << type_name; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + type_name = #Name; \ + Out << 'u' << type_name.size() << type_name; \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" } } diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 28f66e71..ed8d1cf 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -2741,6 +2741,13 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, break; #include "clang/Basic/WebAssemblyReferenceTypes.def" + +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + mangleArtificialTagType(TagTypeKind::Struct, #Name); \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" + #define SVE_TYPE(Name, Id, SingletonId) \ case BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" diff --git a/clang/lib/AST/NSAPI.cpp b/clang/lib/AST/NSAPI.cpp index 48d1763..3d1f848 100644 --- a/clang/lib/AST/NSAPI.cpp +++ b/clang/lib/AST/NSAPI.cpp @@ -455,6 +455,8 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::BoundMember: case BuiltinType::UnresolvedTemplate: case BuiltinType::Dependent: diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp index 3031d76..3c6cd2d 100644 --- a/clang/lib/AST/PrintfFormatString.cpp +++ b/clang/lib/AST/PrintfFormatString.cpp @@ -867,6 +867,8 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" #define SIGNED_TYPE(Id, SingletonId) #define UNSIGNED_TYPE(Id, SingletonId) #define FLOATING_TYPE(Id, SingletonId) diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 0456b5f..e89ce2e 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2447,6 +2447,9 @@ bool Type::isSizelessBuiltinType() const { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/WebAssemblyReferenceTypes.def" + // HLSL intangible types +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" return true; default: return false; @@ -3454,6 +3457,10 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const { case Id: \ return Name; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case Id: \ + return #Name; +#include "clang/Basic/HLSLIntangibleTypes.def" } llvm_unreachable("Invalid builtin type."); @@ -4786,6 +4793,8 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::BuiltinFn: case BuiltinType::NullPtr: case BuiltinType::IncompleteMatrixIdx: diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp index 33e6ccb..0d653d6 100644 --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/lib/AST/TypeLoc.cpp @@ -430,6 +430,8 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::BuiltinFn: case BuiltinType::IncompleteMatrixIdx: case BuiltinType::ArraySection: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index b49dee2..8d57c87 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -744,6 +744,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { case BuiltinType::Id: \ return getOrCreateStructPtrType("opencl_" #ExtType, Id##Ty); #include "clang/Basic/OpenCLExtensionTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + return getOrCreateStructPtrType(#Name, SingletonId); +#include "clang/Basic/HLSLIntangibleTypes.def" #define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index a0c419c..4ccff58 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -87,6 +87,9 @@ class CGDebugInfo { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + llvm::DIType *SingletonId = nullptr; +#include "clang/Basic/HLSLIntangibleTypes.def" /// Cache of previously constructed Types. llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache; diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index defc796..a2c3e76 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -15,6 +15,7 @@ #include "CGHLSLRuntime.h" #include "CGDebugInfo.h" #include "CodeGenModule.h" +#include "TargetInfo.h" #include "clang/AST/Decl.h" #include "clang/Basic/TargetOptions.h" #include "llvm/IR/Metadata.h" @@ -115,6 +116,16 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) { } // namespace +llvm::Type *CGHLSLRuntime::convertHLSLSpecificType(const Type *T) { + assert(T->isHLSLSpecificType() && "Not an HLSL specific type!"); + + // Check if the target has a specific translation for this type first. + if (llvm::Type *TargetTy = CGM.getTargetCodeGenInfo().getHLSLType(CGM, T)) + return TargetTy; + + llvm_unreachable("Generic handling of HLSL types is not supported."); +} + llvm::Triple::ArchType CGHLSLRuntime::getArch() { return CGM.getTarget().getTriple().getArch(); } diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h b/clang/lib/CodeGen/CGHLSLRuntime.h index 3f2dc0a..527e73a 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.h +++ b/clang/lib/CodeGen/CGHLSLRuntime.h @@ -113,6 +113,8 @@ public: CGHLSLRuntime(CodeGenModule &CGM) : CGM(CGM) {} virtual ~CGHLSLRuntime() {} + llvm::Type *convertHLSLSpecificType(const Type *T); + void annotateHLSLResource(const VarDecl *D, llvm::GlobalVariable *GV); void generateGlobalCtorDtorCalls(); diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index e0f567c..652a6d2 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -13,6 +13,7 @@ #include "CodeGenTypes.h" #include "CGCXXABI.h" #include "CGCall.h" +#include "CGHLSLRuntime.h" #include "CGOpenCLRuntime.h" #include "CGRecordLayout.h" #include "TargetInfo.h" @@ -593,6 +594,10 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { case BuiltinType::Id: \ return llvm::PointerType::get(getLLVMContext(), AS); #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + ResultType = CGM.getHLSLRuntime().convertHLSLSpecificType(Ty); + break; case BuiltinType::Dependent: #define BUILTIN_TYPE(Id, SingletonId) #define PLACEHOLDER_TYPE(Id, SingletonId) \ diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index cd76f84..e5d0cc4 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3630,6 +3630,8 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::ShortAccum: case BuiltinType::Accum: case BuiltinType::LongAccum: diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index 8f17c05..f38275c 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -418,6 +418,11 @@ public: return nullptr; } + /// Return an LLVM type that corresponds to a HLSL type + virtual llvm::Type *getHLSLType(CodeGenModule &CGM, const Type *T) const { + return nullptr; + } + static void setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI, llvm::Function &F); diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index ad78703..f00bc564 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -785,6 +785,11 @@ void USRGenerator::VisitType(QualType T) { Out << "@BT@" << #Name; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + Out << "@BT@" << #Name; \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::ShortAccum: Out << "@BT@ShortAccum"; break; case BuiltinType::Accum: diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 4a2d9a6..6c5f4ac 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -4837,6 +4837,13 @@ void Parser::ParseDeclarationSpecifiers( ParseHLSLQualifiers(DS.getAttributes()); continue; +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case tok::kw_##Name: \ + isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##Name, Loc, PrevSpec, \ + DiagID, Policy); \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" + case tok::less: // GCC ObjC supports types like "<SomeProtocol>" as a synonym for // "id<SomeProtocol>". This is hopelessly old fashioned and dangerous, @@ -5847,6 +5854,8 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const { case tok::kw___vector: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" // struct-or-union-specifier (C99) or class-specifier (C++) case tok::kw_class: @@ -5931,6 +5940,8 @@ bool Parser::isTypeSpecifierQualifier() { case tok::kw___vector: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" // struct-or-union-specifier (C99) or class-specifier (C++) case tok::kw_class: @@ -6275,6 +6286,8 @@ bool Parser::isDeclarationSpecifier( case tok::kw___write_only: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" case tok::kw___funcref: case tok::kw_groupshared: diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 826e7b6..b8e15b1 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1644,6 +1644,8 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind, case tok::kw__Sat: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" { if (!getLangOpts().CPlusPlus) { Diag(Tok, diag::err_expected_expression); diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index c0eae73..9bb0fff 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -2455,6 +2455,11 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { Policy); \ break; #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case tok::kw_##Name: \ + DS.SetTypeSpecType(DeclSpec::TST_##Name, Loc, PrevSpec, DiagID, Policy); \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" case tok::annot_decltype: case tok::kw_decltype: diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index 0142271..9f6b4f6 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -1807,6 +1807,8 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename, case tok::annot_pack_indexing_type: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" if (NextToken().is(tok::l_paren)) return TPResult::Ambiguous; @@ -1933,6 +1935,8 @@ bool Parser::isCXXDeclarationSpecifierAType() { case tok::kw__Sat: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" return true; case tok::kw_auto: diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 9a4d52d..5272786 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -377,6 +377,8 @@ bool Declarator::isDeclarationOfFunction() const { case TST_typename_pack_indexing: #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" return false; case TST_decltype_auto: @@ -608,6 +610,10 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T, case DeclSpec::TST_##ImgType##_t: \ return #ImgType "_t"; #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case DeclSpec::TST_##Name: \ + return #Name; +#include "clang/Basic/HLSLIntangibleTypes.def" case DeclSpec::TST_error: return "(error)"; } llvm_unreachable("Unknown typespec!"); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2cefa97..1f4bfa2 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8738,7 +8738,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { } if (!NewVD->hasLocalStorage() && T->isSizelessType() && - !T.isWebAssemblyReferenceType()) { + !T.isWebAssemblyReferenceType() && !T->isHLSLSpecificType()) { Diag(NewVD->getLocation(), diag::err_sizeless_nonlocal) << T; NewVD->setInvalidDecl(); return; @@ -18336,8 +18336,12 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, QualType EltTy = Context.getBaseElementType(T); if (!EltTy->isDependentType() && !EltTy->containsErrors()) { - if (RequireCompleteSizedType(Loc, EltTy, - diag::err_field_incomplete_or_sizeless)) { + bool isIncomplete = + LangOpts.HLSL // HLSL allows sizeless builtin types + ? RequireCompleteType(Loc, EltTy, diag::err_incomplete_type) + : RequireCompleteSizedType(Loc, EltTy, + diag::err_field_incomplete_or_sizeless); + if (isIncomplete) { // Fields of incomplete type force their record to be invalid. Record->setInvalidDecl(); InvalidDecl = true; @@ -18952,9 +18956,12 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, // elsewhere, after synthesized ivars are known. } } else if (!FDTy->isDependentType() && - RequireCompleteSizedType( - FD->getLocation(), FD->getType(), - diag::err_field_incomplete_or_sizeless)) { + (LangOpts.HLSL // HLSL allows sizeless builtin types + ? RequireCompleteType(FD->getLocation(), FD->getType(), + diag::err_incomplete_type) + : RequireCompleteSizedType( + FD->getLocation(), FD->getType(), + diag::err_field_incomplete_or_sizeless))) { // Incomplete type FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d0ba12f..b1b0d1c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6077,6 +6077,8 @@ static bool isPlaceholderToRemoveAsArg(QualType type) { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: #include "clang/AST/BuiltinTypes.def" @@ -20869,6 +20871,8 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) { #include "clang/Basic/WebAssemblyReferenceTypes.def" #define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: #define PLACEHOLDER_TYPE(Id, SingletonId) #include "clang/AST/BuiltinTypes.def" diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 3d4ccaf..c45384f 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -935,6 +935,8 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) { case TST_BFloat16: #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" case TST_unknown_anytype: case TST_error: break; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 6fa39cd..df53748 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1357,6 +1357,12 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { break; #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case DeclSpec::TST_##Name: \ + Result = Context.SingletonId; \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" + case DeclSpec::TST_error: Result = Context.IntTy; declarator.setInvalidType(true); diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp index 444a8a3..f30642f 100644 --- a/clang/lib/Serialization/ASTCommon.cpp +++ b/clang/lib/Serialization/ASTCommon.cpp @@ -263,6 +263,11 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) { ID = PREDEF_TYPE_##Id##_ID; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ + ID = PREDEF_TYPE_##Id##_ID; \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" case BuiltinType::BuiltinFn: ID = PREDEF_TYPE_BUILTIN_FN; break; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 657ea30..fccdece 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -7439,6 +7439,11 @@ QualType ASTReader::GetType(TypeID ID) { T = Context.SingletonId; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case PREDEF_TYPE_##Id##_ID: \ + T = Context.SingletonId; \ + break; +#include "clang/Basic/HLSLIntangibleTypes.def" } assert(!T.isNull() && "Unknown predefined type"); |