diff --git a/include/dxc/DxilContainer/DxcContainerBuilder.h b/include/dxc/DxilContainer/DxcContainerBuilder.h index 316467e9da..1cffaa63ba 100644 --- a/include/dxc/DxilContainer/DxcContainerBuilder.h +++ b/include/dxc/DxilContainer/DxcContainerBuilder.h @@ -25,10 +25,15 @@ namespace hlsl { class DxcContainerBuilder : public IDxcContainerBuilder { public: - HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pDxilContainerHeader) override; // Loads DxilContainer to the builder - HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) override; // Add the given part with fourCC - HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) override; // Remove the part with fourCC - HRESULT STDMETHODCALLTYPE SerializeContainer(_Out_ IDxcOperationResult **ppResult) override; // Builds a container of the given container builder state + // Loads DxilContainer to the builder + HRESULT STDMETHODCALLTYPE Load(IDxcBlob *pDxilContainerHeader) override; + // Add the given part with fourCC + HRESULT STDMETHODCALLTYPE AddPart(UINT32 fourCC, IDxcBlob *pSource) override; + // Remove the part with fourCC + HRESULT STDMETHODCALLTYPE RemovePart(UINT32 fourCC) override; + // Builds a container of the given container builder state + HRESULT STDMETHODCALLTYPE + SerializeContainer(IDxcOperationResult **ppResult) override; DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL() DXC_MICROCOM_TM_CTOR(DxcContainerBuilder) @@ -65,4 +70,4 @@ class DxcContainerBuilder : public IDxcContainerBuilder { HRESULT UpdateOffsetTable(AbstractMemoryStream *pStream); HRESULT UpdateParts(AbstractMemoryStream *pStream); void AddPart(DxilPart&& part); -}; \ No newline at end of file +}; diff --git a/include/dxc/DxilContainer/DxilContainer.h b/include/dxc/DxilContainer/DxilContainer.h index 78871835c4..e4e1cc4c7f 100644 --- a/include/dxc/DxilContainer/DxilContainer.h +++ b/include/dxc/DxilContainer/DxilContainer.h @@ -444,7 +444,7 @@ const DxilProgramHeader * GetDxilProgramHeader(const DxilContainerHeader *pHeader, DxilFourCC fourCC); /// Initializes container with the specified values. -void InitDxilContainer(_Out_ DxilContainerHeader *pHeader, uint32_t partCount, +void InitDxilContainer(DxilContainerHeader *pHeader, uint32_t partCount, uint32_t containerSizeInBytes); /// Checks whether pHeader claims by signature to be a DXIL container @@ -587,7 +587,8 @@ inline bool IsDxilShaderDebugNameValid(const DxilPartHeader *pPart) { } inline bool GetDxilShaderDebugName(const DxilPartHeader *pDebugNamePart, - const char **ppUtf8Name, _Out_opt_ uint16_t *pUtf8NameLen) { + const char **ppUtf8Name, + uint16_t *pUtf8NameLen) { *ppUtf8Name = nullptr; if (!IsDxilShaderDebugNameValid(pDebugNamePart)) { return false; @@ -627,7 +628,7 @@ inline SerializeDxilFlags operator~(SerializeDxilFlags l) { void CreateDxcContainerReflection(IDxcContainerReflection **ppResult); // Converts uint32_t partKind to char array object. -inline char * PartKindToCharArray(uint32_t partKind, _Out_writes_(5) char* pText) { +inline char *PartKindToCharArray(uint32_t partKind, char *pText) { pText[0] = (char)((partKind & 0x000000FF) >> 0); pText[1] = (char)((partKind & 0x0000FF00) >> 8); pText[2] = (char)((partKind & 0x00FF0000) >> 16); diff --git a/include/dxc/DxilContainer/DxilContainerReader.h b/include/dxc/DxilContainer/DxilContainerReader.h index 78803eec52..7f5bff5d8c 100644 --- a/include/dxc/DxilContainer/DxilContainerReader.h +++ b/include/dxc/DxilContainer/DxilContainerReader.h @@ -51,13 +51,14 @@ namespace hlsl { // Minor = DXBC_MAJOR_VERSION // // Returns S_OK or E_FAIL - HRESULT Load(_In_ const void* pContainer, _In_ uint32_t containerSizeInBytes); + HRESULT Load(const void *pContainer, uint32_t containerSizeInBytes); - HRESULT GetVersion(_Out_ DxilContainerVersion *pResult); - HRESULT GetPartCount(_Out_ uint32_t *pResult); - HRESULT GetPartContent(uint32_t idx, _Outptr_ const void **ppResult, _Out_ uint32_t *pResultSize = nullptr); - HRESULT GetPartFourCC(uint32_t idx, _Out_ uint32_t *pResult); - HRESULT FindFirstPartKind(uint32_t kind, _Out_ uint32_t *pResult); + HRESULT GetVersion(DxilContainerVersion *pResult); + HRESULT GetPartCount(uint32_t *pResult); + HRESULT GetPartContent(uint32_t idx, const void **ppResult, + uint32_t *pResultSize = nullptr); + HRESULT GetPartFourCC(uint32_t idx, uint32_t *pResult); + HRESULT FindFirstPartKind(uint32_t kind, uint32_t *pResult); private: const void* m_pContainer = nullptr; diff --git a/include/dxc/DxilContainer/DxilPipelineStateValidation.h b/include/dxc/DxilContainer/DxilPipelineStateValidation.h index 0dfbf9656b..5ea848971f 100644 --- a/include/dxc/DxilContainer/DxilPipelineStateValidation.h +++ b/include/dxc/DxilContainer/DxilPipelineStateValidation.h @@ -194,7 +194,7 @@ struct PSVStringTable { PSVStringTable() : Table(nullptr), Size(0) {} PSVStringTable(const char *table, uint32_t size) : Table(table), Size(size) {} const char *Get(uint32_t offset) const { - _Analysis_assume_(offset < Size && Table && Table[Size-1] == '\0'); + assert(offset < Size && Table && Table[Size - 1] == '\0'); return Table + offset; } }; @@ -279,7 +279,7 @@ struct PSVSemanticIndexTable { PSVSemanticIndexTable() : Table(nullptr), Entries(0) {} PSVSemanticIndexTable(const uint32_t *table, uint32_t entries) : Table(table), Entries(entries) {} const uint32_t *Get(uint32_t offset) const { - _Analysis_assume_(offset < Entries && Table); + assert(offset < Entries && Table); return Table + offset; } }; @@ -526,7 +526,7 @@ class DxilPipelineStateValidation _T *GetRecord(void *pRecords, uint32_t recordSize, uint32_t numRecords, uint32_t index) const { if (pRecords && index < numRecords && sizeof(_T) <= recordSize) { - __analysis_assume((size_t)index * (size_t)recordSize <= UINT_MAX); + assert((size_t)index * (size_t)recordSize <= UINT_MAX); return reinterpret_cast<_T *>(reinterpret_cast(pRecords) + (index * recordSize)); } diff --git a/include/dxc/DxilContainer/DxilRuntimeReflection.h b/include/dxc/DxilContainer/DxilRuntimeReflection.h index 2c4fefadd4..151a5d2d12 100644 --- a/include/dxc/DxilContainer/DxilRuntimeReflection.h +++ b/include/dxc/DxilContainer/DxilRuntimeReflection.h @@ -203,8 +203,6 @@ class StringTableReader { m_size = size; } const char *Get(uint32_t offset) const { - _Analysis_assume_(offset < m_size && m_table && - m_table[m_size - 1] == '\0'); (void)m_size; // avoid unused private warning if use above is ignored. return m_table + offset; } @@ -224,8 +222,6 @@ class RawBytesReader { } uint32_t Size() const { return m_size; } const void *Get(uint32_t offset) const { - _Analysis_assume_(offset < m_size && m_table); - (void)m_size; // avoid unused private warning if use above is ignored. return (const void*)(((const char*)m_table) + offset); } }; diff --git a/include/dxc/DxilRootSignature/DxilRootSignature.h b/include/dxc/DxilRootSignature/DxilRootSignature.h index d3104f366e..4b9ce04ae2 100644 --- a/include/dxc/DxilRootSignature/DxilRootSignature.h +++ b/include/dxc/DxilRootSignature/DxilRootSignature.h @@ -245,7 +245,7 @@ struct DxilDescriptorRange { }; struct DxilRootDescriptorTable { uint32_t NumDescriptorRanges; - _Field_size_full_(NumDescriptorRanges) DxilDescriptorRange *pDescriptorRanges; + DxilDescriptorRange *pDescriptorRanges; }; struct DxilRootConstants { uint32_t ShaderRegister; @@ -280,7 +280,7 @@ struct DxilDescriptorRange1 { }; struct DxilRootDescriptorTable1 { uint32_t NumDescriptorRanges; - _Field_size_full_(NumDescriptorRanges) DxilDescriptorRange1 *pDescriptorRanges; + DxilDescriptorRange1 *pDescriptorRanges; }; struct DxilRootParameter1 { DxilRootParameterType ParameterType; @@ -293,9 +293,9 @@ struct DxilRootParameter1 { }; struct DxilRootSignatureDesc { uint32_t NumParameters; - _Field_size_full_(NumParameters) DxilRootParameter *pParameters; + DxilRootParameter *pParameters; uint32_t NumStaticSamplers; - _Field_size_full_(NumStaticSamplers) DxilStaticSamplerDesc *pStaticSamplers; + DxilStaticSamplerDesc *pStaticSamplers; DxilRootSignatureFlags Flags; }; struct DxilStaticSamplerDesc { @@ -315,9 +315,9 @@ struct DxilStaticSamplerDesc { }; struct DxilRootSignatureDesc1 { uint32_t NumParameters; - _Field_size_full_(NumParameters) DxilRootParameter1 *pParameters; + DxilRootParameter1 *pParameters; uint32_t NumStaticSamplers; - _Field_size_full_(NumStaticSamplers) DxilStaticSamplerDesc *pStaticSamplers; + DxilStaticSamplerDesc *pStaticSamplers; DxilRootSignatureFlags Flags; }; struct DxilVersionedRootSignatureDesc { @@ -365,25 +365,23 @@ void ConvertRootSignature(const DxilVersionedRootSignatureDesc* pRootSignatureIn DxilRootSignatureVersion RootSignatureVersionOut, const DxilVersionedRootSignatureDesc ** ppRootSignatureOut); -void SerializeRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature, - _Outptr_ IDxcBlob **ppBlob, _Outptr_ IDxcBlobEncoding **ppErrorBlob, - bool bAllowReservedRegisterSpace); +void SerializeRootSignature( + const DxilVersionedRootSignatureDesc *pRootSignature, IDxcBlob **ppBlob, + IDxcBlobEncoding **ppErrorBlob, bool bAllowReservedRegisterSpace); -void DeserializeRootSignature(_In_reads_bytes_(SrcDataSizeInBytes) const void *pSrcData, - _In_ uint32_t SrcDataSizeInBytes, - _Out_ const DxilVersionedRootSignatureDesc **ppRootSignature); +void DeserializeRootSignature( + const void *pSrcData, uint32_t SrcDataSizeInBytes, + const DxilVersionedRootSignatureDesc **ppRootSignature); // Takes PSV - pipeline state validation data, not shader container. -bool VerifyRootSignatureWithShaderPSV(_In_ const DxilVersionedRootSignatureDesc *pDesc, - _In_ DXIL::ShaderKind ShaderKind, - _In_reads_bytes_(PSVSize) const void *pPSVData, - _In_ uint32_t PSVSize, - _In_ llvm::raw_ostream &DiagStream); +bool VerifyRootSignatureWithShaderPSV( + const DxilVersionedRootSignatureDesc *pDesc, DXIL::ShaderKind ShaderKind, + const void *pPSVData, uint32_t PSVSize, llvm::raw_ostream &DiagStream); // standalone verification -bool VerifyRootSignature(_In_ const DxilVersionedRootSignatureDesc *pDesc, - _In_ llvm::raw_ostream &DiagStream, - _In_ bool bAllowReservedRegisterSpace); +bool VerifyRootSignature(const DxilVersionedRootSignatureDesc *pDesc, + llvm::raw_ostream &DiagStream, + bool bAllowReservedRegisterSpace); class DxilVersionedRootSignature { DxilVersionedRootSignatureDesc *m_pRootSignature; diff --git a/include/dxc/HLSL/DxilValidation.h b/include/dxc/HLSL/DxilValidation.h index 6a9cdd1bee..960adafb53 100644 --- a/include/dxc/HLSL/DxilValidation.h +++ b/include/dxc/HLSL/DxilValidation.h @@ -29,77 +29,66 @@ namespace hlsl { #include "dxc/HLSL/DxilValidation.inc" const char *GetValidationRuleText(ValidationRule value); -void GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor); -HRESULT ValidateDxilModule(_In_ llvm::Module *pModule, - _In_opt_ llvm::Module *pDebugModule); +void GetValidationVersion(unsigned *pMajor, unsigned *pMinor); +HRESULT ValidateDxilModule(llvm::Module *pModule, llvm::Module *pDebugModule); // DXIL Container Verification Functions (return false on failure) -bool VerifySignatureMatches(_In_ llvm::Module *pModule, +bool VerifySignatureMatches(llvm::Module *pModule, hlsl::DXIL::SignatureKind SigKind, - _In_reads_bytes_(SigSize) const void *pSigData, - _In_ uint32_t SigSize); + const void *pSigData, uint32_t SigSize); // PSV = data for Pipeline State Validation -bool VerifyPSVMatches(_In_ llvm::Module *pModule, - _In_reads_bytes_(PSVSize) const void *pPSVData, - _In_ uint32_t PSVSize); +bool VerifyPSVMatches(llvm::Module *pModule, const void *pPSVData, + uint32_t PSVSize); // PSV = data for Pipeline State Validation -bool VerifyRDATMatches(_In_ llvm::Module *pModule, - _In_reads_bytes_(RDATSize) const void *pRDATData, - _In_ uint32_t RDATSize); +bool VerifyRDATMatches(llvm::Module *pModule, const void *pRDATData, + uint32_t RDATSize); -bool VerifyFeatureInfoMatches(_In_ llvm::Module *pModule, - _In_reads_bytes_(FeatureInfoSize) const void *pFeatureInfoData, - _In_ uint32_t FeatureInfoSize); +bool VerifyFeatureInfoMatches(llvm::Module *pModule, + const void *pFeatureInfoData, + uint32_t FeatureInfoSize); // Validate the container parts, assuming supplied module is valid, loaded from the container provided struct DxilContainerHeader; -HRESULT ValidateDxilContainerParts(_In_ llvm::Module *pModule, - _In_opt_ llvm::Module *pDebugModule, - _In_reads_bytes_(ContainerSize) const DxilContainerHeader *pContainer, - _In_ uint32_t ContainerSize); +HRESULT ValidateDxilContainerParts(llvm::Module *pModule, + llvm::Module *pDebugModule, + const DxilContainerHeader *pContainer, + uint32_t ContainerSize); // Loads module, validating load, but not module. -HRESULT ValidateLoadModule(_In_reads_bytes_(ILLength) const char *pIL, - _In_ uint32_t ILLength, - _In_ std::unique_ptr &pModule, - _In_ llvm::LLVMContext &Ctx, - _In_ llvm::raw_ostream &DiagStream, - _In_ unsigned bLazyLoad); +HRESULT ValidateLoadModule(const char *pIL, uint32_t ILLength, + std::unique_ptr &pModule, + llvm::LLVMContext &Ctx, + llvm::raw_ostream &DiagStream, unsigned bLazyLoad); // Loads module from container, validating load, but not module. HRESULT ValidateLoadModuleFromContainer( - _In_reads_bytes_(ContainerSize) const void *pContainer, - _In_ uint32_t ContainerSize, _In_ std::unique_ptr &pModule, - _In_ std::unique_ptr &pDebugModule, - _In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx, - _In_ llvm::raw_ostream &DiagStream); + const void *pContainer, uint32_t ContainerSize, + std::unique_ptr &pModule, + std::unique_ptr &pDebugModule, llvm::LLVMContext &Ctx, + llvm::LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream); // Lazy loads module from container, validating load, but not module. HRESULT ValidateLoadModuleFromContainerLazy( - _In_reads_bytes_(ContainerSize) const void *pContainer, - _In_ uint32_t ContainerSize, _In_ std::unique_ptr &pModule, - _In_ std::unique_ptr &pDebugModule, - _In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx, - _In_ llvm::raw_ostream &DiagStream); + const void *pContainer, uint32_t ContainerSize, + std::unique_ptr &pModule, + std::unique_ptr &pDebugModule, llvm::LLVMContext &Ctx, + llvm::LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream); // Load and validate Dxil module from bitcode. -HRESULT ValidateDxilBitcode(_In_reads_bytes_(ILLength) const char *pIL, - _In_ uint32_t ILLength, - _In_ llvm::raw_ostream &DiagStream); +HRESULT ValidateDxilBitcode(const char *pIL, uint32_t ILLength, + llvm::raw_ostream &DiagStream); // Full container validation, including ValidateDxilModule -HRESULT ValidateDxilContainer(_In_reads_bytes_(ContainerSize) const void *pContainer, - _In_ uint32_t ContainerSize, - _In_ llvm::raw_ostream &DiagStream); +HRESULT ValidateDxilContainer(const void *pContainer, uint32_t ContainerSize, + llvm::raw_ostream &DiagStream); // Full container validation, including ValidateDxilModule, with debug module -HRESULT ValidateDxilContainer(_In_reads_bytes_(ContainerSize) const void *pContainer, - _In_ uint32_t ContainerSize, +HRESULT ValidateDxilContainer(const void *pContainer, uint32_t ContainerSize, const void *pOptDebugBitcode, uint32_t OptDebugBitcodeSize, - _In_ llvm::raw_ostream &DiagStream); + llvm::raw_ostream &DiagStream); class PrintDiagnosticContext { private: diff --git a/include/dxc/Support/DxcLangExtensionsCommonHelper.h b/include/dxc/Support/DxcLangExtensionsCommonHelper.h index bea7543384..39f015467a 100644 --- a/include/dxc/Support/DxcLangExtensionsCommonHelper.h +++ b/include/dxc/Support/DxcLangExtensionsCommonHelper.h @@ -93,8 +93,7 @@ class DxcLangExtensionsCommonHelper { return RegisterIntoVector(name, m_defines); } - HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable* pTable) - { + HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(IDxcIntrinsicTable *pTable) { try { IFTPTR(pTable); LPCSTR tableName = nullptr; @@ -115,7 +114,8 @@ class DxcLangExtensionsCommonHelper { // Set the validator used to validate semantic defines. // Only one validator stored and used to run validation. - HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) { + HRESULT STDMETHODCALLTYPE + SetSemanticDefineValidator(IDxcSemanticDefineValidator *pValidator) { if (pValidator == nullptr) return E_POINTER; @@ -228,38 +228,43 @@ class DxcLangExtensionsCommonHelper { // Use this macro to embed an implementation that will delegate to a field. // Note that QueryInterface still needs to return the vtable. -#define DXC_LANGEXTENSIONS_HELPER_IMPL(_helper_field_) \ - HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable *pTable) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).RegisterIntrinsicTable(pTable); \ - } \ - HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).RegisterSemanticDefine(name); \ - } \ - HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).RegisterSemanticDefineExclusion(name); \ - } \ - HRESULT STDMETHODCALLTYPE RegisterNonOptSemanticDefine(LPCWSTR name) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).RegisterNonOptSemanticDefine(name); \ - } \ - HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).RegisterDefine(name); \ - } \ - HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).SetSemanticDefineValidator(pValidator); \ - } \ - HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).SetSemanticDefineMetaDataName(name); \ - } \ - HRESULT STDMETHODCALLTYPE SetTargetTriple(LPCSTR name) override { \ - DxcThreadMalloc TM(m_pMalloc); \ - return (_helper_field_).SetTargetTriple(name); \ - } \ +#define DXC_LANGEXTENSIONS_HELPER_IMPL(_helper_field_) \ + HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(IDxcIntrinsicTable *pTable) \ + override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).RegisterIntrinsicTable(pTable); \ + } \ + HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).RegisterSemanticDefine(name); \ + } \ + HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) \ + override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).RegisterSemanticDefineExclusion(name); \ + } \ + HRESULT STDMETHODCALLTYPE RegisterNonOptSemanticDefine(LPCWSTR name) \ + override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).RegisterNonOptSemanticDefine(name); \ + } \ + HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).RegisterDefine(name); \ + } \ + HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator( \ + IDxcSemanticDefineValidator *pValidator) override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).SetSemanticDefineValidator(pValidator); \ + } \ + HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) \ + override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).SetSemanticDefineMetaDataName(name); \ + } \ + HRESULT STDMETHODCALLTYPE SetTargetTriple(LPCSTR name) override { \ + DxcThreadMalloc TM(m_pMalloc); \ + return (_helper_field_).SetTargetTriple(name); \ + } } // namespace hlsl diff --git a/include/dxc/Support/DxcLangExtensionsHelper.h b/include/dxc/Support/DxcLangExtensionsHelper.h index 2b04ed945e..da113f19a8 100644 --- a/include/dxc/Support/DxcLangExtensionsHelper.h +++ b/include/dxc/Support/DxcLangExtensionsHelper.h @@ -79,8 +79,8 @@ inline bool IsMacroMatch(StringRef name, const std::string &mask) { // Return the collection of semantic defines parsed by the compiler instance. ParsedSemanticDefineList - CollectSemanticDefinesParsedByCompiler(clang::CompilerInstance &compiler, - _In_ DxcLangExtensionsHelper *helper); +CollectSemanticDefinesParsedByCompiler(clang::CompilerInstance &compiler, + DxcLangExtensionsHelper *helper); } // namespace hlsl diff --git a/include/dxc/Support/FileIOHelper.h b/include/dxc/Support/FileIOHelper.h index 1b7744d25c..8a56fd0747 100644 --- a/include/dxc/Support/FileIOHelper.h +++ b/include/dxc/Support/FileIOHelper.h @@ -30,17 +30,17 @@ IMalloc *GetGlobalHeapMalloc() throw(); class CDxcThreadMallocAllocator { public: - _Ret_maybenull_ _Post_writable_byte_size_(nBytes) _ATL_DECLSPEC_ALLOCATOR - static void *Reallocate(_In_ void *p, _In_ size_t nBytes) throw() { + _ATL_DECLSPEC_ALLOCATOR + static void *Reallocate(void *p, size_t nBytes) throw() { return DxcGetThreadMallocNoRef()->Realloc(p, nBytes); } - _Ret_maybenull_ _Post_writable_byte_size_(nBytes) _ATL_DECLSPEC_ALLOCATOR - static void *Allocate(_In_ size_t nBytes) throw() { + _ATL_DECLSPEC_ALLOCATOR + static void *Allocate(size_t nBytes) throw() { return DxcGetThreadMallocNoRef()->Alloc(nBytes); } - static void Free(_In_ void *p) throw() { + static void Free(void *p) throw() { return DxcGetThreadMallocNoRef()->Free(p); } }; @@ -55,10 +55,8 @@ class CDxcTMHeapPtr : { } - explicit CDxcTMHeapPtr(_In_ T* pData) throw() : - CHeapPtr(pData) - { - } + explicit CDxcTMHeapPtr(T *pData) throw() + : CHeapPtr(pData) {} }; // Like CComHeapPtr, but with a stateful allocator. @@ -82,7 +80,7 @@ class CDxcMallocHeapPtr IMalloc* GetMallocNoRef() const throw() { return m_pMalloc.p; } - bool Allocate(_In_ SIZE_T ElementCount) throw() { + bool Allocate(SIZE_T ElementCount) throw() { ATLASSERT(m_pData == NULL); SIZE_T nBytes = ElementCount * sizeof(T); m_pData = static_cast(m_pMalloc->Alloc(nBytes)); @@ -91,14 +89,14 @@ class CDxcMallocHeapPtr return true; } - void AllocateBytes(_In_ SIZE_T ByteCount) throw() { + void AllocateBytes(SIZE_T ByteCount) throw() { if (m_pData) m_pMalloc->Free(m_pData); m_pData = static_cast(m_pMalloc->Alloc(ByteCount)); } // Attach to an existing pointer (takes ownership) - void Attach(_In_ T *pData) throw() { + void Attach(T *pData) throw() { m_pMalloc->Free(m_pData); m_pData = pData; } @@ -117,22 +115,17 @@ class CDxcMallocHeapPtr } }; -HRESULT ReadBinaryFile(_In_opt_ IMalloc *pMalloc, - _In_z_ LPCWSTR pFileName, - _Outptr_result_bytebuffer_(*pDataSize) void **ppData, - _Out_ DWORD *pDataSize) throw(); -HRESULT ReadBinaryFile(_In_z_ LPCWSTR pFileName, - _Outptr_result_bytebuffer_(*pDataSize) void **ppData, - _Out_ DWORD *pDataSize) throw(); -HRESULT WriteBinaryFile(_In_z_ LPCWSTR pFileName, - _In_reads_bytes_(DataSize) const void *pData, - _In_ DWORD DataSize) throw(); +HRESULT ReadBinaryFile(IMalloc *pMalloc, LPCWSTR pFileName, void **ppData, + DWORD *pDataSize) throw(); +HRESULT ReadBinaryFile(LPCWSTR pFileName, void **ppData, + DWORD *pDataSize) throw(); +HRESULT WriteBinaryFile(LPCWSTR pFileName, const void *pData, + DWORD DataSize) throw(); /////////////////////////////////////////////////////////////////////////////// // Blob and encoding manipulation functions. -UINT32 DxcCodePageFromBytes(_In_count_(byteLen) const char *bytes, - size_t byteLen) throw(); +UINT32 DxcCodePageFromBytes(const char *bytes, size_t byteLen) throw(); // More general create blob functions, used by other functions // Null pMalloc means use current thread malloc. @@ -154,77 +147,73 @@ HRESULT DxcCreateBlobEncodingFromBlob( IMalloc *pMalloc, IDxcBlobEncoding **ppBlobEncoding) throw(); // Load files -HRESULT DxcCreateBlobFromFile(_In_opt_ IMalloc *pMalloc, LPCWSTR pFileName, - _In_opt_ UINT32 *pCodePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw(); +HRESULT DxcCreateBlobFromFile(IMalloc *pMalloc, LPCWSTR pFileName, + UINT32 *pCodePage, + IDxcBlobEncoding **pBlobEncoding) throw(); -HRESULT DxcCreateBlobFromFile(LPCWSTR pFileName, _In_opt_ UINT32 *pCodePage, - _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) throw(); +HRESULT DxcCreateBlobFromFile(LPCWSTR pFileName, UINT32 *pCodePage, + IDxcBlobEncoding **ppBlobEncoding) throw(); // Given a blob, creates a subrange view. -HRESULT DxcCreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, - UINT32 length, - _COM_Outptr_ IDxcBlob **ppResult) throw(); +HRESULT DxcCreateBlobFromBlob(IDxcBlob *pBlob, UINT32 offset, UINT32 length, + IDxcBlob **ppResult) throw(); // Creates a blob wrapping a buffer to be freed with the provided IMalloc HRESULT -DxcCreateBlobOnMalloc(_In_bytecount_(size) LPCVOID pData, _In_ IMalloc* pIMalloc, - UINT32 size, _COM_Outptr_ IDxcBlob **ppResult) throw(); +DxcCreateBlobOnMalloc(LPCVOID pData, IMalloc *pIMalloc, UINT32 size, + IDxcBlob **ppResult) throw(); // Creates a blob with a copy of the provided data HRESULT -DxcCreateBlobOnHeapCopy(_In_bytecount_(size) LPCVOID pData, UINT32 size, - _COM_Outptr_ IDxcBlob **ppResult) throw(); +DxcCreateBlobOnHeapCopy(LPCVOID pData, UINT32 size, + IDxcBlob **ppResult) throw(); // Given a blob, creates a new instance with a specific code page set. HRESULT -DxcCreateBlobWithEncodingSet(_In_ IDxcBlob *pBlob, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) throw(); +DxcCreateBlobWithEncodingSet(IDxcBlob *pBlob, UINT32 codePage, + IDxcBlobEncoding **ppBlobEncoding) throw(); HRESULT -DxcCreateBlobWithEncodingSet( - _In_ IMalloc *pMalloc, _In_ IDxcBlob *pBlob, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) throw(); +DxcCreateBlobWithEncodingSet(IMalloc *pMalloc, IDxcBlob *pBlob, UINT32 codePage, + IDxcBlobEncoding **ppBlobEncoding) throw(); // Creates a blob around encoded text without ownership transfer -HRESULT DxcCreateBlobWithEncodingFromPinned( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw(); +HRESULT +DxcCreateBlobWithEncodingFromPinned(LPCVOID pText, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) throw(); -HRESULT DxcCreateBlobFromPinned( - _In_bytecount_(size) LPCVOID pText, UINT32 size, - _COM_Outptr_ IDxcBlob **pBlob) throw(); +HRESULT DxcCreateBlobFromPinned(LPCVOID pText, UINT32 size, + IDxcBlob **pBlob) throw(); HRESULT -DxcCreateBlobWithEncodingFromStream( - IStream *pStream, bool newInstanceAlways, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw(); +DxcCreateBlobWithEncodingFromStream(IStream *pStream, bool newInstanceAlways, + UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) throw(); // Creates a blob with a copy of the encoded text HRESULT -DxcCreateBlobWithEncodingOnHeapCopy( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw(); +DxcCreateBlobWithEncodingOnHeapCopy(LPCVOID pText, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) throw(); // Creates a blob wrapping encoded text to be freed with the provided IMalloc HRESULT -DxcCreateBlobWithEncodingOnMalloc( - _In_bytecount_(size) LPCVOID pText, _In_ IMalloc *pIMalloc, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw(); +DxcCreateBlobWithEncodingOnMalloc(LPCVOID pText, IMalloc *pIMalloc, UINT32 size, + UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) throw(); // Creates a blob with a copy of encoded text, allocated using the provided IMalloc HRESULT -DxcCreateBlobWithEncodingOnMallocCopy( - _In_ IMalloc *pIMalloc, _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw(); +DxcCreateBlobWithEncodingOnMallocCopy(IMalloc *pIMalloc, LPCVOID pText, + UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) throw(); -HRESULT DxcGetBlobAsUtf8(_In_ IDxcBlob *pBlob, _In_ IMalloc *pMalloc, - _COM_Outptr_ IDxcBlobUtf8 **pBlobEncoding, +HRESULT DxcGetBlobAsUtf8(IDxcBlob *pBlob, IMalloc *pMalloc, + IDxcBlobUtf8 **pBlobEncoding, UINT32 defaultCodePage = CP_ACP) throw(); HRESULT -DxcGetBlobAsWide(_In_ IDxcBlob *pBlob, _In_ IMalloc *pMalloc, - _COM_Outptr_ IDxcBlobWide **pBlobEncoding) throw(); +DxcGetBlobAsWide(IDxcBlob *pBlob, IMalloc *pMalloc, + IDxcBlobWide **pBlobEncoding) throw(); -bool IsBlobNullOrEmpty(_In_opt_ IDxcBlob *pBlob) throw(); +bool IsBlobNullOrEmpty(IDxcBlob *pBlob) throw(); /////////////////////////////////////////////////////////////////////////////// // Stream implementations. @@ -236,9 +225,11 @@ class AbstractMemoryStream : public IStream { virtual UINT64 GetPosition() throw() = 0; virtual HRESULT Reserve(ULONG targetSize) throw() = 0; }; -HRESULT CreateMemoryStream(_In_ IMalloc *pMalloc, _COM_Outptr_ AbstractMemoryStream** ppResult) throw(); -HRESULT CreateReadOnlyBlobStream(_In_ IDxcBlob *pSource, _COM_Outptr_ IStream** ppResult) throw(); -HRESULT CreateFixedSizeMemoryStream(_In_ LPBYTE pBuffer, size_t size, _COM_Outptr_ AbstractMemoryStream** ppResult) throw(); +HRESULT CreateMemoryStream(IMalloc *pMalloc, + AbstractMemoryStream **ppResult) throw(); +HRESULT CreateReadOnlyBlobStream(IDxcBlob *pSource, IStream **ppResult) throw(); +HRESULT CreateFixedSizeMemoryStream(LPBYTE pBuffer, size_t size, + AbstractMemoryStream **ppResult) throw(); template HRESULT WriteStreamValue(IStream *pStream, const T& value) { diff --git a/include/dxc/Support/Global.h b/include/dxc/Support/Global.h index d8e047db45..2c372aad08 100644 --- a/include/dxc/Support/Global.h +++ b/include/dxc/Support/Global.h @@ -111,20 +111,26 @@ void CheckLLVMErrorCode(const std::error_code &ec); #define IFTBOOLMSG(x, y, msg) { if (!(x)) throw ::hlsl::Exception(y, msg); } // Propagate an C++ exception into an HRESULT. -#define CATCH_CPP_ASSIGN_HRESULT() \ - catch (std::bad_alloc&) { hr = E_OUTOFMEMORY; } \ - catch (hlsl::Exception& _hlsl_exception_) { \ - _Analysis_assume_(DXC_FAILED(_hlsl_exception_.hr)); \ - hr = _hlsl_exception_.hr; \ - } \ - catch (...) { hr = E_FAIL; } -#define CATCH_CPP_RETURN_HRESULT() \ - catch (std::bad_alloc&) { return E_OUTOFMEMORY; } \ - catch (hlsl::Exception& _hlsl_exception_) { \ - _Analysis_assume_(DXC_FAILED(_hlsl_exception_.hr)); \ - return _hlsl_exception_.hr; \ - } \ - catch (...) { return E_FAIL; } +#define CATCH_CPP_ASSIGN_HRESULT() \ + catch (std::bad_alloc &) { \ + hr = E_OUTOFMEMORY; \ + } \ + catch (hlsl::Exception & _hlsl_exception_) { \ + hr = _hlsl_exception_.hr; \ + } \ + catch (...) { \ + hr = E_FAIL; \ + } +#define CATCH_CPP_RETURN_HRESULT() \ + catch (std::bad_alloc &) { \ + return E_OUTOFMEMORY; \ + } \ + catch (hlsl::Exception & _hlsl_exception_) { \ + return _hlsl_exception_.hr; \ + } \ + catch (...) { \ + return E_FAIL; \ + } template T *VerifyNullAndThrow(T *p) { if (p == nullptr) @@ -135,7 +141,8 @@ template T *VerifyNullAndThrow(T *p) { #ifdef _MSC_VER -extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(_In_opt_ const char *msg); +extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( + const char *msg); inline void OutputDebugBytes(const void *ptr, size_t len) { const char digits[] = "0123456789abcdef"; @@ -166,7 +173,7 @@ inline void OutputDebugBytes(const void *ptr, size_t len) { } } -inline void OutputDebugFormatA(_In_ _Printf_format_string_ _Null_terminated_ const char* pszFormat, ...) { +inline void OutputDebugFormatA(const char *pszFormat, ...) { char buffer[1024]; va_list argList; @@ -198,11 +205,15 @@ inline void OutputDebugFormatA(_In_ _Printf_format_string_ _Null_terminated_ con // This prints 'Hello World (i > 10)' and breaks in the debugger if the // assertion doesn't hold. // -#define DXASSERT_ARGS(exp, fmt, ...)\ - do { _Analysis_assume_(exp); if(!(exp)) { \ - OutputDebugFormatA("Error: \t%s\nFile:\n%s(%d)\nFunc:\t%s.\n\t" fmt "\n", "!(" #exp ")", __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \ - __debugbreak();\ - } } while(0) +#define DXASSERT_ARGS(exp, fmt, ...) \ + do { \ + if (!(exp)) { \ + OutputDebugFormatA( \ + "Error: \t%s\nFile:\n%s(%d)\nFunc:\t%s.\n\t" fmt "\n", \ + "!(" #exp ")", __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \ + __debugbreak(); \ + } \ + } while (0) #define DXASSERT(exp, msg) DXASSERT_ARGS(exp, msg) #define DXASSERT_LOCALVAR(local, exp, msg) DXASSERT(exp, msg) @@ -233,19 +244,25 @@ inline void OutputDebugFormatA(_In_ _Printf_format_string_ _Null_terminated_ con #else // NDEBUG // DXASSERT_ARGS is disabled in free builds. -#define DXASSERT_ARGS(exp, s, ...) _Analysis_assume_(exp) +#define DXASSERT_ARGS(exp, s, ...) // DXASSERT is disabled in free builds. -#define DXASSERT(exp, msg) _Analysis_assume_(exp) +#define DXASSERT(exp, msg) // DXASSERT_LOCALVAR is disabled in free builds, but we keep the local referenced to avoid a warning. -#define DXASSERT_LOCALVAR(local, exp, msg) do { (void)(local); _Analysis_assume_(exp); } while (0) +#define DXASSERT_LOCALVAR(local, exp, msg) \ + do { \ + (void)(local); \ + } while (0) #define DXASSERT_LOCALVAR_NOMSG(local, exp) DXASSERT_LOCALVAR(local, exp, "") // DXASSERT_NOMSG is disabled in free builds. -#define DXASSERT_NOMSG(exp) _Analysis_assume_(exp) +#define DXASSERT_NOMSG(exp) // DXVERIFY is patterned after NT_VERIFY and will evaluate the expression -#define DXVERIFY_NOMSG(exp) do { (void)(exp); _Analysis_assume_(exp); } while (0) +#define DXVERIFY_NOMSG(exp) \ + do { \ + (void)(exp); \ + } while (0) #endif // NDEBUG diff --git a/include/dxc/Support/Unicode.h b/include/dxc/Support/Unicode.h index 71cb48fd36..d7dc3e4a9e 100644 --- a/include/dxc/Support/Unicode.h +++ b/include/dxc/Support/Unicode.h @@ -45,53 +45,38 @@ typedef char acp_char; // A ccp_char is a character encoded in the console code page. typedef char ccp_char; -_Success_(return != false) -bool UTF8ToConsoleString(_In_opt_count_(textLen) const char* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy); +bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue, + bool *lossy); -_Success_(return != false) -bool UTF8ToConsoleString(_In_z_ const char* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy); +bool UTF8ToConsoleString(const char *text, std::string *pValue, bool *lossy); -_Success_(return != false) -bool WideToConsoleString(_In_opt_count_(textLen) const wchar_t* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy); +bool WideToConsoleString(const wchar_t *text, size_t textLen, + std::string *pValue, bool *lossy); -_Success_(return != false) -bool WideToConsoleString(_In_z_ const wchar_t* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy); +bool WideToConsoleString(const wchar_t *text, std::string *pValue, bool *lossy); -_Success_(return != false) -bool UTF8ToWideString(_In_opt_z_ const char *pUTF8, _Inout_ std::wstring *pWide); +bool UTF8ToWideString(const char *pUTF8, std::wstring *pWide); -_Success_(return != false) -bool UTF8ToWideString(_In_opt_count_(cbUTF8) const char *pUTF8, size_t cbUTF8, _Inout_ std::wstring *pWide); +bool UTF8ToWideString(const char *pUTF8, size_t cbUTF8, std::wstring *pWide); -std::wstring UTF8ToWideStringOrThrow(_In_z_ const char *pUTF8); +std::wstring UTF8ToWideStringOrThrow(const char *pUTF8); -_Success_(return != false) -bool WideToUTF8String(_In_z_ const wchar_t *pWide, size_t cWide, _Inout_ std::string *pUTF8); -bool WideToUTF8String(_In_z_ const wchar_t *pWide, _Inout_ std::string *pUTF8); +bool WideToUTF8String(const wchar_t *pWide, size_t cWide, std::string *pUTF8); +bool WideToUTF8String(const wchar_t *pWide, std::string *pUTF8); -std::string WideToUTF8StringOrThrow(_In_z_ const wchar_t *pWide); +std::string WideToUTF8StringOrThrow(const wchar_t *pWide); -bool IsStarMatchUTF8(_In_reads_opt_(maskLen) const char *pMask, size_t maskLen, - _In_reads_opt_(nameLen) const char *pName, size_t nameLen); -bool IsStarMatchWide(_In_reads_opt_(maskLen) const wchar_t *pMask, size_t maskLen, - _In_reads_opt_(nameLen) const wchar_t *pName, size_t nameLen); +bool IsStarMatchUTF8(const char *pMask, size_t maskLen, const char *pName, + size_t nameLen); +bool IsStarMatchWide(const wchar_t *pMask, size_t maskLen, const wchar_t *pName, + size_t nameLen); -_Success_(return != false) -bool UTF8BufferToWideComHeap(_In_z_ const char *pUTF8, - _Outptr_result_z_ wchar_t **ppWide) throw(); +bool UTF8BufferToWideComHeap(const char *pUTF8, wchar_t **ppWide) throw(); -_Success_(return != false) -bool UTF8BufferToWideBuffer( - _In_NLS_string_(cbUTF8) const char *pUTF8, - int cbUTF8, - _Outptr_result_buffer_(*pcchWide) wchar_t **ppWide, - size_t *pcchWide) throw(); +bool UTF8BufferToWideBuffer(const char *pUTF8, int cbUTF8, wchar_t **ppWide, + size_t *pcchWide) throw(); -_Success_(return != false) -bool WideBufferToUTF8Buffer( - _In_NLS_string_(cchWide) const wchar_t *pWide, - int cchWide, - _Outptr_result_buffer_(*pcbUTF8) char **ppUTF8, - size_t *pcbUTF8) throw(); +bool WideBufferToUTF8Buffer(const wchar_t *pWide, int cchWide, char **ppUTF8, + size_t *pcbUTF8) throw(); } // namespace Unicode diff --git a/include/dxc/Support/WinFunctions.h b/include/dxc/Support/WinFunctions.h index 9b1a0590a9..2f580f3ef0 100644 --- a/include/dxc/Support/WinFunctions.h +++ b/include/dxc/Support/WinFunctions.h @@ -32,28 +32,21 @@ int _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n); int wsprintf(wchar_t *wcs, const wchar_t *fmt, ...); unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask); -HANDLE CreateFile2(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, - _In_opt_ void *pCreateExParams); +HANDLE CreateFile2(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + DWORD dwCreationDisposition, void *pCreateExParams); -HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, _In_opt_ void *lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile); +HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + void *lpSecurityAttributes, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); -BOOL GetFileSizeEx(_In_ HANDLE hFile, _Out_ PLARGE_INTEGER lpFileSize); +BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize); -BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer, - _In_ DWORD nNumberOfBytesToRead, - _Out_opt_ LPDWORD lpNumberOfBytesRead, - _Inout_opt_ void *lpOverlapped); -BOOL WriteFile(_In_ HANDLE hFile, _In_ LPCVOID lpBuffer, - _In_ DWORD nNumberOfBytesToWrite, - _Out_opt_ LPDWORD lpNumberOfBytesWritten, - _Inout_opt_ void *lpOverlapped); +BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, void *lpOverlapped); +BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, void *lpOverlapped); -BOOL CloseHandle(_In_ HANDLE hObject); +BOOL CloseHandle(HANDLE hObject); // Windows-specific heap functions HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize , SIZE_T dwMaximumSize); diff --git a/include/dxc/Support/dxcapi.impl.h b/include/dxc/Support/dxcapi.impl.h index 3122ab4ba0..f075b639c0 100644 --- a/include/dxc/Support/dxcapi.impl.h +++ b/include/dxc/Support/dxcapi.impl.h @@ -34,8 +34,8 @@ class raw_stream_ostream : public llvm::raw_ostream { }; namespace { -HRESULT TranslateUtf8StringForOutput( - _In_opt_count_(size) LPCSTR pStr, SIZE_T size, UINT32 codePage, IDxcBlobEncoding **ppBlobEncoding) { +HRESULT TranslateUtf8StringForOutput(LPCSTR pStr, SIZE_T size, UINT32 codePage, + IDxcBlobEncoding **ppBlobEncoding) { CComPtr pBlobEncoding; IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pStr, size, DXC_CP_UTF8, &pBlobEncoding)); if (codePage == DXC_CP_WIDE) { @@ -47,8 +47,8 @@ HRESULT TranslateUtf8StringForOutput( return S_OK; } -HRESULT TranslateWideStringForOutput( - _In_opt_count_(size) LPCWSTR pStr, SIZE_T size, UINT32 codePage, IDxcBlobEncoding **ppBlobEncoding) { +HRESULT TranslateWideStringForOutput(LPCWSTR pStr, SIZE_T size, UINT32 codePage, + IDxcBlobEncoding **ppBlobEncoding) { CComPtr pBlobEncoding; IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pStr, size, DXC_CP_WIDE, &pBlobEncoding)); if (codePage == DXC_CP_UTF8) { @@ -138,7 +138,7 @@ struct DxcOutputObject { } return S_OK; } - HRESULT SetObjectData(_In_opt_bytecount_(size) LPCVOID pData, SIZE_T size) { + HRESULT SetObjectData(LPCVOID pData, SIZE_T size) { DXASSERT_NOMSG(!object); if (!pData || !size) return S_OK; @@ -147,7 +147,7 @@ struct DxcOutputObject { object = pBlob; return S_OK; } - HRESULT SetString(_In_ UINT32 codePage, _In_opt_count_(size) LPCWSTR pText, SIZE_T size = kAutoSize) { + HRESULT SetString(UINT32 codePage, LPCWSTR pText, SIZE_T size = kAutoSize) { DXASSERT_NOMSG(!object); if (!pText) return S_OK; @@ -158,7 +158,7 @@ struct DxcOutputObject { object = pBlobEncoding; return S_OK; } - HRESULT SetString(_In_ UINT32 codePage, _In_opt_count_(size) LPCSTR pText, SIZE_T size = kAutoSize) { + HRESULT SetString(UINT32 codePage, LPCSTR pText, SIZE_T size = kAutoSize) { DXASSERT_NOMSG(!object); if (!pText) return S_OK; @@ -169,12 +169,12 @@ struct DxcOutputObject { object = pBlobEncoding; return S_OK; } - HRESULT SetName(_In_opt_z_ IDxcBlobWide *pName) { + HRESULT SetName(IDxcBlobWide *pName) { DXASSERT_NOMSG(!name); name = pName; return S_OK; } - HRESULT SetName(_In_opt_z_ LPCWSTR pName) { + HRESULT SetName(LPCWSTR pName) { DXASSERT_NOMSG(!name); if (!pName) return S_OK; @@ -183,7 +183,7 @@ struct DxcOutputObject { pName, (wcslen(pName) + 1) * sizeof(wchar_t), DXC_CP_WIDE, &pBlobEncoding)); return pBlobEncoding->QueryInterface(&name); } - HRESULT SetName(_In_opt_z_ LPCSTR pName) { + HRESULT SetName(LPCSTR pName) { DXASSERT_NOMSG(!name); if (!pName) return S_OK; @@ -191,7 +191,7 @@ struct DxcOutputObject { IFR(TranslateUtf8StringForOutput(pName, strlen(pName) + 1, DXC_CP_WIDE, &pBlobEncoding)); return pBlobEncoding->QueryInterface(&name); } - HRESULT SetName(_In_opt_z_ llvm::StringRef Name) { + HRESULT SetName(llvm::StringRef Name) { DXASSERT_NOMSG(!name); if (Name.empty()) return S_OK; @@ -204,67 +204,56 @@ struct DxcOutputObject { // Static object constructors ///////////////////////////// - template - static DxcOutputObject StringOutput(_In_ DXC_OUT_KIND kind, - _In_ UINT32 codePage, - _In_opt_count_(size) DataTy pText, _In_ SIZE_T size, - _In_opt_z_ NameTy pName) { + template + static DxcOutputObject StringOutput(DXC_OUT_KIND kind, UINT32 codePage, + DataTy pText, SIZE_T size, NameTy pName) { DxcOutputObject output; output.kind = kind; IFT(output.SetString(codePage, pText, size)); IFT(output.SetName(pName)); return output; } - template - static DxcOutputObject StringOutput(_In_ DXC_OUT_KIND kind, - _In_ UINT32 codePage, - _In_opt_ DataTy pText, - _In_opt_z_ NameTy pName) { + template + static DxcOutputObject StringOutput(DXC_OUT_KIND kind, UINT32 codePage, + DataTy pText, NameTy pName) { return StringOutput(kind, codePage, pText, kAutoSize, pName); } - template - static DxcOutputObject DataOutput(_In_ DXC_OUT_KIND kind, - _In_opt_bytecount_(size) LPCVOID pData, _In_ SIZE_T size, - _In_opt_z_ NameTy pName) { + template + static DxcOutputObject DataOutput(DXC_OUT_KIND kind, LPCVOID pData, + SIZE_T size, NameTy pName) { DxcOutputObject output; output.kind = kind; IFT(output.SetObjectData(pData, size)); IFT(output.SetName(pName)); return output; } - template - static DxcOutputObject DataOutput(_In_ DXC_OUT_KIND kind, - _In_opt_ IDxcBlob *pBlob, - _In_opt_z_ NameTy pName) { + template + static DxcOutputObject DataOutput(DXC_OUT_KIND kind, IDxcBlob *pBlob, + NameTy pName) { DxcOutputObject output; output.kind = kind; IFT(output.SetObject(pBlob)); IFT(output.SetName(pName)); return output; } - static DxcOutputObject DataOutput(_In_ DXC_OUT_KIND kind, - _In_opt_ IDxcBlob *pBlob) { + static DxcOutputObject DataOutput(DXC_OUT_KIND kind, IDxcBlob *pBlob) { return DataOutput(kind, pBlob, DxcOutNoName); } - template - static DxcOutputObject DataOutput(_In_ DXC_OUT_KIND kind, - _In_ UINT32 codePage, - _In_opt_ IDxcBlob *pBlob, - _In_opt_z_ NameTy pName) { + template + static DxcOutputObject DataOutput(DXC_OUT_KIND kind, UINT32 codePage, + IDxcBlob *pBlob, NameTy pName) { DxcOutputObject output; output.kind = kind; IFT(output.SetObject(pBlob, codePage)); IFT(output.SetName(pName)); return output; } - static DxcOutputObject DataOutput(_In_ DXC_OUT_KIND kind, - _In_ UINT32 codePage, - _In_opt_ IDxcBlob *pBlob) { + static DxcOutputObject DataOutput(DXC_OUT_KIND kind, UINT32 codePage, + IDxcBlob *pBlob) { return DataOutput(kind, codePage, pBlob, DxcOutNoName); } - static DxcOutputObject DataOutput(_In_ DXC_OUT_KIND kind, - _In_ UINT32 codePage, - _In_opt_ IUnknown *pBlob) { + static DxcOutputObject DataOutput(DXC_OUT_KIND kind, UINT32 codePage, + IUnknown *pBlob) { DxcOutputObject output; output.kind = kind; IFT(output.SetObject(pBlob, codePage)); @@ -322,11 +311,10 @@ class DxcExtraOutputs : public IDxcExtraOutputs { return m_uCount; } - HRESULT STDMETHODCALLTYPE GetOutput(_In_ UINT32 uIndex, - _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject, - _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputType, - _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) override - { + HRESULT STDMETHODCALLTYPE GetOutput(UINT32 uIndex, REFIID iid, + void **ppvObject, + IDxcBlobWide **ppOutputType, + IDxcBlobWide **ppOutputName) override { if (uIndex >= m_uCount) return E_INVALIDARG; @@ -395,7 +383,7 @@ class DxcResult : public IDxcResult { // IDxcOperationResult ////////////////////// - HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) override { + HRESULT STDMETHODCALLTYPE GetStatus(HRESULT *pStatus) override { if (pStatus == nullptr) return E_INVALIDARG; @@ -403,8 +391,7 @@ class DxcResult : public IDxcResult { return S_OK; } - HRESULT STDMETHODCALLTYPE - GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) override { + HRESULT STDMETHODCALLTYPE GetResult(IDxcBlob **ppResult) override { *ppResult = nullptr; if (m_resultType == DXC_OUT_NONE) return S_OK; @@ -415,7 +402,7 @@ class DxcResult : public IDxcResult { } HRESULT STDMETHODCALLTYPE - GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) override { + GetErrorBuffer(IDxcBlobEncoding **ppErrors) override { *ppErrors = nullptr; DxcOutputObject *pObject = Output(DXC_OUT_ERRORS); if (pObject && pObject->object) @@ -427,14 +414,14 @@ class DxcResult : public IDxcResult { // IDxcResult ///////////// - BOOL STDMETHODCALLTYPE HasOutput(_In_ DXC_OUT_KIND dxcOutKind) override { + BOOL STDMETHODCALLTYPE HasOutput(DXC_OUT_KIND dxcOutKind) override { if (dxcOutKind <= DXC_OUT_NONE || (unsigned)dxcOutKind > kNumDxcOutputTypes) return FALSE; return m_outputs[(unsigned)dxcOutKind - 1].kind != DXC_OUT_NONE; } - HRESULT STDMETHODCALLTYPE GetOutput(_In_ DXC_OUT_KIND dxcOutKind, - _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject, - _COM_Outptr_ IDxcBlobWide **ppOutputName) override { + HRESULT STDMETHODCALLTYPE GetOutput(DXC_OUT_KIND dxcOutKind, REFIID iid, + void **ppvObject, + IDxcBlobWide **ppOutputName) override { if (ppvObject == nullptr) return E_INVALIDARG; if (dxcOutKind <= DXC_OUT_NONE || (unsigned)dxcOutKind > kNumDxcOutputTypes) @@ -590,7 +577,7 @@ class DxcResult : public IDxcResult { } // All-in-one initialization - HRESULT Init(_In_ HRESULT status, _In_ DXC_OUT_KIND resultType, + HRESULT Init(HRESULT status, DXC_OUT_KIND resultType, const llvm::ArrayRef outputs) { m_status = status; m_resultType = resultType; @@ -599,10 +586,9 @@ class DxcResult : public IDxcResult { // All-in-one create functions - static HRESULT Create(_In_ HRESULT status, _In_ DXC_OUT_KIND resultType, - _In_opt_count_(numOutputs) const DxcOutputObject *pOutputs, - _In_ unsigned numOutputs, - _COM_Outptr_ IDxcResult **ppResult) { + static HRESULT Create(HRESULT status, DXC_OUT_KIND resultType, + const DxcOutputObject *pOutputs, unsigned numOutputs, + IDxcResult **ppResult) { *ppResult = nullptr; CComPtr result = DxcResult::Alloc(DxcGetThreadMallocNoRef()); @@ -611,15 +597,15 @@ class DxcResult : public IDxcResult { *ppResult = result.Detach(); return S_OK; } - static HRESULT Create(_In_ HRESULT status, _In_ DXC_OUT_KIND resultType, + static HRESULT Create(HRESULT status, DXC_OUT_KIND resultType, const llvm::ArrayRef outputs, - _COM_Outptr_ IDxcResult **ppResult) { + IDxcResult **ppResult) { return Create(status, resultType, outputs.data(), outputs.size(), ppResult); } // For convenient use in legacy interface implementations - static HRESULT Create(_In_ HRESULT status, _In_ DXC_OUT_KIND resultType, + static HRESULT Create(HRESULT status, DXC_OUT_KIND resultType, const llvm::ArrayRef outputs, - _COM_Outptr_ IDxcOperationResult **ppResult) { + IDxcOperationResult **ppResult) { IDxcResult *pResult; IFR(Create(status, resultType, outputs.data(), outputs.size(), &pResult)); *ppResult = pResult; diff --git a/include/dxc/Support/dxcapi.use.h b/include/dxc/Support/dxcapi.use.h index b47686bed0..cdabf53382 100644 --- a/include/dxc/Support/dxcapi.use.h +++ b/include/dxc/Support/dxcapi.use.h @@ -88,16 +88,16 @@ class DxcDllSupport { return InitializeInternal(kDxCompilerLib, "DxcCreateInstance"); } - HRESULT InitializeForDll(_In_z_ LPCSTR dll, _In_z_ LPCSTR entryPoint) { + HRESULT InitializeForDll(LPCSTR dll, LPCSTR entryPoint) { return InitializeInternal(dll, entryPoint); } template - HRESULT CreateInstance(REFCLSID clsid, _Outptr_ TInterface** pResult) { + HRESULT CreateInstance(REFCLSID clsid, TInterface **pResult) { return CreateInstance(clsid, __uuidof(TInterface), (IUnknown**)pResult); } - HRESULT CreateInstance(REFCLSID clsid, REFIID riid, _Outptr_ IUnknown **pResult) { + HRESULT CreateInstance(REFCLSID clsid, REFIID riid, IUnknown **pResult) { if (pResult == nullptr) return E_POINTER; if (m_dll == nullptr) return E_FAIL; HRESULT hr = m_createFn(clsid, riid, (LPVOID*)pResult); @@ -105,11 +105,13 @@ class DxcDllSupport { } template - HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, _Outptr_ TInterface** pResult) { + HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, + TInterface **pResult) { return CreateInstance2(pMalloc, clsid, __uuidof(TInterface), (IUnknown**)pResult); } - HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, REFIID riid, _Outptr_ IUnknown **pResult) { + HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, REFIID riid, + IUnknown **pResult) { if (pResult == nullptr) return E_POINTER; if (m_dll == nullptr) return E_FAIL; if (m_createFn2 == nullptr) return E_FAIL; @@ -145,7 +147,7 @@ class DxcDllSupport { } }; -inline DxcDefine GetDefine(_In_ LPCWSTR name, LPCWSTR value) { +inline DxcDefine GetDefine(LPCWSTR name, LPCWSTR value) { DxcDefine result; result.Name = name; result.Value = value; @@ -153,21 +155,22 @@ inline DxcDefine GetDefine(_In_ LPCWSTR name, LPCWSTR value) { } // Checks an HRESULT and formats an error message with the appended data. -void IFT_Data(HRESULT hr, _In_opt_ LPCWSTR data); +void IFT_Data(HRESULT hr, LPCWSTR data); void EnsureEnabled(DxcDllSupport &dxcSupport); -void ReadFileIntoBlob(DxcDllSupport &dxcSupport, _In_ LPCWSTR pFileName, - _Outptr_ IDxcBlobEncoding **ppBlobEncoding); -void WriteBlobToConsole(_In_opt_ IDxcBlob *pBlob, DWORD streamType = STD_OUTPUT_HANDLE); -void WriteBlobToFile(_In_opt_ IDxcBlob *pBlob, _In_ LPCWSTR pFileName, _In_ UINT32 textCodePage); -void WriteBlobToHandle(_In_opt_ IDxcBlob *pBlob, _In_ HANDLE hFile, _In_opt_ LPCWSTR pFileName, _In_ UINT32 textCodePage); -void WriteUtf8ToConsole(_In_opt_count_(charCount) const char *pText, - int charCount, DWORD streamType = STD_OUTPUT_HANDLE); -void WriteUtf8ToConsoleSizeT(_In_opt_count_(charCount) const char *pText, - size_t charCount, DWORD streamType = STD_OUTPUT_HANDLE); -void WriteOperationErrorsToConsole(_In_ IDxcOperationResult *pResult, +void ReadFileIntoBlob(DxcDllSupport &dxcSupport, LPCWSTR pFileName, + IDxcBlobEncoding **ppBlobEncoding); +void WriteBlobToConsole(IDxcBlob *pBlob, DWORD streamType = STD_OUTPUT_HANDLE); +void WriteBlobToFile(IDxcBlob *pBlob, LPCWSTR pFileName, UINT32 textCodePage); +void WriteBlobToHandle(IDxcBlob *pBlob, HANDLE hFile, LPCWSTR pFileName, + UINT32 textCodePage); +void WriteUtf8ToConsole(const char *pText, int charCount, + DWORD streamType = STD_OUTPUT_HANDLE); +void WriteUtf8ToConsoleSizeT(const char *pText, size_t charCount, + DWORD streamType = STD_OUTPUT_HANDLE); +void WriteOperationErrorsToConsole(IDxcOperationResult *pResult, bool outputWarnings); -void WriteOperationResultToConsole(_In_ IDxcOperationResult *pRewriteResult, +void WriteOperationResultToConsole(IDxcOperationResult *pRewriteResult, bool outputWarnings); } // namespace dxc diff --git a/include/dxc/Support/dxcfilesystem.h b/include/dxc/Support/dxcfilesystem.h index d6e1ff26f0..40bd56d492 100644 --- a/include/dxc/Support/dxcfilesystem.h +++ b/include/dxc/Support/dxcfilesystem.h @@ -41,16 +41,16 @@ class DxcArgsFileSystem : public ::llvm::sys::fs::MSFileSystem { virtual void WriteStdErrToStream(llvm::raw_string_ostream &s) = 0; virtual void WriteStdOutToStream(llvm::raw_string_ostream &s) = 0; virtual void EnableDisplayIncludeProcess() = 0; - virtual HRESULT CreateStdStreams(_In_ IMalloc *pMalloc) = 0; + virtual HRESULT CreateStdStreams(IMalloc *pMalloc) = 0; virtual HRESULT RegisterOutputStream(LPCWSTR pName, IStream *pStream) = 0; virtual HRESULT UnRegisterOutputStream() = 0; }; -DxcArgsFileSystem * -CreateDxcArgsFileSystem(_In_ IDxcBlobUtf8 *pSource, _In_ LPCWSTR pSourceName, - _In_opt_ IDxcIncludeHandler *pIncludeHandler, - _In_opt_ UINT32 defaultCodePage = CP_ACP); +DxcArgsFileSystem *CreateDxcArgsFileSystem(IDxcBlobUtf8 *pSource, + LPCWSTR pSourceName, + IDxcIncludeHandler *pIncludeHandler, + UINT32 defaultCodePage = CP_ACP); void MakeAbsoluteOrCurDirRelativeW(LPCWSTR &Path, std::wstring &PathStorage); -} // namespace dxcutil \ No newline at end of file +} // namespace dxcutil diff --git a/include/dxc/Support/microcom.h b/include/dxc/Support/microcom.h index b47f1cb5af..f4a96d49e9 100644 --- a/include/dxc/Support/microcom.h +++ b/include/dxc/Support/microcom.h @@ -183,35 +183,30 @@ HRESULT DoBasicQueryInterface(TObject* self, REFIID iid, void** ppvObject) { return DoBasicQueryInterface_recurse(self, iid, ppvObject); } -template -HRESULT AssignToOut(T value, _Out_ T* pResult) { +template HRESULT AssignToOut(T value, T *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = value; return S_OK; } -template -HRESULT AssignToOut(nullptr_t value, _Out_ T* pResult) { +template HRESULT AssignToOut(nullptr_t value, T *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = value; return S_OK; } -template -HRESULT ZeroMemoryToOut(_Out_ T* pResult) { +template HRESULT ZeroMemoryToOut(T *pResult) { if (pResult == nullptr) return E_POINTER; ZeroMemory(pResult, sizeof(*pResult)); return S_OK; } -template -void AssignToOutOpt(T value, _Out_opt_ T* pResult) { +template void AssignToOutOpt(T value, T *pResult) { if (pResult != nullptr) *pResult = value; } -template -void AssignToOutOpt(nullptr_t value, _Out_opt_ T* pResult) { +template void AssignToOutOpt(nullptr_t value, T *pResult) { if (pResult != nullptr) *pResult = value; } diff --git a/include/dxc/Test/CompilationResult.h b/include/dxc/Test/CompilationResult.h index fdc193c522..7f5d8eb0fc 100644 --- a/include/dxc/Test/CompilationResult.h +++ b/include/dxc/Test/CompilationResult.h @@ -110,7 +110,7 @@ class HlslIntellisenseSupport : public dxc::DxcDllSupport { HlslIntellisenseSupport(HlslIntellisenseSupport &&other) : dxc::DxcDllSupport(std::move(other)) {} - HRESULT CreateIntellisense(_Outptr_ IDxcIntelliSense **pResult) { + HRESULT CreateIntellisense(IDxcIntelliSense **pResult) { return CreateInstance(CLSID_DxcIntelliSense, pResult); } }; @@ -210,11 +210,11 @@ class CompilationResult return result; } - static CompilationResult CreateForProgramAndArgs(const char* text, size_t textLen, - _In_count_(commandLineArgsCount) const char* commandLineArgs[], - unsigned commandLineArgsCount, - _In_opt_ DxcTranslationUnitFlags* options = nullptr) - { + static CompilationResult + CreateForProgramAndArgs(const char *text, size_t textLen, + const char *commandLineArgs[], + unsigned commandLineArgsCount, + DxcTranslationUnitFlags *options = nullptr) { std::shared_ptr support(GetHlslSupport()); CComPtr isense; @@ -247,7 +247,7 @@ class CompilationResult static CompilationResult CreateForProgram(const char *text, size_t textLen, - _In_opt_ DxcTranslationUnitFlags *options = nullptr) { + DxcTranslationUnitFlags *options = nullptr) { const char *commandLineArgs[] = {"-c", "-ferror-limit=200"}; unsigned commandLineArgsCount = _countof(commandLineArgs); return CreateForProgramAndArgs(text, textLen, commandLineArgs, diff --git a/include/dxc/Test/DxcTestUtils.h b/include/dxc/Test/DxcTestUtils.h index db3b7384ce..6141967c5c 100644 --- a/include/dxc/Test/DxcTestUtils.h +++ b/include/dxc/Test/DxcTestUtils.h @@ -161,8 +161,8 @@ class FileRunTestResult { }; void AssembleToContainer(dxc::DxcDllSupport &dllSupport, IDxcBlob *pModule, IDxcBlob **pContainer); -std::string BlobToUtf8(_In_ IDxcBlob *pBlob); -std::wstring BlobToWide(_In_ IDxcBlob *pBlob); +std::string BlobToUtf8(IDxcBlob *pBlob); +std::wstring BlobToWide(IDxcBlob *pBlob); void CheckOperationSucceeded(IDxcOperationResult *pResult, IDxcBlob **ppBlob); bool CheckOperationResultMsgs(IDxcOperationResult *pResult, llvm::ArrayRef pErrorMsgs, @@ -177,19 +177,27 @@ bool CheckNotMsgs(const LPCSTR pText, size_t TextCount, const LPCSTR *pErrorMsgs void GetDxilPart(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram, IDxcBlob **pDxilPart); std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram); void SplitPassList(LPWSTR pPassesBuffer, std::vector &passes); -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, UINT32 codePoint, _Outptr_ IDxcBlob **ppBlob); -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, UINT32 codePoint, _Outptr_ IDxcBlobEncoding **ppBlob); -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, _Outptr_ IDxcBlob **ppBlob); -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, _Outptr_ IDxcBlobEncoding **ppBlob); -void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, _Outptr_ IDxcBlobEncoding **ppBlob); -void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, _Outptr_ IDxcBlob **ppBlob); -void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, _Outptr_ IDxcBlobEncoding **ppBlob); +void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, + const std::string &val, UINT32 codePoint, + IDxcBlob **ppBlob); +void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, + const std::string &val, UINT32 codePoint, + IDxcBlobEncoding **ppBlob); +void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, + IDxcBlob **ppBlob); +void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, + IDxcBlobEncoding **ppBlob); +void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, + IDxcBlobEncoding **ppBlob); +void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, + IDxcBlob **ppBlob); +void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, + IDxcBlobEncoding **ppBlob); void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, - LPWSTR pTargetProfile, LPCWSTR pArgs, - _Outptr_ IDxcBlob **ppResult); + LPWSTR pTargetProfile, LPCWSTR pArgs, IDxcBlob **ppResult); void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, LPWSTR pTargetProfile, std::vector &args, - _Outptr_ IDxcBlob **ppResult); + IDxcBlob **ppResult); HRESULT GetVersion(dxc::DxcDllSupport& DllSupport, REFCLSID clsid, unsigned &Major, unsigned &Minor); bool ParseTargetProfile(llvm::StringRef targetProfile, llvm::StringRef &outStage, unsigned &outMajor, unsigned &outMinor); diff --git a/include/dxc/Test/HlslTestUtils.h b/include/dxc/Test/HlslTestUtils.h index a26f4b9190..21112c2542 100644 --- a/include/dxc/Test/HlslTestUtils.h +++ b/include/dxc/Test/HlslTestUtils.h @@ -168,8 +168,7 @@ inline void strreplace(const std::vector& lookFors, const std::vect namespace hlsl_test { -inline std::wstring -vFormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, va_list argptr) { +inline std::wstring vFormatToWString(const wchar_t *fmt, va_list argptr) { std::wstring result; #ifdef _WIN32 int len = _vscwprintf(fmt, argptr); @@ -185,8 +184,7 @@ vFormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, va_list argpt return result; } -inline std::wstring -FormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) { +inline std::wstring FormatToWString(const wchar_t *fmt, ...) { va_list args; va_start(args, fmt); std::wstring result(vFormatToWString(fmt, args)); @@ -194,7 +192,7 @@ FormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) { return result; } -inline void LogCommentFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) { +inline void LogCommentFmt(const wchar_t *fmt, ...) { va_list args; va_start(args, fmt); std::wstring buf(vFormatToWString(fmt, args)); @@ -202,12 +200,12 @@ inline void LogCommentFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) WEX::Logging::Log::Comment(buf.data()); } -inline void LogErrorFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) { - va_list args; - va_start(args, fmt); - std::wstring buf(vFormatToWString(fmt, args)); - va_end(args); - WEX::Logging::Log::Error(buf.data()); +inline void LogErrorFmt(const wchar_t *fmt, ...) { + va_list args; + va_start(args, fmt); + std::wstring buf(vFormatToWString(fmt, args)); + va_end(args); + WEX::Logging::Log::Error(buf.data()); } inline std::wstring GetPathToHlslDataFile(const wchar_t* relative, LPCWSTR paramName = HLSLDATAFILEPARAM, LPCWSTR defaultDataDir = DEFAULT_TEST_DIR) { diff --git a/include/dxc/Test/WEXAdapter.h b/include/dxc/Test/WEXAdapter.h index c9eba87dc5..4c7c3f82cb 100644 --- a/include/dxc/Test/WEXAdapter.h +++ b/include/dxc/Test/WEXAdapter.h @@ -102,9 +102,8 @@ bool moduleTeardown(); bool moduleTeardown() { return method(); } // No need to expand env vars on Unix platforms, so convert the slashes instead. -inline DWORD ExpandEnvironmentStringsW(_In_ LPCWSTR lpSrc, - _Out_opt_ LPWSTR lpDst, - _In_ DWORD nSize) { +inline DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, + DWORD nSize) { unsigned i; bool wasSlash = false; for (i = 0; i < nSize && *lpSrc; i++, lpSrc++) { diff --git a/include/dxc/WinAdapter.h b/include/dxc/WinAdapter.h index 414602de44..812e7a4d2b 100644 --- a/include/dxc/WinAdapter.h +++ b/include/dxc/WinAdapter.h @@ -251,89 +251,30 @@ #define _In_opt_ #define _In_opt_count_(size) #define _In_opt_z_ -#define _In_reads_(size) -#define _In_reads_bytes_(size) -#define _In_reads_bytes_opt_(size) -#define _In_reads_opt_(size) -#define _In_reads_to_ptr_(ptr) #define _In_count_(size) -#define _In_range_(lb, ub) #define _In_bytecount_(size) -#define _In_opt_bytecount_(size) -#define _In_NLS_string_(size) -#define __in_bcount(size) #define _Out_ -#define _Out_bytecap_(nbytes) -#define _Out_writes_to_(a, b) -#define _Out_writes_to_opt_(a, b) +#define _Out_opt_ #define _Outptr_ #define _Outptr_opt_ -#define _Outptr_opt_result_z_ -#define _Out_opt_ -#define _Out_writes_(size) -#define _Out_write_bytes_(size) -#define _Out_writes_z_(size) -#define _Out_writes_all_(size) -#define _Out_writes_bytes_(size) -#define _Outref_result_buffer_(size) -#define _Outptr_result_buffer_(size) -#define _Out_cap_(size) -#define _Out_cap_x_(size) -#define _Out_range_(lb, ub) #define _Outptr_result_z_ -#define _Outptr_result_buffer_maybenull_(ptr) +#define _Outptr_opt_result_z_ #define _Outptr_result_maybenull_ #define _Outptr_result_nullonfailure_ - -#define __out_ecount_part(a, b) - -#define _Inout_ -#define _Inout_z_ -#define _Inout_opt_ -#define _Inout_cap_(size) -#define _Inout_count_(size) -#define _Inout_count_c_(size) -#define _Inout_opt_count_c_(size) -#define _Inout_bytecount_c_(size) -#define _Inout_opt_bytecount_c_(size) - -#define _Ret_maybenull_ -#define _Ret_notnull_ -#define _Ret_opt_ - -#define _Use_decl_annotations_ -#define __analysis_assume(expr) -#define _Analysis_assume_(expr) -#define _Analysis_assume_nullterminated_(x) -#define _Success_(expr) - -#define __inexpressible_readableTo(size) -#define __inexpressible_writableTo(size) - -#define _Printf_format_string_ -#define _Null_terminated_ - -#define _Field_size_(size) -#define _Field_size_full_(size) -#define _Field_size_opt_(size) -#define _Post_writable_byte_size_(size) -#define _Post_readable_byte_size_(size) -#define __drv_allocatesMem(mem) +#define _Outptr_result_buffer_maybenull_(ptr) +#define _Outptr_result_buffer_(ptr) #define _COM_Outptr_ #define _COM_Outptr_opt_ #define _COM_Outptr_result_maybenull_ #define _COM_Outptr_opt_result_maybenull_ -#define _Null_ -#define _Notnull_ -#define _Maybenull_ #define THIS_ #define THIS #define PURE = 0 -#define _Outptr_result_bytebuffer_(size) +#define _Maybenull_ #define __debugbreak() @@ -1039,7 +980,7 @@ class CComBSTR public: BSTR m_str; CComBSTR() : m_str(nullptr) {}; - CComBSTR(_In_ int nSize, LPCWSTR sz); + CComBSTR(int nSize, LPCWSTR sz); ~CComBSTR() throw() { SysFreeString(m_str); } @@ -1049,7 +990,7 @@ class CComBSTR return m_str; } - bool operator==(_In_ const CComBSTR& bstrSrc) const throw(); + bool operator==(const CComBSTR &bstrSrc) const throw(); BSTR* operator&() throw() { diff --git a/include/dxc/dxcapi.internal.h b/include/dxc/dxcapi.internal.h index 337c0a4c25..226bc81721 100644 --- a/include/dxc/dxcapi.internal.h +++ b/include/dxc/dxcapi.internal.h @@ -148,11 +148,10 @@ CROSS_PLATFORM_UUIDOF(IDxcIntrinsicTable, "f0d4da3f-f863-4660-b8b4-dfd94ded6215" struct IDxcIntrinsicTable : public IUnknown { public: - virtual HRESULT STDMETHODCALLTYPE GetTableName(_Outptr_ LPCSTR *pTableName) = 0; - virtual HRESULT STDMETHODCALLTYPE LookupIntrinsic( - LPCWSTR typeName, LPCWSTR functionName, - const HLSL_INTRINSIC** pIntrinsic, - _Inout_ UINT64* pLookupCookie) = 0; + virtual HRESULT STDMETHODCALLTYPE GetTableName(LPCSTR *pTableName) = 0; + virtual HRESULT STDMETHODCALLTYPE + LookupIntrinsic(LPCWSTR typeName, LPCWSTR functionName, + const HLSL_INTRINSIC **pIntrinsic, UINT64 *pLookupCookie) = 0; // Get the lowering strategy for an hlsl extension intrinsic. virtual HRESULT STDMETHODCALLTYPE GetLoweringStrategy(UINT opcode, LPCSTR *pStrategy) = 0; @@ -192,11 +191,13 @@ struct IDxcLangExtensions : public IUnknown /// Registers a definition for compilation. virtual HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) = 0; /// Registers a table of built-in intrinsics. - virtual HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable* pTable) = 0; + virtual HRESULT STDMETHODCALLTYPE + RegisterIntrinsicTable(IDxcIntrinsicTable *pTable) = 0; /// Sets an (optional) validator for parsed semantic defines. /// This provides a hook to check that the semantic defines present in the source /// contain valid data. One validator is used to validate all parsed semantic defines. - virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) = 0; + virtual HRESULT STDMETHODCALLTYPE + SetSemanticDefineValidator(IDxcSemanticDefineValidator *pValidator) = 0; /// Sets the name for the root metadata node used in DXIL to hold the semantic defines. virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) = 0; }; @@ -219,51 +220,62 @@ struct IDxcSystemAccess : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName, IEnumSTATSTG** pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE OpenStorage( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, IUnknown** pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE SetStorageTime(_In_ IUnknown* storage, - _In_opt_ const FILETIME *lpCreationTime, - _In_opt_ const FILETIME *lpLastAccessTime, - _In_opt_ const FILETIME *lpLastWriteTime) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage(_In_ IUnknown* storage, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFileTypeForStorage(_In_ IUnknown* storage, _Out_ DWORD* fileType) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) = 0; - virtual HRESULT STDMETHODCALLTYPE MoveStorage(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFileAttributesForStorage(_In_ LPCWSTR lpFileName, _Out_ DWORD* pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE DeleteStorage(_In_ LPCWSTR lpFileName) = 0; + virtual HRESULT STDMETHODCALLTYPE OpenStorage(LPCWSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, + IUnknown **pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE SetStorageTime( + IUnknown *storage, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime) = 0; + virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage( + IUnknown *storage, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) = 0; + virtual HRESULT STDMETHODCALLTYPE GetFileTypeForStorage(IUnknown *storage, + DWORD *fileType) = 0; + virtual HRESULT STDMETHODCALLTYPE + CreateHardLinkInStorage(LPCWSTR lpFileName, LPCWSTR lpExistingFileName) = 0; + virtual HRESULT STDMETHODCALLTYPE MoveStorage(LPCWSTR lpExistingFileName, + LPCWSTR lpNewFileName, + DWORD dwFlags) = 0; + virtual HRESULT STDMETHODCALLTYPE + GetFileAttributesForStorage(LPCWSTR lpFileName, DWORD *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE DeleteStorage(LPCWSTR lpFileName) = 0; virtual HRESULT STDMETHODCALLTYPE RemoveDirectoryStorage(LPCWSTR lpFileName) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateDirectoryStorage(_In_ LPCWSTR lpPathName) = 0; - virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0; - virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0; - virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0; - virtual HRESULT STDMETHODCALLTYPE SupportsCreateSymbolicLink(_Out_ BOOL* pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) = 0; + virtual HRESULT STDMETHODCALLTYPE + CreateDirectoryStorage(LPCWSTR lpPathName) = 0; + virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage( + DWORD nBufferLength, LPWSTR lpBuffer, DWORD *written) = 0; + virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(DWORD nBufferLength, + LPWSTR lpBuffer, + DWORD *written) = 0; + virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength, + LPWSTR lpBuffer, + DWORD *written) = 0; + virtual HRESULT STDMETHODCALLTYPE + SupportsCreateSymbolicLink(BOOL *pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage( + LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName, DWORD dwFlags) = 0; virtual HRESULT STDMETHODCALLTYPE CreateStorageMapping( - _In_ IUnknown* hFile, - _In_ DWORD flProtect, - _In_ DWORD dwMaximumSizeHigh, - _In_ DWORD dwMaximumSizeLow, - _Outptr_ IUnknown** pResult) = 0; - virtual HRESULT MapViewOfFile( - _In_ IUnknown* hFileMappingObject, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwFileOffsetHigh, - _In_ DWORD dwFileOffsetLow, - _In_ SIZE_T dwNumberOfBytesToMap, - _Outptr_ ID3D10Blob** pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE OpenStdStorage(int standardFD, _Outptr_ IUnknown** pResult) = 0; - virtual HRESULT STDMETHODCALLTYPE GetStreamDisplay(_COM_Outptr_result_maybenull_ ITextFont** textFont, _Out_ unsigned* columnCount) = 0; + IUnknown *hFile, DWORD flProtect, DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow, IUnknown **pResult) = 0; + virtual HRESULT MapViewOfFile(IUnknown *hFileMappingObject, + DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, + DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap, + ID3D10Blob **pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE OpenStdStorage(int standardFD, + IUnknown **pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE GetStreamDisplay(ITextFont **textFont, + unsigned *columnCount) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcContainerEventsHandler, "e991ca8d-2045-413c-a8b8-788b2c06e14d") struct IDxcContainerEventsHandler : public IUnknown { public: - virtual HRESULT STDMETHODCALLTYPE OnDxilContainerBuilt(_In_ IDxcBlob *pSource, _Out_ IDxcBlob **ppTarget) = 0; + virtual HRESULT STDMETHODCALLTYPE + OnDxilContainerBuilt(IDxcBlob *pSource, IDxcBlob **ppTarget) = 0; }; CROSS_PLATFORM_UUIDOF(IDxcContainerEvent, "0cfc5058-342b-4ff2-83f7-04c12aad3d01") diff --git a/include/dxc/dxcdxrfallbackcompiler.h b/include/dxc/dxcdxrfallbackcompiler.h index 2da833d7fa..acfc96673d 100644 --- a/include/dxc/dxcdxrfallbackcompiler.h +++ b/include/dxc/dxcdxrfallbackcompiler.h @@ -55,45 +55,43 @@ struct __declspec(uuid("76bb3c85-006d-4b72-9e10-63cd97df57f0")) virtual HRESULT STDMETHODCALLTYPE SetDebugOutput(int val) = 0; virtual HRESULT STDMETHODCALLTYPE RenameAndLink( - _In_count_(libCount) DxcShaderBytecode *pLibs, - UINT32 libCount, - _In_count_(ExportCount) DxcExportDesc *pExports, - UINT32 ExportCount, - _COM_Outptr_ IDxcOperationResult **ppResult - ) = 0; + DxcShaderBytecode *pLibs, UINT32 libCount, DxcExportDesc *pExports, + UINT32 ExportCount, IDxcOperationResult **ppResult) = 0; virtual HRESULT STDMETHODCALLTYPE PatchShaderBindingTables( - _In_ const LPCWSTR pEntryName, - _In_ DxcShaderBytecode *pShaderBytecode, - _In_ void *pShaderInfo, - _COM_Outptr_ IDxcOperationResult **ppResult - ) = 0; + const LPCWSTR pEntryName, DxcShaderBytecode *pShaderBytecode, + void *pShaderInfo, IDxcOperationResult **ppResult) = 0; // Compiles libs together to create a raytracing compute shader. One of the libs // should be the fallback implementation lib that defines functions like // Fallback_TraceRay(), Fallback_ReportHit(), etc. Fallback_TraceRay() should - // be one of the shader names so that it gets included in the compile. + // be one of the shader names so that it gets included in the compile. virtual HRESULT STDMETHODCALLTYPE Compile( - _In_count_(libCount) DxcShaderBytecode *pLibs, // Array of libraries containing shaders - UINT32 libCount, // Number of libraries containing shaders - _In_count_(shaderCount) const LPCWSTR *pShaderNames, // Array of shader names to compile - _Out_writes_(shaderCount) DxcShaderInfo *pShaderInfo, // Array of shaderInfo corresponding to pShaderNames - UINT32 shaderCount, // Number of shaders to compile - UINT32 maxAttributeSize, - _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors - ) = 0; + DxcShaderBytecode *pLibs, // Array of libraries containing shaders + UINT32 libCount, // Number of libraries containing shaders + const LPCWSTR *pShaderNames, // Array of shader names to compile + DxcShaderInfo + *pShaderInfo, // Array of shaderInfo corresponding to pShaderNames + UINT32 shaderCount, // Number of shaders to compile + UINT32 maxAttributeSize, + IDxcOperationResult * + *ppResult // Compiler output status, buffer, and errors + ) = 0; virtual HRESULT STDMETHODCALLTYPE Link( - _In_ const LPCWSTR pEntryName, // Name of entry function, null if compiling a collection - _In_count_(libCount) IDxcBlob **pLibs, // Array of libraries containing shaders - UINT32 libCount, // Number of libraries containing shaders - _In_count_(shaderCount) const LPCWSTR *pShaderNames, // Array of shader names to compile - _In_count_(shaderCount) DxcShaderInfo *pShaderInfo, // Array of shaderInfo corresponding to pShaderNames - UINT32 shaderCount, // Number of shaders to compile + const LPCWSTR + pEntryName, // Name of entry function, null if compiling a collection + IDxcBlob **pLibs, // Array of libraries containing shaders + UINT32 libCount, // Number of libraries containing shaders + const LPCWSTR *pShaderNames, // Array of shader names to compile + DxcShaderInfo + *pShaderInfo, // Array of shaderInfo corresponding to pShaderNames + UINT32 shaderCount, // Number of shaders to compile UINT32 maxAttributeSize, - UINT32 stackSizeInBytes, // Continuation stack size. Use 0 for default. - _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors - ) = 0; + UINT32 stackSizeInBytes, // Continuation stack size. Use 0 for default. + IDxcOperationResult * + *ppResult // Compiler output status, buffer, and errors + ) = 0; }; // Note: __declspec(selectany) requires 'extern' @@ -112,10 +110,8 @@ CLSID_SCOPE const GUID CLSID_DxcDxrFallbackCompiler = { { 0x9e, 0x10, 0x63, 0xcd, 0x97, 0xdf, 0x57, 0xf0 } }; -typedef HRESULT(__stdcall *DxcCreateDxrFallbackCompilerProc)( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID* ppv - ); +typedef HRESULT(__stdcall *DxcCreateDxrFallbackCompilerProc)(REFCLSID rclsid, + REFIID riid, + LPVOID *ppv); #endif diff --git a/include/dxc/dxctools.h b/include/dxc/dxctools.h index 59527b163c..bfdc0d86f7 100644 --- a/include/dxc/dxctools.h +++ b/include/dxc/dxctools.h @@ -25,27 +25,21 @@ enum RewriterOptionMask { CROSS_PLATFORM_UUIDOF(IDxcRewriter, "c012115b-8893-4eb9-9c5a-111456ea1c45") struct IDxcRewriter : public IUnknown { - virtual HRESULT STDMETHODCALLTYPE RemoveUnusedGlobals(_In_ IDxcBlobEncoding *pSource, - _In_z_ LPCWSTR entryPoint, - _In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount, - _COM_Outptr_ IDxcOperationResult **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE RemoveUnusedGlobals( + IDxcBlobEncoding *pSource, LPCWSTR entryPoint, DxcDefine *pDefines, + UINT32 defineCount, IDxcOperationResult **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE + RewriteUnchanged(IDxcBlobEncoding *pSource, DxcDefine *pDefines, + UINT32 defineCount, IDxcOperationResult **ppResult) = 0; - virtual HRESULT STDMETHODCALLTYPE RewriteUnchanged(_In_ IDxcBlobEncoding *pSource, - _In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount, - _COM_Outptr_ IDxcOperationResult **ppResult) = 0; - - virtual HRESULT STDMETHODCALLTYPE RewriteUnchangedWithInclude(_In_ IDxcBlobEncoding *pSource, - // Optional file name for pSource. Used in errors and include handlers. - _In_opt_ LPCWSTR pSourceName, - _In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount, - // user-provided interface to handle #include directives (optional) - _In_opt_ IDxcIncludeHandler *pIncludeHandler, - _In_ UINT32 rewriteOption, - _COM_Outptr_ IDxcOperationResult **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE RewriteUnchangedWithInclude( + IDxcBlobEncoding *pSource, + // Optional file name for pSource. Used in errors and include handlers. + LPCWSTR pSourceName, DxcDefine *pDefines, UINT32 defineCount, + // user-provided interface to handle #include directives (optional) + IDxcIncludeHandler *pIncludeHandler, UINT32 rewriteOption, + IDxcOperationResult **ppResult) = 0; }; #ifdef _MSC_VER @@ -64,16 +58,16 @@ CLSID_SCOPE const CLSID CROSS_PLATFORM_UUIDOF(IDxcRewriter2, "261afca1-0609-4ec6-a77f-d98c7035194e") struct IDxcRewriter2 : public IDxcRewriter { - virtual HRESULT STDMETHODCALLTYPE RewriteWithOptions(_In_ IDxcBlobEncoding *pSource, - // Optional file name for pSource. Used in errors and include handlers. - _In_opt_ LPCWSTR pSourceName, - // Compiler arguments - _In_count_(argCount) LPCWSTR *pArguments, _In_ UINT32 argCount, - // Defines - _In_count_(defineCount) DxcDefine *pDefines, _In_ UINT32 defineCount, - // user-provided interface to handle #include directives (optional) - _In_opt_ IDxcIncludeHandler *pIncludeHandler, - _COM_Outptr_ IDxcOperationResult **ppResult) = 0; + virtual HRESULT STDMETHODCALLTYPE RewriteWithOptions( + IDxcBlobEncoding *pSource, + // Optional file name for pSource. Used in errors and include handlers. + LPCWSTR pSourceName, + // Compiler arguments + LPCWSTR *pArguments, UINT32 argCount, + // Defines + DxcDefine *pDefines, UINT32 defineCount, + // user-provided interface to handle #include directives (optional) + IDxcIncludeHandler *pIncludeHandler, IDxcOperationResult **ppResult) = 0; }; #endif diff --git a/include/llvm-c/Analysis.h b/include/llvm-c/Analysis.h index 7f8a799685..f0bdddc50a 100644 --- a/include/llvm-c/Analysis.h +++ b/include/llvm-c/Analysis.h @@ -43,7 +43,7 @@ typedef enum { Optionally returns a human-readable description of any invalid constructs. OutMessage must be disposed with LLVMDisposeMessage. */ LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, - _Outptr_opt_ char **OutMessage); + char **OutMessage); /* Verifies that a single function is valid, taking the specified action. Useful for debugging. */ diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index b0c49dfcf7..a20d54ce53 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -15,7 +15,6 @@ #ifndef LLVM_C_CORE_H #define LLVM_C_CORE_H -#include "dxc/WinAdapter.h" // HLSL Change #include "llvm-c/Support.h" #ifdef __cplusplus @@ -433,7 +432,7 @@ void LLVMShutdown(void); /*===-- Error handling ----------------------------------------------------===*/ char *LLVMCreateMessage(const char *Message); -void LLVMDisposeMessage(_Out_opt_ char *Message); +void LLVMDisposeMessage(char *Message); typedef void (*LLVMFatalErrorHandler)(const char *Reason); @@ -617,7 +616,7 @@ void LLVMDumpModule(LLVMModuleRef M); * @see Module::print() */ LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, - _Out_opt_ char **ErrorMessage); + char **ErrorMessage); /** * Return a string representation of the module. Use @@ -2902,9 +2901,9 @@ void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, - _Out_opt_ char **OutMessage); + char **OutMessage); LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, - _Out_opt_ char **OutMessage); + char **OutMessage); LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h index 7cc8f88145..c70618040b 100644 --- a/include/llvm-c/Disassembler.h +++ b/include/llvm-c/Disassembler.h @@ -242,7 +242,7 @@ void LLVMDisasmDispose(LLVMDisasmContextRef DC); */ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, - _Out_writes_z_(OutStringSize) char *OutString, size_t OutStringSize); // HLSL Change: annotation + char *OutString, size_t OutStringSize); /** * @} diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 94861a5842..eb3ecabfa8 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -74,16 +74,16 @@ void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal); LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE, LLVMModuleRef M, - _Out_opt_ char **OutError); + char **OutError); LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp, LLVMModuleRef M, - _Out_opt_ char **OutError); + char **OutError); LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, unsigned OptLevel, - _Out_opt_ char **OutError); + char **OutError); void LLVMInitializeMCJITCompilerOptions( struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions); @@ -108,23 +108,23 @@ void LLVMInitializeMCJITCompilerOptions( LLVMBool LLVMCreateMCJITCompilerForModule( LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions, - _Out_opt_ char **OutError); + char **OutError); /** Deprecated: Use LLVMCreateExecutionEngineForModule instead. */ LLVMBool LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE, LLVMModuleProviderRef MP, - _Out_opt_ char **OutError); + char **OutError); /** Deprecated: Use LLVMCreateInterpreterForModule instead. */ LLVMBool LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp, LLVMModuleProviderRef MP, - _Out_opt_ char **OutError); + char **OutError); /** Deprecated: Use LLVMCreateJITCompilerForModule instead. */ LLVMBool LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT, LLVMModuleProviderRef MP, unsigned OptLevel, - _Out_opt_ char **OutError); + char **OutError); void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE); @@ -148,12 +148,12 @@ void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M); void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP); LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M, - LLVMModuleRef *OutMod, _Out_opt_ char **OutError); + LLVMModuleRef *OutMod, char **OutError); /** Deprecated: Use LLVMRemoveModule instead. */ LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP, - LLVMModuleRef *OutMod, _Out_opt_ char **OutError); + LLVMModuleRef *OutMod, char **OutError); LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name, LLVMValueRef *OutFn); diff --git a/include/llvm-c/Linker.h b/include/llvm-c/Linker.h index 67725a4198..9f98a3342d 100644 --- a/include/llvm-c/Linker.h +++ b/include/llvm-c/Linker.h @@ -36,7 +36,7 @@ typedef enum { * Note that the linker mode parameter \p Unused is no longer used, and has * no effect. */ LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, - LLVMLinkerMode Unused, _Outptr_result_maybenull_ char **OutMessage); + LLVMLinkerMode Unused, char **OutMessage); #ifdef __cplusplus } diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h index 0c74678856..1d0e914b11 100644 --- a/include/llvm-c/TargetMachine.h +++ b/include/llvm-c/TargetMachine.h @@ -72,7 +72,7 @@ LLVMTargetRef LLVMGetTargetFromName(const char *Name); LLVMBool LLVMGetTargetFromTriple( const char* Triple, LLVMTargetRef *T, - _Out_opt_ char **ErrorMessage); + char **ErrorMessage); /** Returns the name of a target. See llvm::Target::getName */ const char *LLVMGetTargetName(LLVMTargetRef T); @@ -128,13 +128,13 @@ void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, wraps several c++ only classes (among them a file stream). Returns any error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, - _In_ char *Filename, LLVMCodeGenFileType codegen, - _Out_opt_ char **ErrorMessage); + char *Filename, LLVMCodeGenFileType codegen, + char **ErrorMessage); /** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */ LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, - _Out_opt_ char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf); + char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf); /*===-- Triple ------------------------------------------------------------===*/ /** Get a triple for the host machine as a string. The result needs to be diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index 966a488d22..14bcd84919 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -387,7 +387,7 @@ class APFloat { /// Write out a hexadecimal representation of the floating point value to DST, /// which must be of sufficient size, in the C99 form [-]0xh.hhhhp[+-]d. /// Return the number of characters written, excluding the terminating NUL. - unsigned int convertToHexString(_In_ char *dst, unsigned int hexDigits, + unsigned int convertToHexString(char *dst, unsigned int hexDigits, bool upperCase, roundingMode) const; #endif // HLSL Change @@ -595,7 +595,7 @@ class APFloat { opStatus convertFromDecimalString(StringRef, roundingMode); #if 0 // HLSL Change - dst should be _Out_writes_(constant), but this turns out to be unused in any case char *convertNormalToHexString( - _In_ char *dst, + char *dst, unsigned int hexDigits, bool upperCase, roundingMode rounding_mode) const; diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index 1ec96c5494..462fcd6120 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -357,7 +357,7 @@ template class FoldingSetBucketIterator; // require the definition of FoldingSetNodeID. template inline bool -DefaultFoldingSetTrait::Equals(_In_ T &X, const FoldingSetNodeID &ID, +DefaultFoldingSetTrait::Equals(T &X, const FoldingSetNodeID &ID, unsigned /*IDHash*/, FoldingSetNodeID &TempID) { FoldingSetTrait::Profile(X, TempID); @@ -527,7 +527,7 @@ class ContextualFoldingSet final : public FoldingSetImpl { /// FindNodeOrInsertPos - Look up the node specified by ID. If it /// exists, return it. If not, return the insertion token that will /// make insertion faster. - T *FindNodeOrInsertPos(_In_ const FoldingSetNodeID &ID, void *&InsertPos) { + T *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos) { return static_cast(FoldingSetImpl::FindNodeOrInsertPos(ID, InsertPos)); } }; diff --git a/include/llvm/Analysis/DependenceAnalysis.h b/include/llvm/Analysis/DependenceAnalysis.h index 528b169360..a08ce574ea 100644 --- a/include/llvm/Analysis/DependenceAnalysis.h +++ b/include/llvm/Analysis/DependenceAnalysis.h @@ -268,7 +268,7 @@ namespace llvm { unsigned short Levels; bool LoopIndependent; bool Consistent; // Init to true, then refine. - _Field_size_opt_(Levels) DVEntry *DV; + DVEntry *DV; friend class DependenceAnalysis; }; diff --git a/include/llvm/CodeGen/LexicalScopes.h b/include/llvm/CodeGen/LexicalScopes.h index c647c4cba8..50ddbc399d 100644 --- a/include/llvm/CodeGen/LexicalScopes.h +++ b/include/llvm/CodeGen/LexicalScopes.h @@ -100,7 +100,7 @@ class LexicalScope { } /// dominates - Return true if current scope dominates given lexical scope. - bool dominates(_In_ const LexicalScope *S) const { + bool dominates(const LexicalScope *S) const { if (S == this) return true; if (DFSIn < S->getDFSIn() && DFSOut > S->getDFSOut()) diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index ff7662f152..2ecd24381d 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -230,7 +230,7 @@ class Type { /// are valid for types of the same size only where no re-interpretation of /// the bits is done. /// @brief Determine if this type could be losslessly bitcast to Ty - bool canLosslesslyBitCastTo(_In_ Type *Ty) const; + bool canLosslesslyBitCastTo(Type *Ty) const; /// isEmptyTy - Return true if this type is empty, that is, it has no /// elements or all its elements are empty. diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index f7b2c8279d..7c852fadb5 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -530,7 +530,7 @@ class MCStreamer { /// \brief Special case of EmitValue that avoids the client having /// to pass in a MCExpr for constant integers. - virtual void EmitIntValue(uint64_t Value, _In_range_(0, 8) unsigned Size); + virtual void EmitIntValue(uint64_t Value, unsigned Size); virtual void EmitULEB128Value(const MCExpr *Value); diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index bca7ac0ad4..b9911229bf 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -90,7 +90,6 @@ class MallocAllocator : public AllocatorBase { public: void Reset() {} - _Ret_notnull_ // HLSL Change - SAL LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, size_t /*Alignment*/) { return ::operator new(Size); // HLSL Change: use overridable operator new and throw on OOM diff --git a/include/llvm/Support/ConvertUTF.h b/include/llvm/Support/ConvertUTF.h index 0513a72e46..1ba53e85b0 100644 --- a/include/llvm/Support/ConvertUTF.h +++ b/include/llvm/Support/ConvertUTF.h @@ -196,7 +196,7 @@ namespace llvm { * \return true on success. */ bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, - _Out_cap_x_(WideCharWidth * (Source.Size() + 1)) char *&ResultPtr, const UTF8 *&ErrorPtr); // HLSL Change + char *&ResultPtr, const UTF8 *&ErrorPtr); /** * Convert an Unicode code point to UTF8 sequence. @@ -208,7 +208,7 @@ bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, * * \returns true on success. */ -bool ConvertCodePointToUTF8(unsigned Source, _Inout_cap_(UNI_MAX_UTF8_BYTES_PER_CODE_POINT) char *&ResultPtr); // HLSL Change +bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr); /** * Convert the first UTF8 sequence in the given source buffer to a UTF32 diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 4ccd2954b8..15f883ac13 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -52,7 +52,7 @@ namespace fs { // HLSL Change Start class MSFileSystem; -typedef _Inout_ MSFileSystem* MSFileSystemRef; +typedef MSFileSystem* MSFileSystemRef; std::error_code GetFileSystemTlsStatus() throw(); @@ -81,7 +81,7 @@ class AutoPerThreadSystem ::llvm::sys::fs::MSFileSystem* m_pOrigValue; std::error_code ec; public: - AutoPerThreadSystem(_In_ ::llvm::sys::fs::MSFileSystem *value) + AutoPerThreadSystem(::llvm::sys::fs::MSFileSystem *value) : m_pOrigValue(::llvm::sys::fs::GetCurrentThreadFileSystem()) { SetCurrentThreadFileSystem(nullptr); ec = ::llvm::sys::fs::SetCurrentThreadFileSystem(value); diff --git a/include/llvm/Support/Format.h b/include/llvm/Support/Format.h index 67ee193e2b..ef39e63a57 100644 --- a/include/llvm/Support/Format.h +++ b/include/llvm/Support/Format.h @@ -43,7 +43,7 @@ class format_object_base { virtual void home(); // Out of line virtual method. /// Call snprintf() for this object, on the given buffer and size. - virtual int snprint(_Out_ char *Buffer, unsigned BufferSize) const = 0; // HLSL Change - SAL + virtual int snprint(char *Buffer, unsigned BufferSize) const = 0; public: format_object_base(const char *fmt) : Fmt(fmt) {} @@ -51,7 +51,7 @@ class format_object_base { /// Format the object into the specified buffer. On success, this returns /// the length of the formatted string. If the buffer is too small, this /// returns a length to retry with, which will be larger than BufferSize. - unsigned print(_Out_ char *Buffer, unsigned BufferSize) const { // HLSL Change - SAL + unsigned print(char *Buffer, unsigned BufferSize) const { assert(BufferSize && "Invalid buffer size!"); // Print the string, leaving room for the terminating null. diff --git a/include/llvm/Support/MSFileSystem.h b/include/llvm/Support/MSFileSystem.h index da180b8d09..fe8d173931 100644 --- a/include/llvm/Support/MSFileSystem.h +++ b/include/llvm/Support/MSFileSystem.h @@ -17,60 +17,55 @@ struct stat; namespace llvm { -namespace sys { +namespace sys { namespace fs { -class MSFileSystem -{ +class MSFileSystem { public: - virtual ~MSFileSystem() { }; - virtual BOOL FindNextFileW( - _In_ HANDLE hFindFile, - _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() = 0; - virtual HANDLE FindFirstFileW( - _In_ LPCWSTR lpFileName, - _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() = 0; + virtual ~MSFileSystem(){}; + virtual BOOL FindNextFileW(HANDLE hFindFile, + LPWIN32_FIND_DATAW lpFindFileData) throw() = 0; + virtual HANDLE FindFirstFileW(LPCWSTR lpFileName, + LPWIN32_FIND_DATAW lpFindFileData) throw() = 0; virtual void FindClose(HANDLE findHandle) throw() = 0; - virtual HANDLE CreateFileW( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes) throw() = 0; - virtual BOOL SetFileTime(_In_ HANDLE hFile, - _In_opt_ const FILETIME *lpCreationTime, - _In_opt_ const FILETIME *lpLastAccessTime, - _In_opt_ const FILETIME *lpLastWriteTime) throw() = 0; - virtual BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() = 0; - virtual DWORD GetFileType(_In_ HANDLE hFile) throw() = 0; - virtual BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() = 0; - virtual BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() = 0; - virtual DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() = 0; - virtual BOOL CloseHandle(_In_ HANDLE hObject) throw() = 0; - virtual BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() = 0; - virtual BOOL RemoveDirectoryW(_In_ LPCWSTR lpFileName) throw() = 0; - virtual BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() = 0; - _Success_(return != 0 && return < nBufferLength) - virtual DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() = 0; - _Success_(return != 0 && return < nSize) - virtual DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return + 1) LPWSTR lpFilename, DWORD nSize) throw() = 0; - virtual DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() = 0; - virtual BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() = 0; + virtual HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, + DWORD dwShareMode, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes) throw() = 0; + virtual BOOL SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) throw() = 0; + virtual BOOL GetFileInformationByHandle( + HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() = 0; + virtual DWORD GetFileType(HANDLE hFile) throw() = 0; + virtual BOOL CreateHardLinkW(LPCWSTR lpFileName, + LPCWSTR lpExistingFileName) throw() = 0; + virtual BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, + DWORD dwFlags) throw() = 0; + virtual DWORD GetFileAttributesW(LPCWSTR lpFileName) throw() = 0; + virtual BOOL CloseHandle(HANDLE hObject) throw() = 0; + virtual BOOL DeleteFileW(LPCWSTR lpFileName) throw() = 0; + virtual BOOL RemoveDirectoryW(LPCWSTR lpFileName) throw() = 0; + virtual BOOL CreateDirectoryW(LPCWSTR lpPathName) throw() = 0; + virtual DWORD GetCurrentDirectoryW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() = 0; + virtual DWORD GetMainModuleFileNameW(LPWSTR lpFilename, + DWORD nSize) throw() = 0; + virtual DWORD GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) throw() = 0; + virtual BOOLEAN CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, + LPCWSTR lpTargetFileName, + DWORD dwFlags) throw() = 0; virtual bool SupportsCreateSymbolicLink() throw() = 0; - virtual BOOL ReadFile(_In_ HANDLE hFile, _Out_bytecap_(nNumberOfBytesToRead) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() = 0; - virtual HANDLE CreateFileMappingW( - _In_ HANDLE hFile, - _In_ DWORD flProtect, - _In_ DWORD dwMaximumSizeHigh, - _In_ DWORD dwMaximumSizeLow) throw() = 0; - virtual LPVOID MapViewOfFile( - _In_ HANDLE hFileMappingObject, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwFileOffsetHigh, - _In_ DWORD dwFileOffsetLow, - _In_ SIZE_T dwNumberOfBytesToMap) throw() = 0; - virtual BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() = 0; - + virtual BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() = 0; + virtual HANDLE CreateFileMappingW(HANDLE hFile, DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow) throw() = 0; + virtual LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap) throw() = 0; + virtual BOOL UnmapViewOfFile(LPCVOID lpBaseAddress) throw() = 0; + // Console APIs. virtual bool FileDescriptorIsDisplayed(int fd) throw() = 0; virtual unsigned GetColumnCount(DWORD nStdHandle) throw() = 0; @@ -84,30 +79,34 @@ class MSFileSystem virtual int close(int fd) throw() = 0; virtual long lseek(int fd, long offset, int origin) throw() = 0; virtual int setmode(int fd, int mode) throw() = 0; - virtual errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() = 0; // A number of C calls. - virtual int Read(int fd, _Out_bytecap_(count) void* buffer, unsigned int count) throw() = 0; - virtual int Write(int fd, _In_bytecount_(count) const void* buffer, unsigned int count) throw() = 0; + virtual errno_t resize_file(LPCWSTR path, uint64_t size) throw() = 0; + virtual int Read(int fd, void *buffer, unsigned int count) throw() = 0; + virtual int Write(int fd, const void *buffer, unsigned int count) throw() = 0; // Unix interface #ifndef _WIN32 - virtual int Open(const char *lpFileName, int flags, mode_t mode = 0) throw() = 0; + virtual int Open(const char *lpFileName, int flags, + mode_t mode = 0) throw() = 0; virtual int Stat(const char *lpFileName, struct stat *Status) throw() = 0; virtual int Fstat(int FD, struct stat *Status) throw() = 0; #endif }; - } // end namespace fs } // end namespace sys } // end namespace llvm -/// Creates a Win32/CRT-based implementation with full fidelity for a console program. -/// This requires the LLVM MS Support library to be linked in. -HRESULT CreateMSFileSystemForDisk(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw(); +/// Creates a Win32/CRT-based implementation with full fidelity for a +/// console program. This requires the LLVM MS Support +/// library to be linked in. +HRESULT +CreateMSFileSystemForDisk(::llvm::sys::fs::MSFileSystem **pResult) throw(); struct IUnknown; /// Creates an implementation based on IDxcSystemAccess. -HRESULT CreateMSFileSystemForIface(_In_ IUnknown* pService, _COM_Outptr_::llvm::sys::fs::MSFileSystem** pResult) throw(); +HRESULT +CreateMSFileSystemForIface(IUnknown *pService, + ::llvm::sys::fs::MSFileSystem **pResult) throw(); #endif // LLVM_SUPPORT_MSFILESYSTEM_H diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index a788b702f0..b8fa9df1df 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -306,7 +306,7 @@ class raw_ostream { /// Use the provided buffer as the raw_ostream buffer. This is intended for /// use only by subclasses which can arrange for the output to go directly /// into the desired output buffer, instead of being copied on each flush. - void SetBuffer(_Out_opt_ char *BufferStart, size_t Size) { // HLSL Change - SAL + void SetBuffer(char *BufferStart, size_t Size) { SetBufferAndMode(BufferStart, Size, ExternalBuffer); } @@ -322,7 +322,7 @@ class raw_ostream { //===--------------------------------------------------------------------===// private: /// Install the given buffer and mode. - void SetBufferAndMode(_Out_opt_ char *BufferStart, size_t Size, BufferKind Mode); // HLSL Change - SAL + void SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode); /// Flush the current buffer, which is known to be non-empty. This outputs the /// currently buffered data and resets the buffer to empty. diff --git a/include/llvm/TableGen/Main.h b/include/llvm/TableGen/Main.h index 664bb6ba3f..1a02690102 100644 --- a/include/llvm/TableGen/Main.h +++ b/include/llvm/TableGen/Main.h @@ -30,7 +30,7 @@ class raw_ostream; /// \returns true on error, false otherwise typedef bool TableGenMainFn(raw_ostream &OS, RecordKeeper &Records); -int TableGenMain(_In_z_ char *argv0, _In_ TableGenMainFn *MainFn); // HLSL Change - SAL +int TableGenMain(char *argv0, TableGenMainFn *MainFn); } #endif diff --git a/lib/Analysis/Analysis.cpp b/lib/Analysis/Analysis.cpp index 74d275551a..beb28e8b60 100644 --- a/lib/Analysis/Analysis.cpp +++ b/lib/Analysis/Analysis.cpp @@ -97,7 +97,6 @@ void LLVMInitializeAnalysis(LLVMPassRegistryRef R) { initializeAnalysis(*unwrap(R)); } -_Use_decl_annotations_ LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, char **OutMessages) { raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr; diff --git a/lib/Analysis/DependenceAnalysis.cpp b/lib/Analysis/DependenceAnalysis.cpp index c054a4077c..d71d676718 100644 --- a/lib/Analysis/DependenceAnalysis.cpp +++ b/lib/Analysis/DependenceAnalysis.cpp @@ -245,7 +245,7 @@ FullDependence::FullDependence(Instruction *Source, Instruction *Destination, // getDirection - Returns the direction associated with a particular level. unsigned FullDependence::getDirection(unsigned Level) const { assert(0 < Level && Level <= Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Levels); // HLSL Change - TVS return DV[Level - 1].Direction; } @@ -253,7 +253,7 @@ unsigned FullDependence::getDirection(unsigned Level) const { // Returns the distance (or NULL) associated with a particular level. const SCEV *FullDependence::getDistance(unsigned Level) const { assert(0 < Level && Level <= Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Levels); // HLSL Change - TVS return DV[Level - 1].Distance; } @@ -263,7 +263,7 @@ const SCEV *FullDependence::getDistance(unsigned Level) const { // variable associated with the loop at this level. bool FullDependence::isScalar(unsigned Level) const { assert(0 < Level && Level <= Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Levels); // HLSL Change - TVS return DV[Level - 1].Scalar; } @@ -272,7 +272,7 @@ bool FullDependence::isScalar(unsigned Level) const { // will break this dependence. bool FullDependence::isPeelFirst(unsigned Level) const { assert(0 < Level && Level <= Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Levels); // HLSL Change - TVS return DV[Level - 1].PeelFirst; } @@ -281,7 +281,7 @@ bool FullDependence::isPeelFirst(unsigned Level) const { // will break this dependence. bool FullDependence::isPeelLast(unsigned Level) const { assert(0 < Level && Level <= Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Levels); // HLSL Change - TVS return DV[Level - 1].PeelLast; } @@ -289,7 +289,7 @@ bool FullDependence::isPeelLast(unsigned Level) const { // Returns true if splitting this loop will break the dependence. bool FullDependence::isSplitable(unsigned Level) const { assert(0 < Level && Level <= Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Levels); // HLSL Change - TVS return DV[Level - 1].Splitable; } @@ -1099,8 +1099,8 @@ bool DependenceAnalysis::strongSIVtest(const SCEV *Coeff, DEBUG(dbgs() << ", " << *DstConst->getType() << "\n"); ++StrongSIVapplications; assert(0 < Level && Level <= CommonLevels && "level out of range"); - _Analysis_assume_(0 < Level && Level <= CommonLevels); // HLSL Change - TVS - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(0 < Level && Level <= CommonLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS Level--; const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst); @@ -1238,8 +1238,8 @@ bool DependenceAnalysis::weakCrossingSIVtest(const SCEV *Coeff, DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++WeakCrossingSIVapplications; assert(0 < Level && Level <= CommonLevels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= CommonLevels); // HLSL Change - TVS - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(0 < Level && Level <= CommonLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS Level--; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); @@ -1463,8 +1463,8 @@ bool DependenceAnalysis::exactSIVtest(const SCEV *SrcCoeff, DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++ExactSIVapplications; assert(0 < Level && Level <= CommonLevels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= CommonLevels); // HLSL Change - TVS - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(0 < Level && Level <= CommonLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS Level--; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); @@ -1678,8 +1678,8 @@ bool DependenceAnalysis::weakZeroSrcSIVtest(const SCEV *DstCoeff, DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++WeakZeroSIVapplications; assert(0 < Level && Level <= MaxLevels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= MaxLevels); // HLSL Change - TVS - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(0 < Level && Level <= MaxLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS Level--; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst); @@ -1790,8 +1790,8 @@ bool DependenceAnalysis::weakZeroDstSIVtest(const SCEV *SrcCoeff, DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++WeakZeroSIVapplications; assert(0 < Level && Level <= SrcLevels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= SrcLevels); // HLSL Change - TVS - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(0 < Level && Level <= SrcLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS Level--; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); @@ -2474,7 +2474,7 @@ bool DependenceAnalysis::gcdMIVtest(const SCEV *Src, if (Remainder != 0) { unsigned Level = mapSrcLoop(CurLoop); assert(0 < Level && Level <= Result.Levels && "Level out of range"); - _Analysis_assume_(0 < Level && Level <= Result.Levels); // HLSL Change - TVS + assert(0 < Level && Level <= Result.Levels); // HLSL Change - TVS Result.DV[Level - 1].Direction &= unsigned(~Dependence::DVEntry::EQ); Improved = true; } @@ -2567,8 +2567,8 @@ bool DependenceAnalysis::banerjeeMIVtest(const SCEV *Src, bool Improved = false; for (unsigned K = 1; K <= CommonLevels; ++K) { if (Loops[K]) { - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS - _Analysis_assume_(K <= MaxLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(K <= MaxLevels); // HLSL Change - TVS unsigned Old = Result.DV[K - 1].Direction; Result.DV[K - 1].Direction = Old & Bound[K].DirSet; Improved |= Old != Result.DV[K - 1].Direction; @@ -3407,7 +3407,7 @@ DependenceAnalysis::depends(Instruction *Src, Instruction *Dst, DEBUG(dbgs() << " maximum nesting levels = " << MaxLevels << "\n"); FullDependence Result(Src, Dst, PossiblyLoopIndependent, CommonLevels); - _Analysis_assume_(Result.Levels == CommonLevels); // HLSL Change - TVS + assert(Result.Levels == CommonLevels); // HLSL Change - TVS ++TotalArrayPairs; // See if there are GEPs we can use. diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp index f862a8b1ef..1e2d8d9ad3 100644 --- a/lib/CodeGen/RegAllocGreedy.cpp +++ b/lib/CodeGen/RegAllocGreedy.cpp @@ -979,7 +979,7 @@ void RAGreedy::addThroughConstraints(InterferenceCache::Cursor Intf, if (!Intf.hasInterference()) { assert(T < GroupSize && "Array overflow"); - _Analysis_assume_(T < GroupSize); // This is reset to zero when it reaches GroupSize + assert(T < GroupSize); // This is reset to zero when it reaches GroupSize TBS[T] = Number; if (++T == GroupSize) { SpillPlacer->addLinks(makeArrayRef(TBS, T)); @@ -989,7 +989,7 @@ void RAGreedy::addThroughConstraints(InterferenceCache::Cursor Intf, } assert(B < GroupSize && "Array overflow"); - _Analysis_assume_(B < GroupSize); // This is reset to zero when it reaches GroupSize + assert(B < GroupSize); // This is reset to zero when it reaches GroupSize BCS[B].Number = Number; // Interference for the live-in value. diff --git a/lib/DXIL/DxilModule.cpp b/lib/DXIL/DxilModule.cpp index e39080041a..6440e4928c 100644 --- a/lib/DXIL/DxilModule.cpp +++ b/lib/DXIL/DxilModule.cpp @@ -388,7 +388,7 @@ unsigned DxilModule::GetNumThreads(unsigned idx) const { (m_pSM->IsCS() || m_pSM->IsMS() || m_pSM->IsAS()), "only works for CS/MS/AS profiles"); DXASSERT(idx < 3, "Thread dimension index must be 0-2"); - __analysis_assume(idx < 3); + assert(idx < 3); if (!(m_pSM->IsCS() || m_pSM->IsMS() || m_pSM->IsAS())) return 0; const DxilFunctionProps &props = m_DxilEntryPropsMap.begin()->second->props; diff --git a/lib/DXIL/DxilOperations.cpp b/lib/DXIL/DxilOperations.cpp index e72521d471..892f90f1bb 100644 --- a/lib/DXIL/DxilOperations.cpp +++ b/lib/DXIL/DxilOperations.cpp @@ -1080,7 +1080,7 @@ void OP::UpdateCache(OpCodeClass opClass, Type * Ty, llvm::Function *F) { Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) { DXASSERT(0 <= (unsigned)opCode && opCode < OpCode::NumOpCodes, "otherwise caller passed OOB OpCode"); - _Analysis_assume_(0 <= (unsigned)opCode && opCode < OpCode::NumOpCodes); + assert(0 <= (unsigned)opCode && opCode < OpCode::NumOpCodes); DXASSERT(IsOverloadLegal(opCode, pOverloadType), "otherwise the caller requested illegal operation overload (eg HLSL function with unsupported types for mapped intrinsic function)"); OpCodeClass opClass = m_OpCodeProps[(unsigned)opCode].opCodeClass; Function *&F = m_OpCodeClassCache[(unsigned)opClass].pOverloads[pOverloadType]; @@ -1531,7 +1531,7 @@ const SmallMapVector & OP::GetOpFuncList(OpCode opCode) const { DXASSERT(0 <= (unsigned)opCode && opCode < OpCode::NumOpCodes, "otherwise caller passed OOB OpCode"); - _Analysis_assume_(0 <= (unsigned)opCode && opCode < OpCode::NumOpCodes); + assert(0 <= (unsigned)opCode && opCode < OpCode::NumOpCodes); return m_OpCodeClassCache[(unsigned)m_OpCodeProps[(unsigned)opCode] .opCodeClass] .pOverloads; diff --git a/lib/DxcSupport/FileIOHelper.cpp b/lib/DxcSupport/FileIOHelper.cpp index c39ec139bb..0838583b8e 100644 --- a/lib/DxcSupport/FileIOHelper.cpp +++ b/lib/DxcSupport/FileIOHelper.cpp @@ -44,39 +44,23 @@ struct HeapMalloc : public IMalloc { STDMETHODIMP QueryInterface(REFIID iid, void** ppvObject) override { return DoBasicQueryInterface(this, iid, ppvObject); } - void *STDMETHODCALLTYPE Alloc ( - /* [annotation][in] */ - _In_ SIZE_T cb) override { + void *STDMETHODCALLTYPE Alloc(SIZE_T cb) override { return HeapAlloc(GetProcessHeap(), 0, cb); } - void *STDMETHODCALLTYPE Realloc ( - /* [annotation][in] */ - _In_opt_ void *pv, - /* [annotation][in] */ - _In_ SIZE_T cb) override - { + void *STDMETHODCALLTYPE Realloc(void *pv, SIZE_T cb) override { return HeapReAlloc(GetProcessHeap(), 0, pv, cb); } - void STDMETHODCALLTYPE Free ( - /* [annotation][in] */ - _In_opt_ void *pv) override - { + void STDMETHODCALLTYPE Free(void *pv) override { HeapFree(GetProcessHeap(), 0, pv); } - SIZE_T STDMETHODCALLTYPE GetSize( - /* [annotation][in] */ - _In_opt_ _Post_writable_byte_size_(return) void *pv) override - { + SIZE_T STDMETHODCALLTYPE GetSize(void *pv) override { return HeapSize(GetProcessHeap(), 0, pv); } - int STDMETHODCALLTYPE DidAlloc( - /* [annotation][in] */ - _In_opt_ void *pv) override - { + int STDMETHODCALLTYPE DidAlloc(void *pv) override { return -1; // don't know } @@ -91,7 +75,6 @@ IMalloc *GetGlobalHeapMalloc() throw() { return &g_HeapMalloc; } -_Use_decl_annotations_ HRESULT ReadBinaryFile(IMalloc *pMalloc, LPCWSTR pFileName, void **ppData, DWORD *pDataSize) throw() { HANDLE hFile = CreateFileW(pFileName, GENERIC_READ, FILE_SHARE_READ, NULL, @@ -129,12 +112,10 @@ HRESULT ReadBinaryFile(IMalloc *pMalloc, LPCWSTR pFileName, void **ppData, return S_OK; } -_Use_decl_annotations_ HRESULT ReadBinaryFile(LPCWSTR pFileName, void **ppData, DWORD *pDataSize) throw() { return ReadBinaryFile(GetGlobalHeapMalloc(), pFileName, ppData, pDataSize); } -_Use_decl_annotations_ HRESULT WriteBinaryFile(LPCWSTR pFileName, const void *pData, DWORD DataSize) throw() { HANDLE hFile = CreateFileW(pFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if(hFile == INVALID_HANDLE_VALUE) { @@ -151,7 +132,6 @@ HRESULT WriteBinaryFile(LPCWSTR pFileName, const void *pData, DWORD DataSize) th return S_OK; } -_Use_decl_annotations_ UINT32 DxcCodePageFromBytes(const char *bytes, size_t byteLen) throw() { UINT32 codePage; if (byteLen >= 4) { @@ -341,9 +321,9 @@ class InternalDxcBlobEncoding_Impl : public _T { } } - static HRESULT - CreateFromBlob(_In_ IDxcBlob *pBlob, _In_ IMalloc *pMalloc, bool encodingKnown, UINT32 codePage, - _COM_Outptr_ InternalDxcBlobEncoding_Impl **pEncoding) { + static HRESULT CreateFromBlob(IDxcBlob *pBlob, IMalloc *pMalloc, + bool encodingKnown, UINT32 codePage, + InternalDxcBlobEncoding_Impl **pEncoding) { *pEncoding = InternalDxcBlobEncoding_Impl::Alloc(pMalloc); if (*pEncoding == nullptr) { return E_OUTOFMEMORY; @@ -360,9 +340,10 @@ class InternalDxcBlobEncoding_Impl : public _T { return S_OK; } - static HRESULT - CreateFromMalloc(LPCVOID buffer, IMalloc *pIMalloc, SIZE_T bufferSize, bool encodingKnown, - UINT32 codePage, _COM_Outptr_ InternalDxcBlobEncoding_Impl **pEncoding) { + static HRESULT CreateFromMalloc(LPCVOID buffer, IMalloc *pIMalloc, + SIZE_T bufferSize, bool encodingKnown, + UINT32 codePage, + InternalDxcBlobEncoding_Impl **pEncoding) { *pEncoding = InternalDxcBlobEncoding_Impl::Alloc(pIMalloc); if (*pEncoding == nullptr) { *pEncoding = nullptr; @@ -394,7 +375,8 @@ class InternalDxcBlobEncoding_Impl : public _T { virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) override { return m_BufferSize; } - virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown, _Out_ UINT32 *pCodePage) override { + virtual HRESULT STDMETHODCALLTYPE GetEncoding(BOOL *pKnown, + UINT32 *pCodePage) override { *pKnown = m_EncodingKnown ? TRUE : FALSE; *pCodePage = m_CodePage; return S_OK; @@ -410,9 +392,9 @@ typedef InternalDxcBlobEncoding_Impl InternalDxcBlobWide; typedef InternalDxcBlobEncoding_Impl InternalDxcBlobUtf8; static HRESULT CodePageBufferToWide(UINT32 codePage, LPCVOID bufferPointer, - SIZE_T bufferSize, - CDxcMallocHeapPtr &wideNewCopy, - _Out_ UINT32 *pConvertedCharCount) { + SIZE_T bufferSize, + CDxcMallocHeapPtr &wideNewCopy, + UINT32 *pConvertedCharCount) { *pConvertedCharCount = 0; // If the buffer is empty, don't dereference bufferPointer at all. @@ -468,10 +450,9 @@ static HRESULT CodePageBufferToWide(UINT32 codePage, LPCVOID bufferPointer, } static HRESULT CodePageBufferToUtf8(UINT32 codePage, LPCVOID bufferPointer, - SIZE_T bufferSize, - IMalloc *pMalloc, + SIZE_T bufferSize, IMalloc *pMalloc, CDxcMallocHeapPtr &utf8NewCopy, - _Out_ UINT32 *pConvertedCharCount) { + UINT32 *pConvertedCharCount) { *pConvertedCharCount = 0; CDxcMallocHeapPtr wideNewCopy(pMalloc); UINT32 wideCharCount = 0; @@ -783,7 +764,6 @@ HRESULT DxcCreateBlobEncodingFromBlob( } -_Use_decl_annotations_ HRESULT DxcCreateBlobFromBlob( IDxcBlob *pBlob, UINT32 offset, UINT32 length, IDxcBlob **ppResult) throw() { IFRBOOL(ppResult, E_POINTER); @@ -794,7 +774,6 @@ HRESULT DxcCreateBlobFromBlob( return S_OK; } -_Use_decl_annotations_ HRESULT DxcCreateBlobOnMalloc(LPCVOID pData, IMalloc *pIMalloc, UINT32 size, IDxcBlob **ppResult) throw() { IFRBOOL(ppResult, E_POINTER); @@ -805,10 +784,9 @@ DxcCreateBlobOnMalloc(LPCVOID pData, IMalloc *pIMalloc, UINT32 size, IDxcBlob ** return S_OK; } -_Use_decl_annotations_ HRESULT -DxcCreateBlobOnHeapCopy(_In_bytecount_(size) LPCVOID pData, UINT32 size, - _COM_Outptr_ IDxcBlob **ppResult) throw() { +DxcCreateBlobOnHeapCopy(LPCVOID pData, UINT32 size, + IDxcBlob **ppResult) throw() { IFRBOOL(ppResult, E_POINTER); *ppResult = nullptr; IDxcBlobEncoding *pResult; @@ -817,7 +795,6 @@ DxcCreateBlobOnHeapCopy(_In_bytecount_(size) LPCVOID pData, UINT32 size, return S_OK; } -_Use_decl_annotations_ HRESULT DxcCreateBlobFromFile(IMalloc *pMalloc, LPCWSTR pFileName, UINT32 *pCodePage, IDxcBlobEncoding **ppBlobEncoding) throw() { @@ -842,42 +819,36 @@ DxcCreateBlobFromFile(IMalloc *pMalloc, LPCWSTR pFileName, UINT32 *pCodePage, return hr; } -_Use_decl_annotations_ HRESULT DxcCreateBlobFromFile(LPCWSTR pFileName, UINT32 *pCodePage, IDxcBlobEncoding **ppBlobEncoding) throw() { return DxcCreateBlobFromFile(DxcGetThreadMallocNoRef(), pFileName, pCodePage, ppBlobEncoding); } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingSet(IMalloc *pMalloc, IDxcBlob *pBlob, UINT32 codePage, IDxcBlobEncoding **ppBlobEncoding) throw() { return DxcCreateBlobEncodingFromBlob(pBlob, 0, 0, true, codePage, pMalloc, ppBlobEncoding); } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingSet(IDxcBlob *pBlob, UINT32 codePage, IDxcBlobEncoding **ppBlobEncoding) throw() { return DxcCreateBlobEncodingFromBlob(pBlob, 0, 0, true, codePage, nullptr, ppBlobEncoding); } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingFromPinned(LPCVOID pText, UINT32 size, UINT32 codePage, IDxcBlobEncoding **pBlobEncoding) throw() { return DxcCreateBlob(pText, size, true, false, true, codePage, nullptr, pBlobEncoding); } -HRESULT DxcCreateBlobFromPinned( - _In_bytecount_(size) LPCVOID pText, UINT32 size, - _COM_Outptr_ IDxcBlob **pBlob) throw() { +HRESULT DxcCreateBlobFromPinned(LPCVOID pText, UINT32 size, + IDxcBlob **pBlob) throw() { CComPtr pBlobEncoding; DxcCreateBlob(pText, size, true, false, false, CP_ACP, nullptr, &pBlobEncoding); return pBlobEncoding.QueryInterface(pBlob); } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingFromStream(IStream *pStream, bool newInstanceAlways, UINT32 codePage, @@ -908,28 +879,24 @@ DxcCreateBlobWithEncodingFromStream(IStream *pStream, bool newInstanceAlways, return E_NOTIMPL; } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingOnHeapCopy(LPCVOID pText, UINT32 size, UINT32 codePage, IDxcBlobEncoding **pBlobEncoding) throw() { return DxcCreateBlob(pText, size, false, true, true, codePage, nullptr, pBlobEncoding); } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingOnMalloc(LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, IDxcBlobEncoding **pBlobEncoding) throw() { return DxcCreateBlob(pText, size, false, false, true, codePage, pIMalloc, pBlobEncoding); } -_Use_decl_annotations_ HRESULT DxcCreateBlobWithEncodingOnMallocCopy(IMalloc *pIMalloc, LPCVOID pText, UINT32 size, UINT32 codePage, IDxcBlobEncoding **ppBlobEncoding) throw() { return DxcCreateBlob(pText, size, false, true, true, codePage, pIMalloc, ppBlobEncoding); } -_Use_decl_annotations_ HRESULT DxcGetBlobAsUtf8(IDxcBlob *pBlob, IMalloc *pMalloc, IDxcBlobUtf8 **pBlobEncoding, UINT32 defaultCodePage) throw() { @@ -1019,8 +986,8 @@ DxcGetBlobAsUtf8(IDxcBlob *pBlob, IMalloc *pMalloc, // This is kept for compatibility. HRESULT -DxcGetBlobAsUtf8NullTerm(_In_ IDxcBlob *pBlob, - _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) throw() { +DxcGetBlobAsUtf8NullTerm(IDxcBlob *pBlob, + IDxcBlobEncoding **ppBlobEncoding) throw() { IFRBOOL(pBlob, E_POINTER); IFRBOOL(ppBlobEncoding, E_POINTER); *ppBlobEncoding = nullptr; @@ -1031,7 +998,6 @@ DxcGetBlobAsUtf8NullTerm(_In_ IDxcBlob *pBlob, return S_OK; } -_Use_decl_annotations_ HRESULT DxcGetBlobAsWide(IDxcBlob *pBlob, IMalloc *pMalloc, IDxcBlobWide **pBlobEncoding) throw() { IFRBOOL(pBlob, E_POINTER); IFRBOOL(pBlobEncoding, E_POINTER); @@ -1117,7 +1083,7 @@ HRESULT DxcGetBlobAsWide(IDxcBlob *pBlob, IMalloc *pMalloc, IDxcBlobWide **pBlob return hr; } -bool IsBlobNullOrEmpty(_In_opt_ IDxcBlob *pBlob) throw() { +bool IsBlobNullOrEmpty(IDxcBlob *pBlob) throw() { return pBlob == nullptr || pBlob->GetBufferSize() == 0; } @@ -1568,7 +1534,8 @@ class FixedSizeMemoryStream : public AbstractMemoryStream { } }; -HRESULT CreateMemoryStream(_In_ IMalloc *pMalloc, _COM_Outptr_ AbstractMemoryStream** ppResult) throw() { +HRESULT CreateMemoryStream(IMalloc *pMalloc, + AbstractMemoryStream **ppResult) throw() { if (pMalloc == nullptr || ppResult == nullptr) { return E_POINTER; } @@ -1578,7 +1545,8 @@ HRESULT CreateMemoryStream(_In_ IMalloc *pMalloc, _COM_Outptr_ AbstractMemoryStr return (*ppResult == nullptr) ? E_OUTOFMEMORY : S_OK; } -HRESULT CreateReadOnlyBlobStream(_In_ IDxcBlob *pSource, _COM_Outptr_ IStream** ppResult) throw() { +HRESULT CreateReadOnlyBlobStream(IDxcBlob *pSource, + IStream **ppResult) throw() { if (pSource == nullptr || ppResult == nullptr) { return E_POINTER; } @@ -1591,7 +1559,8 @@ HRESULT CreateReadOnlyBlobStream(_In_ IDxcBlob *pSource, _COM_Outptr_ IStream** return (*ppResult == nullptr) ? E_OUTOFMEMORY : S_OK; } -HRESULT CreateFixedSizeMemoryStream(_In_ LPBYTE pBuffer, size_t size, _COM_Outptr_ AbstractMemoryStream** ppResult) throw() { +HRESULT CreateFixedSizeMemoryStream(LPBYTE pBuffer, size_t size, + AbstractMemoryStream **ppResult) throw() { if (pBuffer == nullptr || ppResult == nullptr) { return E_POINTER; } diff --git a/lib/DxcSupport/Unicode.cpp b/lib/DxcSupport/Unicode.cpp index e87281d036..cd93c66525 100644 --- a/lib/DxcSupport/Unicode.cpp +++ b/lib/DxcSupport/Unicode.cpp @@ -14,6 +14,7 @@ #else #include #endif +#include #include #include "dxc/Support/Global.h" #include "dxc/Support/Unicode.h" @@ -119,8 +120,8 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t /*dwFlags*/, namespace Unicode { -_Success_(return != false) -bool WideToEncodedString(_In_z_ const wchar_t* text, size_t cWide, DWORD cp, DWORD flags, _Inout_ std::string* pValue, _Out_opt_ bool* lossy) { +bool WideToEncodedString(const wchar_t *text, size_t cWide, DWORD cp, + DWORD flags, std::string *pValue, bool *lossy) { BOOL usedDefaultChar; LPBOOL pUsedDefaultChar = (lossy == nullptr) ? nullptr : &usedDefaultChar; if (lossy != nullptr) *lossy = false; @@ -146,13 +147,11 @@ bool WideToEncodedString(_In_z_ const wchar_t* text, size_t cWide, DWORD cp, DWO return true; } -_Use_decl_annotations_ bool UTF8ToWideString(const char *pUTF8, std::wstring *pWide) { size_t cbUTF8 = (pUTF8 == nullptr) ? 0 : strlen(pUTF8); return UTF8ToWideString(pUTF8, cbUTF8, pWide); } -_Use_decl_annotations_ bool UTF8ToWideString(const char *pUTF8, size_t cbUTF8, std::wstring *pWide) { DXASSERT_NOMSG(pWide != nullptr); @@ -178,7 +177,7 @@ bool UTF8ToWideString(const char *pUTF8, size_t cbUTF8, std::wstring *pWide) { return true; } -std::wstring UTF8ToWideStringOrThrow(_In_z_ const char *pUTF8) { +std::wstring UTF8ToWideStringOrThrow(const char *pUTF8) { std::wstring result; if (!UTF8ToWideString(pUTF8, &result)) { throw hlsl::Exception(DXC_E_STRING_ENCODING_FAILED); @@ -186,8 +185,8 @@ std::wstring UTF8ToWideStringOrThrow(_In_z_ const char *pUTF8) { return result; } -_Use_decl_annotations_ -bool UTF8ToConsoleString(_In_z_ const char* text, _In_ size_t textLen, _Inout_ std::string* pValue, _Out_opt_ bool* lossy) { +bool UTF8ToConsoleString(const char *text, size_t textLen, std::string *pValue, + bool *lossy) { DXASSERT_NOMSG(text != nullptr); DXASSERT_NOMSG(pValue != nullptr); std::wstring text16; @@ -198,39 +197,35 @@ bool UTF8ToConsoleString(_In_z_ const char* text, _In_ size_t textLen, _Inout_ s return WideToConsoleString(text16.c_str(), text16.length(), pValue, lossy); } -_Use_decl_annotations_ -bool UTF8ToConsoleString(_In_z_ const char* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy) { +bool UTF8ToConsoleString(const char *text, std::string *pValue, bool *lossy) { return UTF8ToConsoleString(text, strlen(text), pValue, lossy); } -_Use_decl_annotations_ -bool WideToConsoleString(const wchar_t* text, _In_ size_t textLen, std::string* pValue, bool* lossy) { +bool WideToConsoleString(const wchar_t *text, size_t textLen, + std::string *pValue, bool *lossy) { DXASSERT_NOMSG(text != nullptr); DXASSERT_NOMSG(pValue != nullptr); UINT cp = GetConsoleOutputCP(); return WideToEncodedString(text, textLen, cp, 0, pValue, lossy); } -_Use_decl_annotations_ bool WideToConsoleString(const wchar_t* text, std::string* pValue, bool* lossy) { return WideToConsoleString(text, wcslen(text), pValue, lossy); } -_Use_decl_annotations_ bool WideToUTF8String(const wchar_t *pWide, size_t cWide, std::string *pUTF8) { DXASSERT_NOMSG(pWide != nullptr); DXASSERT_NOMSG(pUTF8 != nullptr); return WideToEncodedString(pWide, cWide, CP_UTF8, 0, pUTF8, nullptr); } -_Use_decl_annotations_ bool WideToUTF8String(const wchar_t *pWide, std::string *pUTF8) { DXASSERT_NOMSG(pWide != nullptr); DXASSERT_NOMSG(pUTF8 != nullptr); return WideToEncodedString(pWide, wcslen(pWide), CP_UTF8, 0, pUTF8, nullptr); } -std::string WideToUTF8StringOrThrow(_In_z_ const wchar_t *pWide) { +std::string WideToUTF8StringOrThrow(const wchar_t *pWide) { std::string result; if (!WideToUTF8String(pWide, &result)) { throw hlsl::Exception(DXC_E_STRING_ENCODING_FAILED); @@ -238,7 +233,6 @@ std::string WideToUTF8StringOrThrow(_In_z_ const wchar_t *pWide) { return result; } -_Use_decl_annotations_ bool UTF8BufferToWideComHeap(const char *pUTF8, wchar_t **ppWide) throw() { *ppWide = nullptr; int c = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, pUTF8, -1, @@ -254,7 +248,6 @@ bool UTF8BufferToWideComHeap(const char *pUTF8, wchar_t **ppWide) throw() { return true; } -_Use_decl_annotations_ bool UTF8BufferToWideBuffer(const char *pUTF8, int cbUTF8, wchar_t **ppWide, size_t *pcWide) throw() { *ppWide = nullptr; *pcWide = 0; @@ -294,7 +287,6 @@ bool UTF8BufferToWideBuffer(const char *pUTF8, int cbUTF8, wchar_t **ppWide, siz return true; } -_Use_decl_annotations_ bool WideBufferToUTF8Buffer(const wchar_t *pWide, int cWide, char **ppUTF8, size_t *pcUTF8) throw() { *ppUTF8 = nullptr; *pcUTF8 = 0; @@ -370,12 +362,10 @@ bool IsStarMatchT(const TChar *pMask, size_t maskLen, const TChar *pName, size_t } } -_Use_decl_annotations_ bool IsStarMatchUTF8(const char *pMask, size_t maskLen, const char *pName, size_t nameLen) { return IsStarMatchT(pMask, maskLen, pName, nameLen, '*'); } -_Use_decl_annotations_ bool IsStarMatchWide(const wchar_t *pMask, size_t maskLen, const wchar_t *pName, size_t nameLen) { return IsStarMatchT(pMask, maskLen, pName, nameLen, L'*'); } diff --git a/lib/DxcSupport/WinAdapter.cpp b/lib/DxcSupport/WinAdapter.cpp index 29eae4403a..9378e0275c 100644 --- a/lib/DxcSupport/WinAdapter.cpp +++ b/lib/DxcSupport/WinAdapter.cpp @@ -78,7 +78,7 @@ CHandle::~CHandle() { CloseHandle(m_h); } CHandle::operator HANDLE() const throw() { return m_h; } // CComBSTR -CComBSTR::CComBSTR(_In_ int nSize, LPCWSTR sz) { +CComBSTR::CComBSTR(int nSize, LPCWSTR sz) { if (nSize < 0) { throw std::invalid_argument("CComBSTR must have size >= 0"); } @@ -93,7 +93,7 @@ CComBSTR::CComBSTR(_In_ int nSize, LPCWSTR sz) { } } -bool CComBSTR::operator==(_In_ const CComBSTR &bstrSrc) const throw() { +bool CComBSTR::operator==(const CComBSTR &bstrSrc) const throw() { return wcscmp(m_str, bstrSrc.m_str) == 0; } diff --git a/lib/DxcSupport/WinFunctions.cpp b/lib/DxcSupport/WinFunctions.cpp index e57b90da7c..2c79c0bc9a 100644 --- a/lib/DxcSupport/WinFunctions.cpp +++ b/lib/DxcSupport/WinFunctions.cpp @@ -139,18 +139,15 @@ unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask) { return 1; } -HANDLE CreateFile2(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, - _In_opt_ void *pCreateExParams) { +HANDLE CreateFile2(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + DWORD dwCreationDisposition, void *pCreateExParams) { return CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, pCreateExParams, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr); } -HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, _In_opt_ void *lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile) { +HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + void *lpSecurityAttributes, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { CW2A pUtf8FileName(lpFileName); size_t fd = -1; int flags = 0; @@ -187,7 +184,7 @@ HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, return (HANDLE)fd; } -BOOL GetFileSizeEx(_In_ HANDLE hFile, _Out_ PLARGE_INTEGER lpFileSize) { +BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize) { int fd = (size_t)hFile; struct stat fdstat; int rv = fstat(fd, &fdstat); @@ -198,10 +195,8 @@ BOOL GetFileSizeEx(_In_ HANDLE hFile, _Out_ PLARGE_INTEGER lpFileSize) { return false; } -BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer, - _In_ DWORD nNumberOfBytesToRead, - _Out_opt_ LPDWORD lpNumberOfBytesRead, - _Inout_opt_ void *lpOverlapped) { +BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, void *lpOverlapped) { size_t fd = (size_t)hFile; ssize_t rv = -1; @@ -215,10 +210,8 @@ BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer, return true; } -BOOL WriteFile(_In_ HANDLE hFile, _In_ LPCVOID lpBuffer, - _In_ DWORD nNumberOfBytesToWrite, - _Out_opt_ LPDWORD lpNumberOfBytesWritten, - _Inout_opt_ void *lpOverlapped) { +BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, void *lpOverlapped) { size_t fd = (size_t)hFile; ssize_t rv = -1; @@ -232,7 +225,7 @@ BOOL WriteFile(_In_ HANDLE hFile, _In_ LPCVOID lpBuffer, return true; } -BOOL CloseHandle(_In_ HANDLE hObject) { +BOOL CloseHandle(HANDLE hObject) { int fd = (size_t)hObject; return !close(fd); } diff --git a/lib/DxcSupport/dxcapi.use.cpp b/lib/DxcSupport/dxcapi.use.cpp index 4556a0f72a..cbabd1e66c 100644 --- a/lib/DxcSupport/dxcapi.use.cpp +++ b/lib/DxcSupport/dxcapi.use.cpp @@ -25,7 +25,7 @@ const char* kDxCompilerLib = CMAKE_SHARED_LIBRARY_PREFIX "dxcompiler" CMAKE_SHAR const char* kDxilLib = CMAKE_SHARED_LIBRARY_PREFIX "dxil" CMAKE_SHARED_LIBRARY_SUFFIX; #ifdef _WIN32 -static void TrimEOL(_Inout_z_ char *pMsg) { +static void TrimEOL(char *pMsg) { char *pEnd = pMsg + strlen(pMsg); --pEnd; while (pEnd > pMsg && (*pEnd == '\r' || *pEnd == '\n')) { @@ -76,15 +76,15 @@ void EnsureEnabled(DxcDllSupport &dxcSupport) { } } -void ReadFileIntoBlob(DxcDllSupport &dxcSupport, _In_ LPCWSTR pFileName, - _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) { +void ReadFileIntoBlob(DxcDllSupport &dxcSupport, LPCWSTR pFileName, + IDxcBlobEncoding **ppBlobEncoding) { CComPtr library; IFT(dxcSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT_Data(library->CreateBlobFromFile(pFileName, nullptr, ppBlobEncoding), pFileName); } -void WriteOperationErrorsToConsole(_In_ IDxcOperationResult *pResult, +void WriteOperationErrorsToConsole(IDxcOperationResult *pResult, bool outputWarnings) { HRESULT status; IFT(pResult->GetStatus(&status)); @@ -97,7 +97,7 @@ void WriteOperationErrorsToConsole(_In_ IDxcOperationResult *pResult, } } -void WriteOperationResultToConsole(_In_ IDxcOperationResult *pRewriteResult, +void WriteOperationResultToConsole(IDxcOperationResult *pRewriteResult, bool outputWarnings) { WriteOperationErrorsToConsole(pRewriteResult, outputWarnings); @@ -106,8 +106,7 @@ void WriteOperationResultToConsole(_In_ IDxcOperationResult *pRewriteResult, WriteBlobToConsole(pBlob, STD_OUTPUT_HANDLE); } -static void WriteWideNullTermToConsole(_In_opt_count_(charCount) const wchar_t *pText, - DWORD streamType) { +static void WriteWideNullTermToConsole(const wchar_t *pText, DWORD streamType) { if (pText == nullptr) { return; } @@ -126,7 +125,7 @@ static void WriteWideNullTermToConsole(_In_opt_count_(charCount) const wchar_t * } } -static HRESULT BlobToUtf8IfText(_In_opt_ IDxcBlob *pBlob, IDxcBlobUtf8 **ppBlobUtf8) { +static HRESULT BlobToUtf8IfText(IDxcBlob *pBlob, IDxcBlobUtf8 **ppBlobUtf8) { CComPtr pBlobEncoding; if (SUCCEEDED(pBlob->QueryInterface(&pBlobEncoding))) { BOOL known; @@ -139,7 +138,7 @@ static HRESULT BlobToUtf8IfText(_In_opt_ IDxcBlob *pBlob, IDxcBlobUtf8 **ppBlobU return S_OK; } -static HRESULT BlobToWideIfText(_In_opt_ IDxcBlob *pBlob, IDxcBlobWide **ppBlobWide) { +static HRESULT BlobToWideIfText(IDxcBlob *pBlob, IDxcBlobWide **ppBlobWide) { CComPtr pBlobEncoding; if (SUCCEEDED(pBlob->QueryInterface(&pBlobEncoding))) { BOOL known; @@ -152,7 +151,7 @@ static HRESULT BlobToWideIfText(_In_opt_ IDxcBlob *pBlob, IDxcBlobWide **ppBlobW return S_OK; } -void WriteBlobToConsole(_In_opt_ IDxcBlob *pBlob, DWORD streamType) { +void WriteBlobToConsole(IDxcBlob *pBlob, DWORD streamType) { if (pBlob == nullptr) { return; } @@ -175,7 +174,7 @@ void WriteBlobToConsole(_In_opt_ IDxcBlob *pBlob, DWORD streamType) { } } -void WriteBlobToFile(_In_opt_ IDxcBlob *pBlob, _In_ LPCWSTR pFileName, _In_ UINT32 textCodePage) { +void WriteBlobToFile(IDxcBlob *pBlob, LPCWSTR pFileName, UINT32 textCodePage) { if (pBlob == nullptr) { return; } @@ -189,7 +188,8 @@ void WriteBlobToFile(_In_opt_ IDxcBlob *pBlob, _In_ LPCWSTR pFileName, _In_ UINT WriteBlobToHandle(pBlob, file, pFileName, textCodePage); } -void WriteBlobToHandle(_In_opt_ IDxcBlob *pBlob, _In_ HANDLE hFile, _In_opt_ LPCWSTR pFileName, _In_ UINT32 textCodePage) { +void WriteBlobToHandle(IDxcBlob *pBlob, HANDLE hFile, LPCWSTR pFileName, + UINT32 textCodePage) { if (pBlob == nullptr) { return; } @@ -232,8 +232,7 @@ void WriteBlobToHandle(_In_opt_ IDxcBlob *pBlob, _In_ HANDLE hFile, _In_opt_ LPC } } -void WriteUtf8ToConsole(_In_opt_count_(charCount) const char *pText, - int charCount, DWORD streamType) { +void WriteUtf8ToConsole(const char *pText, int charCount, DWORD streamType) { if (charCount == 0 || pText == nullptr) { return; } @@ -249,8 +248,8 @@ void WriteUtf8ToConsole(_In_opt_count_(charCount) const char *pText, delete[] wideMessage; } -void WriteUtf8ToConsoleSizeT(_In_opt_count_(charCount) const char *pText, - size_t charCount, DWORD streamType) { +void WriteUtf8ToConsoleSizeT(const char *pText, size_t charCount, + DWORD streamType) { if (charCount == 0) { return; } diff --git a/lib/DxilContainer/DxcContainerBuilder.cpp b/lib/DxilContainer/DxcContainerBuilder.cpp index a65df6510c..2cc63a3546 100644 --- a/lib/DxilContainer/DxcContainerBuilder.cpp +++ b/lib/DxilContainer/DxcContainerBuilder.cpp @@ -23,13 +23,13 @@ #include "llvm/ADT/SmallVector.h" // This declaration is used for the locally-linked validator. -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv); template -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ TInterface **ppInterface); +HRESULT DxilLibCreateInstance(REFCLSID rclsid, TInterface **ppInterface); using namespace hlsl; -HRESULT STDMETHODCALLTYPE DxcContainerBuilder::Load(_In_ IDxcBlob *pSource) { +HRESULT STDMETHODCALLTYPE DxcContainerBuilder::Load(IDxcBlob *pSource) { DxcThreadMalloc TM(m_pMalloc); try { IFTBOOL(m_pContainer == nullptr && pSource != nullptr && @@ -49,8 +49,8 @@ HRESULT STDMETHODCALLTYPE DxcContainerBuilder::Load(_In_ IDxcBlob *pSource) { CATCH_CPP_RETURN_HRESULT(); } - -HRESULT STDMETHODCALLTYPE DxcContainerBuilder::AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) { +HRESULT STDMETHODCALLTYPE DxcContainerBuilder::AddPart(UINT32 fourCC, + IDxcBlob *pSource) { DxcThreadMalloc TM(m_pMalloc); try { IFTBOOL(pSource != nullptr && !IsDxilContainerLike(pSource->GetBufferPointer(), @@ -72,7 +72,7 @@ HRESULT STDMETHODCALLTYPE DxcContainerBuilder::AddPart(_In_ UINT32 fourCC, _In_ CATCH_CPP_RETURN_HRESULT(); } -HRESULT STDMETHODCALLTYPE DxcContainerBuilder::RemovePart(_In_ UINT32 fourCC) { +HRESULT STDMETHODCALLTYPE DxcContainerBuilder::RemovePart(UINT32 fourCC) { DxcThreadMalloc TM(m_pMalloc); try { IFTBOOL(fourCC == DxilFourCC::DFCC_ShaderDebugInfoDXIL || @@ -94,7 +94,8 @@ HRESULT STDMETHODCALLTYPE DxcContainerBuilder::RemovePart(_In_ UINT32 fourCC) { CATCH_CPP_RETURN_HRESULT(); } -HRESULT STDMETHODCALLTYPE DxcContainerBuilder::SerializeContainer(_Out_ IDxcOperationResult **ppResult) { +HRESULT STDMETHODCALLTYPE +DxcContainerBuilder::SerializeContainer(IDxcOperationResult **ppResult) { DxcThreadMalloc TM(m_pMalloc); try { // Allocate memory for new dxil container. diff --git a/lib/DxilContainer/DxilContainer.cpp b/lib/DxilContainer/DxilContainer.cpp index 39f113ab92..954ef8b301 100644 --- a/lib/DxilContainer/DxilContainer.cpp +++ b/lib/DxilContainer/DxilContainer.cpp @@ -22,7 +22,7 @@ DxilPartIterator end(const DxilContainerHeader *pHeader) { return{ pHeader, pHeader->PartCount }; } -void InitDxilContainer(_Out_ DxilContainerHeader *pHeader, uint32_t partCount, +void InitDxilContainer(DxilContainerHeader *pHeader, uint32_t partCount, uint32_t containerSizeInBytes) { memset(pHeader, 0, sizeof(*pHeader)); pHeader->HeaderFourCC = DFCC_Container; diff --git a/lib/DxilContainer/DxilContainerReader.cpp b/lib/DxilContainer/DxilContainerReader.cpp index bf0084788a..f7c9cd1478 100644 --- a/lib/DxilContainer/DxilContainerReader.cpp +++ b/lib/DxilContainer/DxilContainerReader.cpp @@ -16,7 +16,8 @@ namespace hlsl { -HRESULT DxilContainerReader::Load(_In_ const void* pContainer, _In_ uint32_t containerSizeInBytes) { +HRESULT DxilContainerReader::Load(const void *pContainer, + uint32_t containerSizeInBytes) { if (pContainer == nullptr) { return E_FAIL; } @@ -36,21 +37,22 @@ HRESULT DxilContainerReader::Load(_In_ const void* pContainer, _In_ uint32_t con return S_OK; } -HRESULT DxilContainerReader::GetVersion(_Out_ DxilContainerVersion *pResult) { +HRESULT DxilContainerReader::GetVersion(DxilContainerVersion *pResult) { if (pResult == nullptr) return E_POINTER; if (!IsLoaded()) return E_NOT_VALID_STATE; *pResult = m_pHeader->Version; return S_OK; } -HRESULT DxilContainerReader::GetPartCount(_Out_ uint32_t *pResult) { +HRESULT DxilContainerReader::GetPartCount(uint32_t *pResult) { if (pResult == nullptr) return E_POINTER; if (!IsLoaded()) return E_NOT_VALID_STATE; *pResult = m_pHeader->PartCount; return S_OK; } -HRESULT DxilContainerReader::GetPartContent(uint32_t idx, _Outptr_ const void **ppResult, _Out_ uint32_t *pResultSize) { +HRESULT DxilContainerReader::GetPartContent(uint32_t idx, const void **ppResult, + uint32_t *pResultSize) { if (ppResult == nullptr) return E_POINTER; *ppResult = nullptr; if (!IsLoaded()) return E_NOT_VALID_STATE; @@ -63,7 +65,7 @@ HRESULT DxilContainerReader::GetPartContent(uint32_t idx, _Outptr_ const void ** return S_OK; } -HRESULT DxilContainerReader::GetPartFourCC(uint32_t idx, _Out_ uint32_t *pResult) { +HRESULT DxilContainerReader::GetPartFourCC(uint32_t idx, uint32_t *pResult) { if (pResult == nullptr) return E_POINTER; if (!IsLoaded()) return E_NOT_VALID_STATE; if (idx >= m_pHeader->PartCount) return E_BOUNDS; @@ -72,7 +74,8 @@ HRESULT DxilContainerReader::GetPartFourCC(uint32_t idx, _Out_ uint32_t *pResult return S_OK; } -HRESULT DxilContainerReader::FindFirstPartKind(uint32_t kind, _Out_ uint32_t *pResult) { +HRESULT DxilContainerReader::FindFirstPartKind(uint32_t kind, + uint32_t *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = 0; if (!IsLoaded()) return E_NOT_VALID_STATE; @@ -80,5 +83,5 @@ HRESULT DxilContainerReader::FindFirstPartKind(uint32_t kind, _Out_ uint32_t *pR *pResult = (it == end(m_pHeader)) ? DXIL_CONTAINER_BLOB_NOT_FOUND : it.index; return S_OK; } - + } // namespace hlsl diff --git a/lib/DxilDia/DxcPixCompilationInfo.cpp b/lib/DxilDia/DxcPixCompilationInfo.cpp index bd3fe9b399..8395bcbcf6 100644 --- a/lib/DxilDia/DxcPixCompilationInfo.cpp +++ b/lib/DxilDia/DxcPixCompilationInfo.cpp @@ -66,20 +66,13 @@ struct CompilationInfo : public IDxcPixCompilationInfo { HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) final { return DoBasicQueryInterface(this, iid, ppvObject); } - virtual STDMETHODIMP - GetSourceFile(_In_ DWORD SourceFileOrdinal, - _Outptr_result_z_ BSTR *pSourceName, - _Outptr_result_z_ BSTR *pSourceContents) override; - virtual STDMETHODIMP - GetArguments(_Outptr_result_z_ BSTR *pArguments) override; - virtual STDMETHODIMP - GetMacroDefinitions(_Outptr_result_z_ BSTR *pMacroDefinitions) override; - virtual STDMETHODIMP - GetEntryPointFile(_Outptr_result_z_ BSTR *pEntryPointFile) override; - virtual STDMETHODIMP - GetHlslTarget(_Outptr_result_z_ BSTR *pHlslTarget) override; - virtual STDMETHODIMP - GetEntryPoint(_Outptr_result_z_ BSTR *pEntryPoint) override; + virtual STDMETHODIMP GetSourceFile(DWORD SourceFileOrdinal, BSTR *pSourceName, + BSTR *pSourceContents) override; + virtual STDMETHODIMP GetArguments(BSTR *pArguments) override; + virtual STDMETHODIMP GetMacroDefinitions(BSTR *pMacroDefinitions) override; + virtual STDMETHODIMP GetEntryPointFile(BSTR *pEntryPointFile) override; + virtual STDMETHODIMP GetHlslTarget(BSTR *pHlslTarget) override; + virtual STDMETHODIMP GetEntryPoint(BSTR *pEntryPoint) override; }; CompilationInfo::CompilationInfo(IMalloc *pMalloc, dxil_dia::Session *pSession) @@ -120,9 +113,8 @@ static void MDStringOperandToBSTR(llvm::MDOperand const &mdOperand, } STDMETHODIMP -CompilationInfo::GetSourceFile(_In_ DWORD SourceFileOrdinal, - _Outptr_result_z_ BSTR *pSourceName, - _Outptr_result_z_ BSTR *pSourceContents) { +CompilationInfo::GetSourceFile(DWORD SourceFileOrdinal, BSTR *pSourceName, + BSTR *pSourceContents) { *pSourceName = nullptr; *pSourceContents = nullptr; @@ -139,7 +131,7 @@ CompilationInfo::GetSourceFile(_In_ DWORD SourceFileOrdinal, return S_OK; } -STDMETHODIMP CompilationInfo::GetArguments(_Outptr_result_z_ BSTR *pArguments) { +STDMETHODIMP CompilationInfo::GetArguments(BSTR *pArguments) { llvm::MDNode *argsNode = m_arguments->getOperand(0); // Don't return any arguments that denote things that are returned via @@ -185,8 +177,7 @@ STDMETHODIMP CompilationInfo::GetArguments(_Outptr_result_z_ BSTR *pArguments) { return S_OK; } -STDMETHODIMP CompilationInfo::GetMacroDefinitions( - _Outptr_result_z_ BSTR *pMacroDefinitions) { +STDMETHODIMP CompilationInfo::GetMacroDefinitions(BSTR *pMacroDefinitions) { llvm::MDNode *definesNode = m_defines->getOperand(0); // Concatenate definitions into one string separated by spaces CComBSTR pBSTR; @@ -221,7 +212,7 @@ STDMETHODIMP CompilationInfo::GetMacroDefinitions( } STDMETHODIMP -CompilationInfo::GetEntryPointFile(_Outptr_result_z_ BSTR *pEntryPointFile) { +CompilationInfo::GetEntryPointFile(BSTR *pEntryPointFile) { llvm::StringRef strRef = llvm::dyn_cast( m_mainFileName->getOperand(0)->getOperand(0)) ->getString(); @@ -235,7 +226,7 @@ CompilationInfo::GetEntryPointFile(_Outptr_result_z_ BSTR *pEntryPointFile) { } STDMETHODIMP -CompilationInfo::GetHlslTarget(_Outptr_result_z_ BSTR *pHlslTarget) { +CompilationInfo::GetHlslTarget(BSTR *pHlslTarget) { CA2W cv(m_pSession->DxilModuleRef().GetShaderModel()->GetName(), CP_UTF8); CComBSTR pBSTR; pBSTR.Append(cv); @@ -244,7 +235,7 @@ CompilationInfo::GetHlslTarget(_Outptr_result_z_ BSTR *pHlslTarget) { } STDMETHODIMP -CompilationInfo::GetEntryPoint(_Outptr_result_z_ BSTR *pEntryPoint) { +CompilationInfo::GetEntryPoint(BSTR *pEntryPoint) { auto name = m_pSession->DxilModuleRef().GetEntryFunctionName(); CA2W cv(name.c_str(), CP_UTF8); CComBSTR pBSTR; diff --git a/lib/DxilDia/DxcPixDxilDebugInfo.cpp b/lib/DxilDia/DxcPixDxilDebugInfo.cpp index 6c81125621..88bcbc1156 100644 --- a/lib/DxilDia/DxcPixDxilDebugInfo.cpp +++ b/lib/DxilDia/DxcPixDxilDebugInfo.cpp @@ -25,25 +25,20 @@ #include "dxc/DxilPixPasses/DxilPixVirtualRegisters.h" STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::GetLiveVariablesAt( - _In_ DWORD InstructionOffset, - _COM_Outptr_ IDxcPixDxilLiveVariables **ppLiveVariables) -{ + DWORD InstructionOffset, IDxcPixDxilLiveVariables **ppLiveVariables) { return m_LiveVars->GetLiveVariablesAtInstruction( FindInstruction(InstructionOffset), ppLiveVariables); } STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::IsVariableInRegister( - _In_ DWORD InstructionOffset, - _In_ const wchar_t *VariableName) -{ + DWORD InstructionOffset, const wchar_t *VariableName) { return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::GetFunctionName( - _In_ DWORD InstructionOffset, - _Outptr_result_z_ BSTR *ppFunctionName) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilDebugInfo::GetFunctionName(DWORD InstructionOffset, + BSTR *ppFunctionName) { llvm::Instruction *IP = FindInstruction(InstructionOffset); const llvm::DITypeIdentifierMap EmptyMap; @@ -67,11 +62,9 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::GetFunctionName( return S_FALSE; } -STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::GetStackDepth( - _In_ DWORD InstructionOffset, - _Outptr_ DWORD *StackDepth -) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilDebugInfo::GetStackDepth(DWORD InstructionOffset, + DWORD *StackDepth) { llvm::Instruction *IP = FindInstruction(InstructionOffset); DWORD Depth = 0; @@ -121,10 +114,8 @@ llvm::Instruction* dxil_debug_info::DxcPixDxilDebugInfo::FindInstruction( STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::InstructionOffsetsFromSourceLocation( - _In_ const wchar_t *FileName, _In_ DWORD SourceLine, - _In_ DWORD SourceColumn, - _COM_Outptr_ IDxcPixDxilInstructionOffsets **ppOffsets) -{ + const wchar_t *FileName, DWORD SourceLine, DWORD SourceColumn, + IDxcPixDxilInstructionOffsets **ppOffsets) { return dxil_debug_info::NewDxcPixDxilDebugInfoObjectOrThrow< dxil_debug_info::DxcPixDxilInstructionOffsets>( ppOffsets, m_pMalloc, m_pSession, FileName, SourceLine, SourceColumn); @@ -132,8 +123,7 @@ dxil_debug_info::DxcPixDxilDebugInfo::InstructionOffsetsFromSourceLocation( STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::SourceLocationsFromInstructionOffset( - _In_ DWORD InstructionOffset, - _COM_Outptr_ IDxcPixDxilSourceLocations **ppSourceLocations) { + DWORD InstructionOffset, IDxcPixDxilSourceLocations **ppSourceLocations) { llvm::Instruction *IP = FindInstruction(InstructionOffset); @@ -259,9 +249,9 @@ STDMETHODIMP_(DWORD) dxil_debug_info::DxcPixDxilSourceLocations::GetCount() return static_cast(m_locations.size()); } -STDMETHODIMP dxil_debug_info::DxcPixDxilSourceLocations::GetFileNameByIndex( - _In_ DWORD Index, _Outptr_result_z_ BSTR *Name) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilSourceLocations::GetFileNameByIndex(DWORD Index, + BSTR *Name) { if (Index >= static_cast(m_locations.size())) { return E_BOUNDS; @@ -270,9 +260,8 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilSourceLocations::GetFileNameByIndex( return S_OK; } -STDMETHODIMP_(DWORD) dxil_debug_info::DxcPixDxilSourceLocations::GetColumnByIndex( - _In_ DWORD Index) -{ +STDMETHODIMP_(DWORD) +dxil_debug_info::DxcPixDxilSourceLocations::GetColumnByIndex(DWORD Index) { if (Index >= static_cast(m_locations.size())) { return E_BOUNDS; @@ -280,13 +269,10 @@ STDMETHODIMP_(DWORD) dxil_debug_info::DxcPixDxilSourceLocations::GetColumnByInde return m_locations[Index].Column; } -STDMETHODIMP_(DWORD) dxil_debug_info::DxcPixDxilSourceLocations::GetLineNumberByIndex( - _In_ DWORD Index) -{ - if (Index >= static_cast(m_locations.size())) - { - return E_BOUNDS; - } - return m_locations[Index].Line; +STDMETHODIMP_(DWORD) +dxil_debug_info::DxcPixDxilSourceLocations::GetLineNumberByIndex(DWORD Index) { + if (Index >= static_cast(m_locations.size())) { + return E_BOUNDS; + } + return m_locations[Index].Line; } - diff --git a/lib/DxilDia/DxcPixDxilDebugInfo.h b/lib/DxilDia/DxcPixDxilDebugInfo.h index 344a5de419..7436efb5a9 100644 --- a/lib/DxilDia/DxcPixDxilDebugInfo.h +++ b/lib/DxilDia/DxcPixDxilDebugInfo.h @@ -61,32 +61,26 @@ class DxcPixDxilDebugInfo : public IDxcPixDxilDebugInfo return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetLiveVariablesAt( - _In_ DWORD InstructionOffset, - _COM_Outptr_ IDxcPixDxilLiveVariables **ppLiveVariables) override; + STDMETHODIMP + GetLiveVariablesAt(DWORD InstructionOffset, + IDxcPixDxilLiveVariables **ppLiveVariables) override; - STDMETHODIMP IsVariableInRegister( - _In_ DWORD InstructionOffset, - _In_ const wchar_t *VariableName) override; + STDMETHODIMP IsVariableInRegister(DWORD InstructionOffset, + const wchar_t *VariableName) override; - STDMETHODIMP GetFunctionName( - _In_ DWORD InstructionOffset, - _Outptr_result_z_ BSTR *ppFunctionName) override; - - STDMETHODIMP GetStackDepth( - _In_ DWORD InstructionOffset, - _Outptr_ DWORD *StackDepth) override; + STDMETHODIMP GetFunctionName(DWORD InstructionOffset, + BSTR *ppFunctionName) override; + STDMETHODIMP GetStackDepth(DWORD InstructionOffset, + DWORD *StackDepth) override; STDMETHODIMP InstructionOffsetsFromSourceLocation( - _In_ const wchar_t *FileName, - _In_ DWORD SourceLine, - _In_ DWORD SourceColumn, - _COM_Outptr_ IDxcPixDxilInstructionOffsets **ppOffsets) override; + const wchar_t *FileName, DWORD SourceLine, DWORD SourceColumn, + IDxcPixDxilInstructionOffsets **ppOffsets) override; - STDMETHODIMP SourceLocationsFromInstructionOffset( - _In_ DWORD InstructionOffset, - _COM_Outptr_ IDxcPixDxilSourceLocations** ppSourceLocations) override; + STDMETHODIMP SourceLocationsFromInstructionOffset( + DWORD InstructionOffset, + IDxcPixDxilSourceLocations **ppSourceLocations) override; llvm::Module *GetModuleRef(); @@ -120,7 +114,7 @@ class DxcPixDxilInstructionOffsets : public IDxcPixDxilInstructionOffsets } virtual STDMETHODIMP_(DWORD) GetCount() override; - virtual STDMETHODIMP_(DWORD) GetOffsetByIndex(_In_ DWORD Index) override; + virtual STDMETHODIMP_(DWORD) GetOffsetByIndex(DWORD Index) override; }; class DxcPixDxilSourceLocations : public IDxcPixDxilSourceLocations @@ -150,10 +144,9 @@ class DxcPixDxilSourceLocations : public IDxcPixDxilSourceLocations } virtual STDMETHODIMP_(DWORD) GetCount() override; - virtual STDMETHODIMP_(DWORD) GetLineNumberByIndex(_In_ DWORD Index) override; - virtual STDMETHODIMP_(DWORD) GetColumnByIndex(_In_ DWORD Index)override; - virtual STDMETHODIMP GetFileNameByIndex(_In_ DWORD Index, - _Outptr_result_z_ BSTR *Name) override; + virtual STDMETHODIMP_(DWORD) GetLineNumberByIndex(DWORD Index) override; + virtual STDMETHODIMP_(DWORD) GetColumnByIndex(DWORD Index) override; + virtual STDMETHODIMP GetFileNameByIndex(DWORD Index, BSTR *Name) override; }; } // namespace dxil_debug_info diff --git a/lib/DxilDia/DxcPixDxilStorage.cpp b/lib/DxilDia/DxcPixDxilStorage.cpp index 3f65ed4426..5e56fef0ce 100644 --- a/lib/DxilDia/DxcPixDxilStorage.cpp +++ b/lib/DxilDia/DxcPixDxilStorage.cpp @@ -98,18 +98,14 @@ HRESULT CreateDxcPixStorageImpl( return E_UNEXPECTED; } - STDMETHODIMP dxil_debug_info::DxcPixDxilArrayStorage::AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) -{ + LPCWSTR Name, IDxcPixDxilStorage **ppResult) { return E_FAIL; } -STDMETHODIMP dxil_debug_info::DxcPixDxilArrayStorage::Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilArrayStorage::Index(DWORD Index, + IDxcPixDxilStorage **ppResult) { CComPtr IndexedType; IFR(m_pType->GetIndexedType(&IndexedType)); @@ -136,8 +132,7 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilArrayStorage::Index( } STDMETHODIMP dxil_debug_info::DxcPixDxilArrayStorage::GetRegisterNumber( - _Outptr_result_z_ DWORD* pRegisterNumber) -{ + DWORD *pRegisterNumber) { return E_FAIL; } @@ -153,18 +148,15 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilArrayStorage::GetIsAlive() return E_FAIL; } -STDMETHODIMP dxil_debug_info::DxcPixDxilArrayStorage::GetType( - _Outptr_result_z_ IDxcPixType** ppType) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilArrayStorage::GetType(IDxcPixType **ppType) { *ppType = m_pOriginalType; (*ppType)->AddRef(); return S_OK; } STDMETHODIMP dxil_debug_info::DxcPixDxilStructStorage::AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) -{ + LPCWSTR Name, IDxcPixDxilStorage **ppResult) { DWORD FieldOffsetInBits = 0; CComPtr FieldType; if (*Name != 0) @@ -192,16 +184,14 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilStructStorage::AccessField( ppResult); } -STDMETHODIMP dxil_debug_info::DxcPixDxilStructStorage::Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilStructStorage::Index(DWORD Index, + IDxcPixDxilStorage **ppResult) { return E_FAIL; } STDMETHODIMP dxil_debug_info::DxcPixDxilStructStorage::GetRegisterNumber( - _Outptr_result_z_ DWORD* pRegisterNumber) -{ + DWORD *pRegisterNumber) { return E_FAIL; } @@ -217,31 +207,26 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilStructStorage::GetIsAlive() return E_FAIL; } -STDMETHODIMP dxil_debug_info::DxcPixDxilStructStorage::GetType( - _Outptr_result_z_ IDxcPixType** ppType) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilStructStorage::GetType(IDxcPixType **ppType) { *ppType = m_pOriginalType; (*ppType)->AddRef(); return S_OK; } STDMETHODIMP dxil_debug_info::DxcPixDxilScalarStorage::AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) -{ + LPCWSTR Name, IDxcPixDxilStorage **ppResult) { return E_FAIL; } -STDMETHODIMP dxil_debug_info::DxcPixDxilScalarStorage::Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilScalarStorage::Index(DWORD Index, + IDxcPixDxilStorage **ppResult) { return E_FAIL; } STDMETHODIMP dxil_debug_info::DxcPixDxilScalarStorage::GetRegisterNumber( - _Outptr_result_z_ DWORD* pRegisterNumber) -{ + DWORD *pRegisterNumber) { const auto &ValueLocationMap = m_pVarInfo->m_ValueLocationMap; auto RegIt = ValueLocationMap.find( m_OffsetFromStorageStartInBits); @@ -279,9 +264,8 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilScalarStorage::GetIsAlive() return RegIt == ValueLocationMap.end() ? E_FAIL : S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixDxilScalarStorage::GetType( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP +dxil_debug_info::DxcPixDxilScalarStorage::GetType(IDxcPixType **ppType) { *ppType = m_pOriginalType; (*ppType)->AddRef(); return S_OK; diff --git a/lib/DxilDia/DxcPixDxilStorage.h b/lib/DxilDia/DxcPixDxilStorage.h index 0240dc3d96..5e989402de 100644 --- a/lib/DxilDia/DxcPixDxilStorage.h +++ b/lib/DxilDia/DxcPixDxilStorage.h @@ -76,21 +76,16 @@ class DxcPixDxilArrayStorage : public IDxcPixDxilStorage return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage **ppResult) override; + STDMETHODIMP AccessField(LPCWSTR Name, + IDxcPixDxilStorage **ppResult) override; - STDMETHODIMP Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage **ppResult) override; + STDMETHODIMP Index(DWORD Index, IDxcPixDxilStorage **ppResult) override; - STDMETHODIMP GetRegisterNumber( - _Outptr_result_z_ DWORD *pRegisterNumber) override; + STDMETHODIMP GetRegisterNumber(DWORD *pRegisterNumber) override; STDMETHODIMP GetIsAlive() override; - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType **ppType) override; + STDMETHODIMP GetType(IDxcPixType **ppType) override; }; class DxcPixDxilStructStorage : public IDxcPixDxilStorage @@ -127,21 +122,16 @@ class DxcPixDxilStructStorage : public IDxcPixDxilStorage return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage **ppResult) override; + STDMETHODIMP AccessField(LPCWSTR Name, + IDxcPixDxilStorage **ppResult) override; - STDMETHODIMP Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage **ppResult) override; + STDMETHODIMP Index(DWORD Index, IDxcPixDxilStorage **ppResult) override; - STDMETHODIMP GetRegisterNumber( - _Outptr_result_z_ DWORD *pRegisterNumber) override; + STDMETHODIMP GetRegisterNumber(DWORD *pRegisterNumber) override; STDMETHODIMP GetIsAlive() override; - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType **ppType) override; + STDMETHODIMP GetType(IDxcPixType **ppType) override; }; class DxcPixDxilScalarStorage : public IDxcPixDxilStorage @@ -178,21 +168,16 @@ class DxcPixDxilScalarStorage : public IDxcPixDxilStorage return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage **ppResult) override; + STDMETHODIMP AccessField(LPCWSTR Name, + IDxcPixDxilStorage **ppResult) override; - STDMETHODIMP Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage **ppResult) override; + STDMETHODIMP Index(DWORD Index, IDxcPixDxilStorage **ppResult) override; - STDMETHODIMP GetRegisterNumber( - _Outptr_result_z_ DWORD *pRegisterNumber) override; + STDMETHODIMP GetRegisterNumber(DWORD *pRegisterNumber) override; STDMETHODIMP GetIsAlive() override; - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType **ppType) override; + STDMETHODIMP GetType(IDxcPixType **ppType) override; }; } // namespace dxil_debug_info diff --git a/lib/DxilDia/DxcPixEntrypoints.cpp b/lib/DxilDia/DxcPixEntrypoints.cpp index f4afa26f30..b722f42ad5 100644 --- a/lib/DxilDia/DxcPixEntrypoints.cpp +++ b/lib/DxilDia/DxcPixEntrypoints.cpp @@ -399,21 +399,15 @@ struct IDxcPixTypeEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixTypeEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *SizeInBits) override - { + STDMETHODIMP GetSizeInBits(DWORD *SizeInBits) override { return InvokeOnReal(&IInterface::GetSizeInBits, CheckNotNull(OutParam(SizeInBits))); } - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType** ppBaseType) override - { + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override { return InvokeOnReal(&IInterface::UnAlias, CheckNotNull(OutParam(ppBaseType))); } }; @@ -423,21 +417,15 @@ struct IDxcPixConstTypeEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixConstTypeEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *SizeInBits) override - { + STDMETHODIMP GetSizeInBits(DWORD *SizeInBits) override { return InvokeOnReal(&IInterface::GetSizeInBits, CheckNotNull(OutParam(SizeInBits))); } - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType** ppBaseType) override - { + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override { return InvokeOnReal(&IInterface::UnAlias, CheckNotNull(OutParam(ppBaseType))); } }; @@ -447,21 +435,15 @@ struct IDxcPixTypedefTypeEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixTypedefTypeEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *SizeInBits) override - { + STDMETHODIMP GetSizeInBits(DWORD *SizeInBits) override { return InvokeOnReal(&IInterface::GetSizeInBits, CheckNotNull(OutParam(SizeInBits))); } - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType** ppBaseType) override - { + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override { return InvokeOnReal(&IInterface::UnAlias, CheckNotNull(OutParam(ppBaseType))); } }; @@ -471,21 +453,15 @@ struct IDxcPixScalarTypeEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixScalarTypeEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *SizeInBits) override - { + STDMETHODIMP GetSizeInBits(DWORD *SizeInBits) override { return InvokeOnReal(&IInterface::GetSizeInBits, CheckNotNull(OutParam(SizeInBits))); } - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType** ppBaseType) override - { + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override { return InvokeOnReal(&IInterface::UnAlias, CheckNotNull(OutParam(ppBaseType))); } }; @@ -495,39 +471,27 @@ struct IDxcPixArrayTypeEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixArrayTypeEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *SizeInBits) override - { + STDMETHODIMP GetSizeInBits(DWORD *SizeInBits) override { return InvokeOnReal(&IInterface::GetSizeInBits, CheckNotNull(OutParam(SizeInBits))); } - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType** ppBaseType) override - { + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override { return InvokeOnReal(&IInterface::UnAlias, CheckNotNull(OutParam(ppBaseType))); } - STDMETHODIMP GetNumElements( - _Outptr_result_z_ DWORD *ppNumElements) override - { + STDMETHODIMP GetNumElements(DWORD *ppNumElements) override { return InvokeOnReal(&IInterface::GetNumElements, CheckNotNull(OutParam(ppNumElements))); } - STDMETHODIMP GetIndexedType( - _Outptr_result_z_ IDxcPixType **ppElementType) override - { + STDMETHODIMP GetIndexedType(IDxcPixType **ppElementType) override { return InvokeOnReal(&IInterface::GetIndexedType, CheckNotNull(OutParam(ppElementType))); } - STDMETHODIMP GetElementType( - _Outptr_result_z_ IDxcPixType** ppElementType) override - { + STDMETHODIMP GetElementType(IDxcPixType **ppElementType) override { return InvokeOnReal(&IInterface::GetElementType, CheckNotNull(OutParam(ppElementType))); } }; @@ -537,21 +501,15 @@ struct IDxcPixStructFieldEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixStructFieldEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType** ppType) override - { + STDMETHODIMP GetType(IDxcPixType **ppType) override { return InvokeOnReal(&IInterface::GetType, CheckNotNull(OutParam(ppType))); } - STDMETHODIMP GetOffsetInBits( - _Outptr_result_z_ DWORD *pOffsetInBits) override - { + STDMETHODIMP GetOffsetInBits(DWORD *pOffsetInBits) override { return InvokeOnReal(&IInterface::GetOffsetInBits, CheckNotNull(OutParam(pOffsetInBits))); } }; @@ -561,47 +519,34 @@ struct IDxcPixStructType2Entrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixStructType2Entrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *SizeInBits) override - { + STDMETHODIMP GetSizeInBits(DWORD *SizeInBits) override { return InvokeOnReal(&IInterface::GetSizeInBits, CheckNotNull(OutParam(SizeInBits))); } - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType** ppBaseType) override - { + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override { return InvokeOnReal(&IInterface::UnAlias, CheckNotNull(OutParam(ppBaseType))); } - STDMETHODIMP GetNumFields( - _Outptr_result_z_ DWORD* ppNumFields) override - { - return InvokeOnReal(&IInterface::GetNumFields, CheckNotNull(OutParam(ppNumFields))); + STDMETHODIMP GetNumFields(DWORD *ppNumFields) override { + return InvokeOnReal(&IInterface::GetNumFields, + CheckNotNull(OutParam(ppNumFields))); } - STDMETHODIMP GetFieldByIndex( - DWORD dwIndex, - _Outptr_result_z_ IDxcPixStructField **ppField) override - { + STDMETHODIMP GetFieldByIndex(DWORD dwIndex, + IDxcPixStructField **ppField) override { return InvokeOnReal(&IInterface::GetFieldByIndex, dwIndex, CheckNotNull(OutParam(ppField))); } - STDMETHODIMP GetFieldByName( - _In_ LPCWSTR lpName, - _Outptr_result_z_ IDxcPixStructField** ppField) override - { + STDMETHODIMP GetFieldByName(LPCWSTR lpName, + IDxcPixStructField **ppField) override { return InvokeOnReal(&IInterface::GetFieldByName, CheckNotNull(InParam(lpName)), CheckNotNull(OutParam(ppField))); } - STDMETHODIMP GetBaseType( - _Outptr_result_z_ IDxcPixType** ppType) override - { + STDMETHODIMP GetBaseType(IDxcPixType **ppType) override { return InvokeOnReal(&IInterface::GetBaseType, CheckNotNull(OutParam(ppType))); } }; @@ -611,23 +556,16 @@ struct IDxcPixDxilStorageEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixDxilStorageEntrypoint); - STDMETHODIMP AccessField( - _In_ LPCWSTR Name, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) override - { + STDMETHODIMP AccessField(LPCWSTR Name, + IDxcPixDxilStorage **ppResult) override { return InvokeOnReal(&IInterface::AccessField, CheckNotNull(InParam(Name)), CheckNotNull(OutParam(ppResult))); } - STDMETHODIMP Index( - _In_ DWORD Index, - _COM_Outptr_ IDxcPixDxilStorage** ppResult) override - { + STDMETHODIMP Index(DWORD Index, IDxcPixDxilStorage **ppResult) override { return InvokeOnReal(&IInterface::Index, Index, CheckNotNull(OutParam(ppResult))); } - STDMETHODIMP GetRegisterNumber( - _Outptr_result_z_ DWORD *pRegNum) override - { + STDMETHODIMP GetRegisterNumber(DWORD *pRegNum) override { return InvokeOnReal(&IInterface::GetRegisterNumber, CheckNotNull(OutParam(pRegNum))); } @@ -636,9 +574,7 @@ struct IDxcPixDxilStorageEntrypoint : public Entrypoint return InvokeOnReal(&IInterface::GetIsAlive); } - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType** ppType) override - { + STDMETHODIMP GetType(IDxcPixType **ppType) override { return InvokeOnReal(&IInterface::GetType, CheckNotNull(OutParam(ppType))); } }; @@ -648,22 +584,17 @@ struct IDxcPixVariableEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixVariableEntrypoint); - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override - { + STDMETHODIMP GetName(BSTR *Name) override { return InvokeOnReal(&IInterface::GetName, CheckNotNull(OutParam(Name))); } - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType **ppType) override - { + STDMETHODIMP GetType(IDxcPixType **ppType) override { return InvokeOnReal(&IInterface::GetType, CheckNotNull(OutParam(ppType))); } - STDMETHODIMP GetStorage( - _COM_Outptr_ IDxcPixDxilStorage **ppStorage) override - { - return InvokeOnReal(&IInterface::GetStorage, CheckNotNull(OutParam(ppStorage))); + STDMETHODIMP GetStorage(IDxcPixDxilStorage **ppStorage) override { + return InvokeOnReal(&IInterface::GetStorage, + CheckNotNull(OutParam(ppStorage))); } }; DEFINE_ENTRYPOINT_WRAPPER_TRAIT(IDxcPixVariable); @@ -672,23 +603,17 @@ struct IDxcPixDxilLiveVariablesEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixDxilDebugInfoEntrypoint); - STDMETHODIMP GetLiveVariablesAt( - _In_ DWORD InstructionOffset, - _COM_Outptr_ IDxcPixDxilLiveVariables **ppLiveVariables) override - { + STDMETHODIMP + GetLiveVariablesAt(DWORD InstructionOffset, + IDxcPixDxilLiveVariables **ppLiveVariables) override { return InvokeOnReal(&IInterface::GetLiveVariablesAt, InstructionOffset, CheckNotNull(OutParam(ppLiveVariables))); } - STDMETHODIMP IsVariableInRegister( - _In_ DWORD InstructionOffset, - _In_ const wchar_t *VariableName) override - { + STDMETHODIMP IsVariableInRegister(DWORD InstructionOffset, + const wchar_t *VariableName) override { return InvokeOnReal(&IInterface::IsVariableInRegister, InstructionOffset, CheckNotNull(InParam(VariableName))); } - STDMETHODIMP GetFunctionName( - _In_ DWORD InstructionOffset, - _Outptr_result_z_ BSTR *ppFunctionName) override - { + STDMETHODIMP GetFunctionName(DWORD InstructionOffset, + BSTR *ppFunctionName) override { return InvokeOnReal(&IInterface::GetFunctionName, InstructionOffset, CheckNotNull(OutParam(ppFunctionName))); } - STDMETHODIMP GetStackDepth( - _In_ DWORD InstructionOffset, - _Outptr_ DWORD *StackDepth) override - { + STDMETHODIMP GetStackDepth(DWORD InstructionOffset, + DWORD *StackDepth) override { return InvokeOnReal(&IInterface::GetStackDepth, InstructionOffset, CheckNotNull(OutParam(StackDepth))); } STDMETHODIMP InstructionOffsetsFromSourceLocation( - _In_ const wchar_t* FileName, - _In_ DWORD SourceLine, - _In_ DWORD SourceColumn, - _COM_Outptr_ IDxcPixDxilInstructionOffsets** ppOffsets) override - { + const wchar_t *FileName, DWORD SourceLine, DWORD SourceColumn, + IDxcPixDxilInstructionOffsets **ppOffsets) override { return InvokeOnReal(&IInterface::InstructionOffsetsFromSourceLocation, CheckNotNull(InParam(FileName)), SourceLine, SourceColumn, CheckNotNull(OutParam(ppOffsets))); } STDMETHODIMP SourceLocationsFromInstructionOffset( - _In_ DWORD InstructionOffset, - _COM_Outptr_ IDxcPixDxilSourceLocations** ppSourceLocations) override - { - return InvokeOnReal(&IInterface::SourceLocationsFromInstructionOffset, InstructionOffset, CheckNotNull(OutParam(ppSourceLocations))); + DWORD InstructionOffset, + IDxcPixDxilSourceLocations **ppSourceLocations) override { + return InvokeOnReal(&IInterface::SourceLocationsFromInstructionOffset, + InstructionOffset, + CheckNotNull(OutParam(ppSourceLocations))); } }; DEFINE_ENTRYPOINT_WRAPPER_TRAIT(IDxcPixDxilDebugInfo); @@ -753,8 +669,7 @@ struct IDxcPixDxilInstructionOffsetsEntrypoint : public Entrypoint { DEFINE_ENTRYPOINT_BOILERPLATE(IDxcPixCompilationInfoEntrypoint); - virtual STDMETHODIMP - GetSourceFile(_In_ DWORD SourceFileOrdinal, - _Outptr_result_z_ BSTR *pSourceName, - _Outptr_result_z_ BSTR *pSourceContents) override { + virtual STDMETHODIMP GetSourceFile(DWORD SourceFileOrdinal, BSTR *pSourceName, + BSTR *pSourceContents) override { return InvokeOnReal(&IInterface::GetSourceFile, SourceFileOrdinal, CheckNotNull(OutParam(pSourceName)), CheckNotNull(OutParam(pSourceContents)) ); } - virtual STDMETHODIMP GetArguments(_Outptr_result_z_ BSTR* pArguments) override - { + virtual STDMETHODIMP GetArguments(BSTR *pArguments) override { return InvokeOnReal(&IInterface::GetArguments, CheckNotNull(OutParam(pArguments))); } - virtual STDMETHODIMP - GetMacroDefinitions(_Outptr_result_z_ BSTR* pMacroDefinitions) override - { + virtual STDMETHODIMP GetMacroDefinitions(BSTR *pMacroDefinitions) override { return InvokeOnReal(&IInterface::GetMacroDefinitions, CheckNotNull(OutParam(pMacroDefinitions))); - } - virtual STDMETHODIMP - GetEntryPointFile(_Outptr_result_z_ BSTR* pEntryPointFile) override { + virtual STDMETHODIMP GetEntryPointFile(BSTR *pEntryPointFile) override { return InvokeOnReal(&IInterface::GetEntryPointFile, CheckNotNull(OutParam(pEntryPointFile))); - } - virtual STDMETHODIMP - GetHlslTarget(_Outptr_result_z_ BSTR* pHlslTarget) override { + virtual STDMETHODIMP GetHlslTarget(BSTR *pHlslTarget) override { return InvokeOnReal(&IInterface::GetHlslTarget, CheckNotNull(OutParam(pHlslTarget))); - } - virtual STDMETHODIMP - GetEntryPoint(_Outptr_result_z_ BSTR* pEntryPoint) override - { + virtual STDMETHODIMP GetEntryPoint(BSTR *pEntryPoint) override { return InvokeOnReal(&IInterface::GetEntryPoint, CheckNotNull(OutParam(pEntryPoint))); - } }; DEFINE_ENTRYPOINT_WRAPPER_TRAIT(IDxcPixCompilationInfo); @@ -885,8 +784,7 @@ static STDMETHODIMP NewDxcPixDxilDebugInfoImpl( } STDMETHODIMP dxil_dia::Session::NewDxcPixDxilDebugInfo( - _COM_Outptr_ IDxcPixDxilDebugInfo** ppDxilDebugInfo) -{ + IDxcPixDxilDebugInfo **ppDxilDebugInfo) { return SetupAndRun( m_pMalloc, &NewDxcPixDxilDebugInfoImpl, @@ -908,8 +806,7 @@ static STDMETHODIMP NewDxcPixCompilationInfoImpl( } STDMETHODIMP dxil_dia::Session::NewDxcPixCompilationInfo( - _COM_Outptr_ IDxcPixCompilationInfo **ppCompilationInfo) -{ + IDxcPixCompilationInfo **ppCompilationInfo) { return SetupAndRun( m_pMalloc, &NewDxcPixCompilationInfoImpl, diff --git a/lib/DxilDia/DxcPixTypes.cpp b/lib/DxilDia/DxcPixTypes.cpp index 79f338df95..f6660a5f42 100644 --- a/lib/DxilDia/DxcPixTypes.cpp +++ b/lib/DxilDia/DxcPixTypes.cpp @@ -87,9 +87,7 @@ HRESULT dxil_debug_info::CreateDxcPixType( return E_UNEXPECTED; } -STDMETHODIMP dxil_debug_info::DxcPixConstType::GetName( - _Outptr_result_z_ BSTR *Name) -{ +STDMETHODIMP dxil_debug_info::DxcPixConstType::GetName(BSTR *Name) { CComPtr BaseType; IFR(UnAlias(&BaseType)); @@ -102,69 +100,55 @@ STDMETHODIMP dxil_debug_info::DxcPixConstType::GetName( return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixConstType::GetSizeInBits( - _Outptr_result_z_ DWORD *pSize) -{ +STDMETHODIMP dxil_debug_info::DxcPixConstType::GetSizeInBits(DWORD *pSize) { CComPtr BaseType; IFR(UnAlias(&BaseType)); return BaseType->GetSizeInBits(pSize); } -STDMETHODIMP dxil_debug_info::DxcPixConstType::UnAlias( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP dxil_debug_info::DxcPixConstType::UnAlias(IDxcPixType **ppType) { return CreateDxcPixType(m_pDxilDebugInfo, m_pBaseType, ppType); } -STDMETHODIMP dxil_debug_info::DxcPixTypedefType::GetName( - _Outptr_result_z_ BSTR *Name) +STDMETHODIMP dxil_debug_info::DxcPixTypedefType::GetName(BSTR *Name) { *Name = CComBSTR(CA2W(GetTypeNameOrDefault(m_pType))).Detach(); return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixTypedefType::GetSizeInBits( - _Outptr_result_z_ DWORD *pSize) -{ +STDMETHODIMP dxil_debug_info::DxcPixTypedefType::GetSizeInBits(DWORD *pSize) { CComPtr BaseType; IFR(UnAlias(&BaseType)); return BaseType->GetSizeInBits(pSize); } -STDMETHODIMP dxil_debug_info::DxcPixTypedefType::UnAlias( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP dxil_debug_info::DxcPixTypedefType::UnAlias(IDxcPixType **ppType) { return CreateDxcPixType(m_pDxilDebugInfo, m_pBaseType, ppType); } -STDMETHODIMP dxil_debug_info::DxcPixScalarType::GetName( - _Outptr_result_z_ BSTR *Name) +STDMETHODIMP dxil_debug_info::DxcPixScalarType::GetName(BSTR *Name) { *Name = CComBSTR(CA2W(GetTypeNameOrDefault(m_pType))).Detach(); return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixScalarType::GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) -{ +STDMETHODIMP +dxil_debug_info::DxcPixScalarType::GetSizeInBits(DWORD *pSizeInBits) { *pSizeInBits = m_pType->getSizeInBits(); return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixScalarType::UnAlias( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP dxil_debug_info::DxcPixScalarType::UnAlias(IDxcPixType **ppType) { *ppType = this; this->AddRef(); return S_FALSE; } -STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetName( - _Outptr_result_z_ BSTR *Name) +STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetName(BSTR *Name) { CComBSTR name(CA2W(GetTypeNameOrDefault(m_pBaseType))); name.Append(L"[]"); @@ -172,9 +156,8 @@ STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetName( return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) -{ +STDMETHODIMP +dxil_debug_info::DxcPixArrayType::GetSizeInBits(DWORD *pSizeInBits) { *pSizeInBits = m_pArray->getSizeInBits(); for (unsigned ContainerDims = 0; ContainerDims < m_DimNum; ++ContainerDims) { @@ -189,17 +172,14 @@ STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetSizeInBits( return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixArrayType::UnAlias( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP dxil_debug_info::DxcPixArrayType::UnAlias(IDxcPixType **ppType) { *ppType = this; this->AddRef(); return S_FALSE; } -STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetNumElements( - _Outptr_result_z_ DWORD *ppNumElements) -{ +STDMETHODIMP +dxil_debug_info::DxcPixArrayType::GetNumElements(DWORD *ppNumElements) { auto* SR = llvm::dyn_cast(m_pArray->getElements()[m_DimNum]); if (SR == nullptr) { @@ -211,8 +191,7 @@ STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetNumElements( } STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetIndexedType( - _Outptr_result_z_ IDxcPixType **ppIndexedElement) -{ + IDxcPixType **ppIndexedElement) { assert(1 + m_DimNum <= m_pArray->getElements().size()); if (1 + m_DimNum == m_pArray->getElements().size()) { @@ -227,38 +206,32 @@ STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetIndexedType( 1 + m_DimNum); } -STDMETHODIMP dxil_debug_info::DxcPixArrayType::GetElementType( - _Outptr_result_z_ IDxcPixType **ppElementType) -{ +STDMETHODIMP +dxil_debug_info::DxcPixArrayType::GetElementType(IDxcPixType **ppElementType) { return CreateDxcPixType(m_pDxilDebugInfo, m_pBaseType, ppElementType); } -STDMETHODIMP dxil_debug_info::DxcPixStructType::GetName( - _Outptr_result_z_ BSTR *Name) +STDMETHODIMP dxil_debug_info::DxcPixStructType::GetName(BSTR *Name) { *Name = CComBSTR(CA2W(GetTypeNameOrDefault(m_pStruct))).Detach(); return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixStructType::GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) -{ +STDMETHODIMP +dxil_debug_info::DxcPixStructType::GetSizeInBits(DWORD *pSizeInBits) { *pSizeInBits = m_pStruct->getSizeInBits(); return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixStructType::UnAlias( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP dxil_debug_info::DxcPixStructType::UnAlias(IDxcPixType **ppType) { *ppType = this; this->AddRef(); return S_FALSE; } -STDMETHODIMP dxil_debug_info::DxcPixStructType::GetNumFields( - _Outptr_result_z_ DWORD *ppNumFields) -{ +STDMETHODIMP +dxil_debug_info::DxcPixStructType::GetNumFields(DWORD *ppNumFields) { *ppNumFields = 0; // DWARF lists the ancestor class, if any, and member fns // as a member element. Don't count those as data members: @@ -273,9 +246,7 @@ STDMETHODIMP dxil_debug_info::DxcPixStructType::GetNumFields( } STDMETHODIMP dxil_debug_info::DxcPixStructType::GetFieldByIndex( - DWORD dwIndex, - _Outptr_result_z_ IDxcPixStructField **ppField) -{ + DWORD dwIndex, IDxcPixStructField **ppField) { *ppField = nullptr; // DWARF lists the ancestor class, if any, and member fns @@ -307,9 +278,7 @@ STDMETHODIMP dxil_debug_info::DxcPixStructType::GetFieldByIndex( } STDMETHODIMP dxil_debug_info::DxcPixStructType::GetFieldByName( - _In_ LPCWSTR lpName, - _Outptr_result_z_ IDxcPixStructField **ppField) -{ + LPCWSTR lpName, IDxcPixStructField **ppField) { std::string name = std::string(CW2A(lpName)); for (auto *Node : m_pStruct->getElements()) { @@ -338,9 +307,8 @@ STDMETHODIMP dxil_debug_info::DxcPixStructType::GetFieldByName( return E_BOUNDS; } -STDMETHODIMP dxil_debug_info::DxcPixStructType::GetBaseType( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP +dxil_debug_info::DxcPixStructType::GetBaseType(IDxcPixType **ppType) { for (auto *Node : m_pStruct->getElements()) { auto* pDIField = llvm::dyn_cast(Node); @@ -366,23 +334,19 @@ STDMETHODIMP dxil_debug_info::DxcPixStructType::GetBaseType( return E_NOINTERFACE; } -STDMETHODIMP dxil_debug_info::DxcPixStructField::GetName( - _Outptr_result_z_ BSTR *Name) +STDMETHODIMP dxil_debug_info::DxcPixStructField::GetName(BSTR *Name) { *Name = CComBSTR(CA2W(GetTypeNameOrDefault(m_pField))).Detach(); return S_OK; } -STDMETHODIMP dxil_debug_info::DxcPixStructField::GetType( - _Outptr_result_z_ IDxcPixType **ppType) -{ +STDMETHODIMP dxil_debug_info::DxcPixStructField::GetType(IDxcPixType **ppType) { return CreateDxcPixType(m_pDxilDebugInfo, m_pType, ppType); } -STDMETHODIMP dxil_debug_info::DxcPixStructField::GetOffsetInBits( - _Outptr_result_z_ DWORD *pOffsetInBits) -{ +STDMETHODIMP +dxil_debug_info::DxcPixStructField::GetOffsetInBits(DWORD *pOffsetInBits) { *pOffsetInBits = m_pField->getOffsetInBits(); return S_OK; } diff --git a/lib/DxilDia/DxcPixTypes.h b/lib/DxilDia/DxcPixTypes.h index 8ff75570f5..7d4b0dc771 100644 --- a/lib/DxilDia/DxcPixTypes.h +++ b/lib/DxilDia/DxcPixTypes.h @@ -58,14 +58,11 @@ class DxcPixConstType : public IDxcPixConstType return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD * pSizeInBits) override; + STDMETHODIMP GetSizeInBits(DWORD *pSizeInBits) override; - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType **ppType) override; + STDMETHODIMP UnAlias(IDxcPixType **ppType) override; }; class DxcPixTypedefType : public IDxcPixTypedefType @@ -96,14 +93,11 @@ class DxcPixTypedefType : public IDxcPixTypedefType return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) override; + STDMETHODIMP GetSizeInBits(DWORD *pSizeInBits) override; - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType **ppBaseType) override; + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override; }; class DxcPixScalarType : public IDxcPixScalarType @@ -131,14 +125,11 @@ class DxcPixScalarType : public IDxcPixScalarType return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) override; + STDMETHODIMP GetSizeInBits(DWORD *pSizeInBits) override; - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType **ppBaseType) override; + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override; }; class DxcPixArrayType : public IDxcPixArrayType @@ -181,23 +172,17 @@ class DxcPixArrayType : public IDxcPixArrayType return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) override; + STDMETHODIMP GetSizeInBits(DWORD *pSizeInBits) override; - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType **ppBaseType) override; + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override; - STDMETHODIMP GetNumElements( - _Outptr_result_z_ DWORD *ppNumElements) override; + STDMETHODIMP GetNumElements(DWORD *ppNumElements) override; - STDMETHODIMP GetIndexedType( - _Outptr_result_z_ IDxcPixType **ppElementType) override; + STDMETHODIMP GetIndexedType(IDxcPixType **ppElementType) override; - STDMETHODIMP GetElementType( - _Outptr_result_z_ IDxcPixType **ppElementType) override; + STDMETHODIMP GetElementType(IDxcPixType **ppElementType) override; }; class DxcPixStructType : public IDxcPixStructType2 @@ -231,28 +216,21 @@ class DxcPixStructType : public IDxcPixStructType2 return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetSizeInBits( - _Outptr_result_z_ DWORD *pSizeInBits) override; + STDMETHODIMP GetSizeInBits(DWORD *pSizeInBits) override; - STDMETHODIMP UnAlias( - _Outptr_result_z_ IDxcPixType **ppBaseType) override; + STDMETHODIMP UnAlias(IDxcPixType **ppBaseType) override; - STDMETHODIMP GetNumFields( - _Outptr_result_z_ DWORD* ppNumFields) override; + STDMETHODIMP GetNumFields(DWORD *ppNumFields) override; - STDMETHODIMP GetFieldByIndex( - DWORD dwIndex, - _Outptr_result_z_ IDxcPixStructField **ppField) override; + STDMETHODIMP GetFieldByIndex(DWORD dwIndex, + IDxcPixStructField **ppField) override; - STDMETHODIMP GetFieldByName( - _In_ LPCWSTR lpName, - _Outptr_result_z_ IDxcPixStructField **ppField) override; + STDMETHODIMP GetFieldByName(LPCWSTR lpName, + IDxcPixStructField **ppField) override; - STDMETHODIMP GetBaseType( - _COM_Outptr_ IDxcPixType **ppType) override; + STDMETHODIMP GetBaseType(IDxcPixType **ppType) override; }; class DxcPixStructField : public IDxcPixStructField @@ -283,13 +261,10 @@ class DxcPixStructField : public IDxcPixStructField return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType **ppType) override; + STDMETHODIMP GetType(IDxcPixType **ppType) override; - STDMETHODIMP GetOffsetInBits( - _Outptr_result_z_ DWORD *pOffsetInBits) override; + STDMETHODIMP GetOffsetInBits(DWORD *pOffsetInBits) override; }; } // namespace dxil_debug_info diff --git a/lib/DxilDia/DxcPixVariables.cpp b/lib/DxilDia/DxcPixVariables.cpp index 00cfbd9bea..a52cb5cf2e 100644 --- a/lib/DxilDia/DxcPixVariables.cpp +++ b/lib/DxilDia/DxcPixVariables.cpp @@ -62,31 +62,23 @@ class DxcPixVariable : public IDxcPixVariable } public: - STDMETHODIMP GetName( - _Outptr_result_z_ BSTR *Name) override; + STDMETHODIMP GetName(BSTR *Name) override; - STDMETHODIMP GetType( - _Outptr_result_z_ IDxcPixType** ppType) override; + STDMETHODIMP GetType(IDxcPixType **ppType) override; - STDMETHODIMP GetStorage( - _COM_Outptr_ IDxcPixDxilStorage** ppStorage) override; + STDMETHODIMP GetStorage(IDxcPixDxilStorage **ppStorage) override; }; } // namespace dxil_debug_info template -STDMETHODIMP dxil_debug_info::DxcPixVariable::GetName( - _Outptr_result_z_ BSTR* Name) -{ +STDMETHODIMP dxil_debug_info::DxcPixVariable::GetName(BSTR *Name) { *Name = CComBSTR(CA2W(m_pVariable->getName().data())).Detach(); return S_OK; } template -STDMETHODIMP dxil_debug_info::DxcPixVariable::GetType( - _Outptr_result_z_ IDxcPixType **ppType -) -{ +STDMETHODIMP dxil_debug_info::DxcPixVariable::GetType(IDxcPixType **ppType) { return dxil_debug_info::CreateDxcPixType( m_pDxilDebugInfo, m_pType, @@ -94,10 +86,8 @@ STDMETHODIMP dxil_debug_info::DxcPixVariable::GetType( } template -STDMETHODIMP dxil_debug_info::DxcPixVariable::GetStorage( - _COM_Outptr_ IDxcPixDxilStorage **ppStorage -) -{ +STDMETHODIMP +dxil_debug_info::DxcPixVariable::GetStorage(IDxcPixDxilStorage **ppStorage) { const unsigned InitialOffsetInBits = 0; return CreateDxcPixStorage( m_pDxilDebugInfo, @@ -145,21 +135,17 @@ class DxcPixDxilLiveVariables : public IDxcPixDxilLiveVariables return DoBasicQueryInterface(this, iid, ppvObject); } - STDMETHODIMP GetCount( - _Outptr_ DWORD *dwSize) override; + STDMETHODIMP GetCount(DWORD *dwSize) override; - STDMETHODIMP GetVariableByIndex( - _In_ DWORD Index, - _Outptr_result_z_ IDxcPixVariable** ppVariable) override; + STDMETHODIMP GetVariableByIndex(DWORD Index, + IDxcPixVariable **ppVariable) override; - STDMETHODIMP GetVariableByName( - _In_ LPCWSTR Name, - _Outptr_result_z_ IDxcPixVariable** ppVariable) override; + STDMETHODIMP GetVariableByName(LPCWSTR Name, + IDxcPixVariable **ppVariable) override; }; } // namespace dxil_debug_info -STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::GetCount( - _Outptr_ DWORD *dwSize) { +STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::GetCount(DWORD *dwSize) { *dwSize = m_LiveVars.size(); return S_OK; } @@ -192,9 +178,7 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::CreateDxcPixVariable( } STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::GetVariableByIndex( - _In_ DWORD Index, - _Outptr_result_z_ IDxcPixVariable **ppVariable) -{ + DWORD Index, IDxcPixVariable **ppVariable) { if (Index >= m_LiveVars.size()) { return E_BOUNDS; @@ -205,9 +189,7 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::GetVariableByIndex( } STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::GetVariableByName( - _In_ LPCWSTR Name, - _Outptr_result_z_ IDxcPixVariable **ppVariable) -{ + LPCWSTR Name, IDxcPixVariable **ppVariable) { std::string name = std::string(CW2A(Name)); for (auto *VarInfo : m_LiveVars) diff --git a/lib/DxilDia/DxilDiaDataSource.cpp b/lib/DxilDia/DxilDiaDataSource.cpp index 10f46254e7..93cda137ec 100644 --- a/lib/DxilDia/DxilDiaDataSource.cpp +++ b/lib/DxilDia/DxilDiaDataSource.cpp @@ -44,14 +44,14 @@ STDMETHODIMP dxil_dia::DataSource::get_lastError(BSTR *pRetVal) { namespace dxil_dia { -std::unique_ptr getMemBufferFromBlob(_In_ IDxcBlob *pBlob, - const llvm::Twine &BufferName) { +std::unique_ptr +getMemBufferFromBlob(IDxcBlob *pBlob, const llvm::Twine &BufferName) { llvm::StringRef Data((LPSTR)pBlob->GetBufferPointer(), pBlob->GetBufferSize()); return llvm::MemoryBuffer::getMemBufferCopy(Data, BufferName); } -std::unique_ptr getMemBufferFromStream(_In_ IStream *pStream, - const llvm::Twine &BufferName) { +std::unique_ptr +getMemBufferFromStream(IStream *pStream, const llvm::Twine &BufferName) { CComPtr pBlob; if (SUCCEEDED(pStream->QueryInterface(&pBlob))) { return getMemBufferFromBlob(pBlob, BufferName); @@ -69,7 +69,7 @@ std::unique_ptr getMemBufferFromStream(_In_ IStream *pStream } } // namespace dxil_dia -STDMETHODIMP dxil_dia::DataSource::loadDataFromIStream(_In_ IStream *pInputIStream) { +STDMETHODIMP dxil_dia::DataSource::loadDataFromIStream(IStream *pInputIStream) { try { DxcThreadMalloc TM(m_pMalloc); if (m_module.get() != nullptr) { @@ -151,7 +151,7 @@ STDMETHODIMP dxil_dia::DataSource::loadDataFromIStream(_In_ IStream *pInputIStre return S_OK; } -STDMETHODIMP dxil_dia::DataSource::openSession(_COM_Outptr_ IDiaSession **ppSession) { +STDMETHODIMP dxil_dia::DataSource::openSession(IDiaSession **ppSession) { DxcThreadMalloc TM(m_pMalloc); *ppSession = nullptr; if (m_module.get() == nullptr) @@ -171,8 +171,7 @@ STDMETHODIMP dxil_dia::DataSource::openSession(_COM_Outptr_ IDiaSession **ppSess return S_OK; } - -HRESULT CreateDxcDiaDataSource(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcDiaDataSource(REFIID riid, LPVOID *ppv) { CComPtr result = CreateOnMalloc(DxcGetThreadMallocNoRef()); if (result == nullptr) { *ppv = nullptr; diff --git a/lib/DxilDia/DxilDiaDataSource.h b/lib/DxilDia/DxilDiaDataSource.h index 7bd9af9861..695b0b53fe 100644 --- a/lib/DxilDia/DxilDiaDataSource.h +++ b/lib/DxilDia/DxilDiaDataSource.h @@ -46,39 +46,36 @@ class DataSource : public IDiaDataSource { STDMETHODIMP get_lastError(BSTR *pRetVal) override; - STDMETHODIMP loadDataFromPdb(_In_ LPCOLESTR pdbPath) override { return ENotImpl(); } + STDMETHODIMP loadDataFromPdb(LPCOLESTR pdbPath) override { + return ENotImpl(); + } - STDMETHODIMP loadAndValidateDataFromPdb( - _In_ LPCOLESTR pdbPath, - _In_ GUID *pcsig70, - _In_ DWORD sig, - _In_ DWORD age) override { return ENotImpl(); } + STDMETHODIMP loadAndValidateDataFromPdb(LPCOLESTR pdbPath, GUID *pcsig70, + DWORD sig, DWORD age) override { + return ENotImpl(); + } - STDMETHODIMP loadDataForExe( - _In_ LPCOLESTR executable, - _In_ LPCOLESTR searchPath, - _In_ IUnknown *pCallback) override { return ENotImpl(); } + STDMETHODIMP loadDataForExe(LPCOLESTR executable, LPCOLESTR searchPath, + IUnknown *pCallback) override { + return ENotImpl(); + } - STDMETHODIMP loadDataFromIStream(_In_ IStream *pIStream) override; + STDMETHODIMP loadDataFromIStream(IStream *pIStream) override; - STDMETHODIMP openSession(_COM_Outptr_ IDiaSession **ppSession) override; + STDMETHODIMP openSession(IDiaSession **ppSession) override; HRESULT STDMETHODCALLTYPE loadDataFromCodeViewInfo( - _In_ LPCOLESTR executable, - _In_ LPCOLESTR searchPath, - _In_ DWORD cbCvInfo, - _In_ BYTE *pbCvInfo, - _In_ IUnknown *pCallback) override { return ENotImpl(); } + LPCOLESTR executable, LPCOLESTR searchPath, DWORD cbCvInfo, + BYTE *pbCvInfo, IUnknown *pCallback) override { + return ENotImpl(); + } HRESULT STDMETHODCALLTYPE loadDataFromMiscInfo( - _In_ LPCOLESTR executable, - _In_ LPCOLESTR searchPath, - _In_ DWORD timeStampExe, - _In_ DWORD timeStampDbg, - _In_ DWORD sizeOfExe, - _In_ DWORD cbMiscInfo, - _In_ BYTE *pbMiscInfo, - _In_ IUnknown *pCallback) override { return ENotImpl(); } + LPCOLESTR executable, LPCOLESTR searchPath, DWORD timeStampExe, + DWORD timeStampDbg, DWORD sizeOfExe, DWORD cbMiscInfo, BYTE *pbMiscInfo, + IUnknown *pCallback) override { + return ENotImpl(); + } }; } // namespace dxil_dia diff --git a/lib/DxilDia/DxilDiaEnumTables.cpp b/lib/DxilDia/DxilDiaEnumTables.cpp index 8e72e4059e..848016a634 100644 --- a/lib/DxilDia/DxilDiaEnumTables.cpp +++ b/lib/DxilDia/DxilDiaEnumTables.cpp @@ -15,7 +15,7 @@ #include "DxilDiaSession.h" #include "DxilDiaTable.h" -STDMETHODIMP dxil_dia::EnumTables::get_Count(_Out_ LONG *pRetVal) { +STDMETHODIMP dxil_dia::EnumTables::get_Count(LONG *pRetVal) { *pRetVal = ((unsigned)Table::LastKind - (unsigned)Table::FirstKind) + 1; return S_OK; } diff --git a/lib/DxilDia/DxilDiaEnumTables.h b/lib/DxilDia/DxilDiaEnumTables.h index 3758ceae4f..d3c2d5eefd 100644 --- a/lib/DxilDia/DxilDiaEnumTables.h +++ b/lib/DxilDia/DxilDiaEnumTables.h @@ -48,7 +48,7 @@ class EnumTables : public IDiaEnumTables { STDMETHODIMP get__NewEnum( /* [retval][out] */ IUnknown **pRetVal) override { return ENotImpl(); } - STDMETHODIMP get_Count(_Out_ LONG *pRetVal) override; + STDMETHODIMP get_Count(LONG *pRetVal) override; STDMETHODIMP Item( /* [in] */ VARIANT index, diff --git a/lib/DxilDia/DxilDiaSession.cpp b/lib/DxilDia/DxilDiaSession.cpp index 96cb1337ce..883b0e3f7a 100644 --- a/lib/DxilDia/DxilDiaSession.cpp +++ b/lib/DxilDia/DxilDiaSession.cpp @@ -137,8 +137,7 @@ STDMETHODIMP dxil_dia::Session::get_globalScope( return S_OK; } -STDMETHODIMP dxil_dia::Session::getEnumTables( - /* [out] */ _COM_Outptr_ IDiaEnumTables **ppEnumTables) { +STDMETHODIMP dxil_dia::Session::getEnumTables(IDiaEnumTables **ppEnumTables) { if (!m_pEnumTables) { DxcThreadMalloc TM(m_pMalloc); IFR(EnumTables::Create(this, &m_pEnumTables)); diff --git a/lib/DxilDia/DxilDiaSession.h b/lib/DxilDia/DxilDiaSession.h index 713f5137f5..ccd8c12342 100644 --- a/lib/DxilDia/DxilDiaSession.h +++ b/lib/DxilDia/DxilDiaSession.h @@ -84,8 +84,7 @@ class Session : public IDiaSession, public IDxcPixDxilDebugInfoFactory { STDMETHODIMP get_globalScope( /* [retval][out] */ IDiaSymbol **pRetVal) override; - STDMETHODIMP getEnumTables( - _COM_Outptr_ IDiaEnumTables **ppEnumTables) override; + STDMETHODIMP getEnumTables(IDiaEnumTables **ppEnumTables) override; STDMETHODIMP getSymbolsByAddr( /* [out] */ IDiaEnumSymbolsByAddr **ppEnumbyAddr) override { return ENotImpl(); } @@ -376,11 +375,11 @@ class Session : public IDiaSession, public IDxcPixDxilDebugInfoFactory { /* [in] */ IDiaSymbol *pSymbol, /* [out] */ IDiaInputAssemblyFile **ppResult) override { return ENotImpl(); } - STDMETHODIMP NewDxcPixDxilDebugInfo( - _COM_Outptr_ IDxcPixDxilDebugInfo** ppDxilDebugInfo) override; + STDMETHODIMP + NewDxcPixDxilDebugInfo(IDxcPixDxilDebugInfo **ppDxilDebugInfo) override; - STDMETHODIMP NewDxcPixCompilationInfo( - _COM_Outptr_ IDxcPixCompilationInfo **ppCompilationInfo) override; + STDMETHODIMP + NewDxcPixCompilationInfo(IDxcPixCompilationInfo **ppCompilationInfo) override; private: DXC_MICROCOM_TM_REF_FIELDS() diff --git a/lib/DxilDia/DxilDiaTable.h b/lib/DxilDia/DxilDiaTable.h index deb5dc3dad..a035d32615 100644 --- a/lib/DxilDia/DxilDiaTable.h +++ b/lib/DxilDia/DxilDiaTable.h @@ -95,10 +95,8 @@ class TableBase : public IDiaTable, public T { } // IEnumUnknown implementation. - STDMETHODIMP Next( - _In_ ULONG celt, - _Out_writes_to_(celt, *pceltFetched) IUnknown **rgelt, - _Out_opt_ ULONG *pceltFetched) override { + STDMETHODIMP Next(ULONG celt, IUnknown **rgelt, + ULONG *pceltFetched) override { DxcThreadMalloc TM(m_pMalloc); ULONG fetched = 0; while (fetched < celt && m_next < m_count) { @@ -140,19 +138,19 @@ class TableBase : public IDiaTable, public T { return (*pRetVal) ? S_OK : E_OUTOFMEMORY; } - STDMETHODIMP get_Count(_Out_ LONG *pRetVal) override { + STDMETHODIMP get_Count(LONG *pRetVal) override { *pRetVal = m_count; return S_OK; } - STDMETHODIMP Item(DWORD index, _COM_Outptr_ IUnknown **table) override { + STDMETHODIMP Item(DWORD index, IUnknown **table) override { if (index >= m_count) return E_INVALIDARG; return GetItem(index, (TItem **)table); } // T implementation (partial). - STDMETHODIMP Clone(_COM_Outptr_ T **ppenum) override { + STDMETHODIMP Clone(T **ppenum) override { *ppenum = nullptr; return ENotImpl(); } diff --git a/lib/DxilDia/DxilDiaTableInjectedSources.cpp b/lib/DxilDia/DxilDiaTableInjectedSources.cpp index bfcd3d435f..31880a77a5 100644 --- a/lib/DxilDia/DxilDiaTableInjectedSources.cpp +++ b/lib/DxilDia/DxilDiaTableInjectedSources.cpp @@ -27,7 +27,7 @@ llvm::StringRef dxil_dia::InjectedSource::Content() { return llvm::dyn_cast(NameContent()->getOperand(1))->getString(); } -STDMETHODIMP dxil_dia::InjectedSource::get_length(_Out_ ULONGLONG *pRetVal) { +STDMETHODIMP dxil_dia::InjectedSource::get_length(ULONGLONG *pRetVal) { *pRetVal = Content().size(); return S_OK; } @@ -99,4 +99,4 @@ void dxil_dia::InjectedSourcesTable::Init(llvm::StringRef filename) { } } m_count = m_indexList.size(); -} \ No newline at end of file +} diff --git a/lib/DxilDia/DxilDiaTableInjectedSources.h b/lib/DxilDia/DxilDiaTableInjectedSources.h index 091d53e082..cd79b5f968 100644 --- a/lib/DxilDia/DxilDiaTableInjectedSources.h +++ b/lib/DxilDia/DxilDiaTableInjectedSources.h @@ -49,7 +49,7 @@ class InjectedSource : public IDiaInjectedSource { STDMETHODIMP get_crc( /* [retval][out] */ DWORD *pRetVal) override { return ENotImpl(); } - STDMETHODIMP get_length(_Out_ ULONGLONG *pRetVal) override; + STDMETHODIMP get_length(ULONGLONG *pRetVal) override; STDMETHODIMP get_filename(BSTR *pRetVal) override; diff --git a/lib/DxilRootSignature/DxilRootSignatureSerializer.cpp b/lib/DxilRootSignature/DxilRootSignatureSerializer.cpp index 70916d065a..7314db4d8d 100644 --- a/lib/DxilRootSignature/DxilRootSignatureSerializer.cpp +++ b/lib/DxilRootSignature/DxilRootSignatureSerializer.cpp @@ -54,7 +54,7 @@ class SimpleSerializer { HRESULT AddBlock(void *pData, unsigned cbSize, unsigned *pOffset); HRESULT ReserveBlock(void **ppData, unsigned cbSize, unsigned *pOffset); - HRESULT Compact(_Out_writes_bytes_(cbSize) char *pData, unsigned cbSize); + HRESULT Compact(char *pData, unsigned cbSize); unsigned GetSize(); protected: @@ -142,8 +142,7 @@ HRESULT SimpleSerializer::ReserveBlock(void **ppData, unsigned cbSize, return hr; } -HRESULT SimpleSerializer::Compact(_Out_writes_bytes_(cbSize) char *pData, - unsigned cbSize) { +HRESULT SimpleSerializer::Compact(char *pData, unsigned cbSize) { unsigned cb = GetSize(); IFRBOOL(cb <= cbSize, E_FAIL); DXASSERT_NOMSG(cb <= UINT32_MAX / 2); @@ -154,13 +153,13 @@ HRESULT SimpleSerializer::Compact(_Out_writes_bytes_(cbSize) char *pData, for (Segment *pSegment = m_pSegment; pSegment; pSegment = pSegment->pNext) { unsigned cbAlign = ((cb + 3) & ~3) - cb; - _Analysis_assume_(p + cbAlign <= pData + cbSize); + assert(p + cbAlign <= pData + cbSize); memset(p, 0xab, cbAlign); p += cbAlign; cb += cbAlign; - _Analysis_assume_(p + pSegment->cbSize <= pData + cbSize); + assert(p + pSegment->cbSize <= pData + cbSize); memcpy(p, pSegment->pData, pSegment->cbSize); p += pSegment->cbSize; @@ -168,7 +167,7 @@ HRESULT SimpleSerializer::Compact(_Out_writes_bytes_(cbSize) char *pData, } // Trailing zeros - _Analysis_assume_(p + cbSize - cb <= pData + cbSize); + assert(p + cbSize - cb <= pData + cbSize); memset(p, 0xab, cbSize - cb); return S_OK; @@ -179,15 +178,14 @@ unsigned SimpleSerializer::GetSize() { return ((m_cbSegments + 3) >> 2) * 4; } -template -void SerializeRootSignatureTemplate(_In_ const T_ROOT_SIGNATURE_DESC* pRootSignature, +template +void SerializeRootSignatureTemplate(const T_ROOT_SIGNATURE_DESC *pRootSignature, DxilRootSignatureVersion DescVersion, - _COM_Outptr_ IDxcBlob** ppBlob, + IDxcBlob **ppBlob, DiagnosticPrinter &DiagPrinter, - _In_ bool bAllowReservedRegisterSpace) { + bool bAllowReservedRegisterSpace) { DxilContainerRootSignatureDesc RS; uint32_t Offset; SimpleSerializer Serializer; @@ -275,7 +273,6 @@ void SerializeRootSignatureTemplate(_In_ const T_ROOT_SIGNATURE_DESC* pRootSigna bytes.Detach(); // Ownership transfered to ppBlob. } -_Use_decl_annotations_ void SerializeRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature, IDxcBlob **ppBlob, IDxcBlobEncoding **ppErrorBlob, bool bAllowReservedRegisterSpace) { @@ -332,16 +329,13 @@ void SerializeRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature } } -template -void DeserializeRootSignatureTemplate(_In_reads_bytes_(SrcDataSizeInBytes) const void *pSrcData, - _In_ uint32_t SrcDataSizeInBytes, - DxilRootSignatureVersion DescVersion, - T_ROOT_SIGNATURE_DESC &RootSignatureDesc) { +template +void DeserializeRootSignatureTemplate( + const void *pSrcData, uint32_t SrcDataSizeInBytes, + DxilRootSignatureVersion DescVersion, + T_ROOT_SIGNATURE_DESC &RootSignatureDesc) { // Note that in case of failure, outside code must deallocate memory. T_ROOT_SIGNATURE_DESC *pRootSignature = &RootSignatureDesc; const char *pData = (const char *)pSrcData; @@ -428,7 +422,6 @@ void DeserializeRootSignatureTemplate(_In_reads_bytes_(SrcDataSizeInBytes) const } } -_Use_decl_annotations_ void DeserializeRootSignature(const void *pSrcData, uint32_t SrcDataSizeInBytes, const DxilVersionedRootSignatureDesc **ppRootSignature) { diff --git a/lib/DxilRootSignature/DxilRootSignatureValidator.cpp b/lib/DxilRootSignature/DxilRootSignatureValidator.cpp index ed637b94cc..75f67c935c 100644 --- a/lib/DxilRootSignature/DxilRootSignatureValidator.cpp +++ b/lib/DxilRootSignature/DxilRootSignatureValidator.cpp @@ -835,7 +835,6 @@ static DxilShaderVisibility GetVisibilityType(DXIL::ShaderKind ShaderKind) { } } -_Use_decl_annotations_ bool VerifyRootSignatureWithShaderPSV(const DxilVersionedRootSignatureDesc *pDesc, DXIL::ShaderKind ShaderKind, const void *pPSVData, @@ -853,9 +852,9 @@ bool VerifyRootSignatureWithShaderPSV(const DxilVersionedRootSignatureDesc *pDes return true; } -bool VerifyRootSignature(_In_ const DxilVersionedRootSignatureDesc *pDesc, - _In_ llvm::raw_ostream &DiagStream, - _In_ bool bAllowReservedRegisterSpace) { +bool VerifyRootSignature(const DxilVersionedRootSignatureDesc *pDesc, + llvm::raw_ostream &DiagStream, + bool bAllowReservedRegisterSpace) { try { RootSignatureVerifier RSV; RSV.AllowReservedRegisterSpace(bAllowReservedRegisterSpace); diff --git a/lib/DxrFallback/StateFunctionTransform.cpp b/lib/DxrFallback/StateFunctionTransform.cpp index 9eb13413f5..37123d6bc6 100644 --- a/lib/DxrFallback/StateFunctionTransform.cpp +++ b/lib/DxrFallback/StateFunctionTransform.cpp @@ -671,8 +671,8 @@ void StateFunctionTransform::setDumpFilename(const std::string& dumpFilename) m_dumpFilename = dumpFilename; } -void StateFunctionTransform::run(std::vector& stateFunctions, _Out_ unsigned int &shaderStackSize) -{ +void StateFunctionTransform::run(std::vector &stateFunctions, + unsigned int &shaderStackSize) { printFunction("Initial"); init(); @@ -861,9 +861,8 @@ static void extendAllocaLifetimes(LiveValues& lv) } } - -void StateFunctionTransform::preserveLiveValuesAcrossCallsites(_Out_ unsigned int &shaderStackSize) -{ +void StateFunctionTransform::preserveLiveValuesAcrossCallsites( + unsigned int &shaderStackSize) { if (m_callSites.empty()) { // No stack frame. Nothing to do. diff --git a/lib/DxrFallback/StateFunctionTransform.h b/lib/DxrFallback/StateFunctionTransform.h index 69be5391b4..4e5fb7afe6 100644 --- a/lib/DxrFallback/StateFunctionTransform.h +++ b/lib/DxrFallback/StateFunctionTransform.h @@ -189,7 +189,8 @@ class StateFunctionTransform // Generates state functions from func into the same module. The original function // is left only as a declaration. - void run(std::vector& stateFunctions, _Out_ unsigned int &shaderStackSize); + void run(std::vector &stateFunctions, + unsigned int &shaderStackSize); // candidateFuncEntryStateIds corresponding to the candidateFuncNames passed to // the constructor. stateIDs are computed as candidateFuncEntryStateIds[functionIdx] @@ -262,7 +263,7 @@ class StateFunctionTransform void init(); void findCallSitesIntrinsicsAndReturns(); void changeCallingConvention(); - void preserveLiveValuesAcrossCallsites(_Out_ unsigned int &shaderStackSize); + void preserveLiveValuesAcrossCallsites(unsigned int &shaderStackSize); void createSubstateFunctions(std::vector& stateFunctions); void lowerStackFuncs(); diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 06d4a05635..7126394def 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -433,7 +433,7 @@ static GenericValue lle_X_sscanf(FunctionType *FT, char *Args[10]; _Analysis_assume_nullterminated_(Args); for (unsigned i = 0; i < args.size(); ++i) { - _Analysis_assume_(i < 10); + assert(i < 10); Args[i] = (char*)GVTOP(args[i]); } @@ -449,7 +449,7 @@ static GenericValue lle_X_scanf(FunctionType *FT, ArrayRef args) { char *Args[10] = { 0 }; for (unsigned i = 0; i < args.size(); ++i) { - _Analysis_assume_(i < 10); + assert(i < 10); Args[i] = (char*)GVTOP(args[i]); } diff --git a/lib/HLSL/DxcOptimizer.cpp b/lib/HLSL/DxcOptimizer.cpp index dbc258a5df..ee53e5412a 100644 --- a/lib/HLSL/DxcOptimizer.cpp +++ b/lib/HLSL/DxcOptimizer.cpp @@ -114,14 +114,14 @@ class DxcOptimizerPass : public IDxcOptimizerPass { return S_OK; } - HRESULT STDMETHODCALLTYPE GetOptionName(_COM_Outptr_ LPWSTR *ppResult) override { + HRESULT STDMETHODCALLTYPE GetOptionName(LPWSTR *ppResult) override { return Utf8ToWideCoTaskMalloc(m_pOptionName, ppResult); } - HRESULT STDMETHODCALLTYPE GetDescription(_COM_Outptr_ LPWSTR *ppResult) override { + HRESULT STDMETHODCALLTYPE GetDescription(LPWSTR *ppResult) override { return Utf8ToWideCoTaskMalloc(m_pDescription, ppResult); } - HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) override { + HRESULT STDMETHODCALLTYPE GetOptionArgCount(UINT32 *pCount) override { if (!pCount) return E_INVALIDARG; *pCount = m_pArgDescriptions.size(); return S_OK; @@ -155,14 +155,14 @@ class DxcOptimizer : public IDxcOptimizer { HRESULT Initialize(); const PassInfo *getPassByID(llvm::AnalysisID PassID); const PassInfo *getPassByName(const char *pName); - HRESULT STDMETHODCALLTYPE GetAvailablePassCount(_Out_ UINT32 *pCount) override { + HRESULT STDMETHODCALLTYPE GetAvailablePassCount(UINT32 *pCount) override { return AssignToOut(m_passes.size(), pCount); } - HRESULT STDMETHODCALLTYPE GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass** ppResult) override; - HRESULT STDMETHODCALLTYPE RunOptimizer(IDxcBlob *pBlob, - _In_count_(optionCount) LPCWSTR *ppOptions, UINT32 optionCount, - _COM_Outptr_ IDxcBlob **ppOutputModule, - _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) override; + HRESULT STDMETHODCALLTYPE + GetAvailablePass(UINT32 index, IDxcOptimizerPass **ppResult) override; + HRESULT STDMETHODCALLTYPE RunOptimizer( + IDxcBlob *pBlob, LPCWSTR *ppOptions, UINT32 optionCount, + IDxcBlob **ppOutputModule, IDxcBlobEncoding **ppOutputText) override; }; class CapturePassManager : public llvm::legacy::PassManagerBase { @@ -213,8 +213,8 @@ const PassInfo *DxcOptimizer::getPassByName(const char *pName) { return m_registry->getPassInfo(StringRef(pName)); } -HRESULT STDMETHODCALLTYPE DxcOptimizer::GetAvailablePass( - UINT32 index, _COM_Outptr_ IDxcOptimizerPass **ppResult) { +HRESULT STDMETHODCALLTYPE +DxcOptimizer::GetAvailablePass(UINT32 index, IDxcOptimizerPass **ppResult) { IFR(AssignToOut(nullptr, ppResult)); if (index >= m_passes.size()) return E_INVALIDARG; @@ -226,9 +226,8 @@ HRESULT STDMETHODCALLTYPE DxcOptimizer::GetAvailablePass( } HRESULT STDMETHODCALLTYPE DxcOptimizer::RunOptimizer( - IDxcBlob *pBlob, _In_count_(optionCount) LPCWSTR *ppOptions, - UINT32 optionCount, _COM_Outptr_ IDxcBlob **ppOutputModule, - _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) { + IDxcBlob *pBlob, LPCWSTR *ppOptions, UINT32 optionCount, + IDxcBlob **ppOutputModule, IDxcBlobEncoding **ppOutputText) { AssignToOutOpt(nullptr, ppOutputModule); AssignToOutOpt(nullptr, ppOutputText); if (pBlob == nullptr) @@ -556,7 +555,7 @@ HRESULT STDMETHODCALLTYPE DxcOptimizer::RunOptimizer( return S_OK; } -HRESULT CreateDxcOptimizer(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxcOptimizer(REFIID riid, LPVOID *ppv) { CComPtr result = DxcOptimizer::Alloc(DxcGetThreadMallocNoRef()); if (result == nullptr) { *ppv = nullptr; diff --git a/lib/HLSL/DxilContainerReflection.cpp b/lib/HLSL/DxilContainerReflection.cpp index f7014bd96d..06d34b570b 100644 --- a/lib/HLSL/DxilContainerReflection.cpp +++ b/lib/HLSL/DxilContainerReflection.cpp @@ -80,12 +80,15 @@ class DxilContainerReflection : public IDxcContainerReflection { return DoBasicQueryInterface(this, iid, ppvObject); } - HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) override; - HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) override; - HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) override; - HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) override; - HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) override; - HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, _COM_Outptr_ void **ppvObject) override; + HRESULT STDMETHODCALLTYPE Load(IDxcBlob *pContainer) override; + HRESULT STDMETHODCALLTYPE GetPartCount(UINT32 *pResult) override; + HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, UINT32 *pResult) override; + HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, + IDxcBlob **ppResult) override; + HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, + UINT32 *pResult) override; + HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, + void **ppvObject) override; }; class CShaderReflectionConstantBuffer; @@ -140,7 +143,7 @@ class DxilModuleReflection { ID3D12ShaderReflectionConstantBuffer* _GetConstantBufferByName(LPCSTR Name); HRESULT _GetResourceBindingDesc(UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc, + D3D12_SHADER_INPUT_BIND_DESC *pDesc, PublicAPI api = PublicAPI::D3D12); ID3D12ShaderReflectionVariable* _GetVariableByName(LPCSTR Name); @@ -197,43 +200,49 @@ class DxilShaderReflection : public DxilModuleReflection, public ID3D12ShaderRef HRESULT Load(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart); // ID3D12ShaderReflection - STDMETHODIMP GetDesc(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) override; + STDMETHODIMP GetDesc(D3D12_SHADER_DESC *pDesc) override; - STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByIndex(THIS_ _In_ UINT Index) override; - STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByName(THIS_ _In_ LPCSTR Name) override; + STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer *) + GetConstantBufferByIndex(UINT Index) override; + STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer *) + GetConstantBufferByName(LPCSTR Name) override; - STDMETHODIMP GetResourceBindingDesc(THIS_ _In_ UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) override; + STDMETHODIMP + GetResourceBindingDesc(UINT ResourceIndex, + D3D12_SHADER_INPUT_BIND_DESC *pDesc) override; - STDMETHODIMP GetInputParameterDesc(THIS_ _In_ UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override; - STDMETHODIMP GetOutputParameterDesc(THIS_ _In_ UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override; - STDMETHODIMP GetPatchConstantParameterDesc(THIS_ _In_ UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override; + STDMETHODIMP + GetInputParameterDesc(UINT ParameterIndex, + D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override; + STDMETHODIMP + GetOutputParameterDesc(UINT ParameterIndex, + D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override; + STDMETHODIMP + GetPatchConstantParameterDesc(UINT ParameterIndex, + D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override; - STDMETHODIMP_(ID3D12ShaderReflectionVariable*) GetVariableByName(THIS_ _In_ LPCSTR Name) override; + STDMETHODIMP_(ID3D12ShaderReflectionVariable *) + GetVariableByName(LPCSTR Name) override; - STDMETHODIMP GetResourceBindingDescByName(THIS_ _In_ LPCSTR Name, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) override; + STDMETHODIMP + GetResourceBindingDescByName(LPCSTR Name, + D3D12_SHADER_INPUT_BIND_DESC *pDesc) override; - STDMETHODIMP_(UINT) GetMovInstructionCount(THIS) override; - STDMETHODIMP_(UINT) GetMovcInstructionCount(THIS) override; - STDMETHODIMP_(UINT) GetConversionInstructionCount(THIS) override; - STDMETHODIMP_(UINT) GetBitwiseInstructionCount(THIS) override; + STDMETHODIMP_(UINT) GetMovInstructionCount() override; + STDMETHODIMP_(UINT) GetMovcInstructionCount() override; + STDMETHODIMP_(UINT) GetConversionInstructionCount() override; + STDMETHODIMP_(UINT) GetBitwiseInstructionCount() override; - STDMETHODIMP_(D3D_PRIMITIVE) GetGSInputPrimitive(THIS) override; - STDMETHODIMP_(BOOL) IsSampleFrequencyShader(THIS) override; + STDMETHODIMP_(D3D_PRIMITIVE) GetGSInputPrimitive() override; + STDMETHODIMP_(BOOL) IsSampleFrequencyShader() override; - STDMETHODIMP_(UINT) GetNumInterfaceSlots(THIS) override; - STDMETHODIMP GetMinFeatureLevel(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) override; + STDMETHODIMP_(UINT) GetNumInterfaceSlots() override; + STDMETHODIMP GetMinFeatureLevel(enum D3D_FEATURE_LEVEL *pLevel) override; - STDMETHODIMP_(UINT) GetThreadGroupSize(THIS_ - _Out_opt_ UINT* pSizeX, - _Out_opt_ UINT* pSizeY, - _Out_opt_ UINT* pSizeZ) override; + STDMETHODIMP_(UINT) + GetThreadGroupSize(UINT *pSizeX, UINT *pSizeY, UINT *pSizeZ) override; - STDMETHODIMP_(UINT64) GetRequiresFlags(THIS) override; + STDMETHODIMP_(UINT64) GetRequiresFlags() override; }; class CFunctionReflection; @@ -262,9 +271,10 @@ class DxilLibraryReflection : public DxilModuleReflection, public ID3D12LibraryR HRESULT Load(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart); // ID3D12LibraryReflection - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) override; + STDMETHOD(GetDesc)(D3D12_LIBRARY_DESC *pDesc) override; - STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) override; + STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex) + (INT FunctionIndex) override; }; namespace hlsl { @@ -333,7 +343,6 @@ HRESULT CreateDxilShaderOrLibraryReflectionFromModulePart(const DxilPartHeader * } -_Use_decl_annotations_ HRESULT DxilContainerReflection::Load(IDxcBlob *pContainer) { if (pContainer == nullptr) { @@ -371,7 +380,6 @@ HRESULT DxilContainerReflection::Load(IDxcBlob *pContainer) { return S_OK; } -_Use_decl_annotations_ HRESULT DxilContainerReflection::GetPartCount(UINT32 *pResult) { if (pResult == nullptr) return E_POINTER; if (!IsLoaded()) return E_NOT_VALID_STATE; @@ -379,8 +387,7 @@ HRESULT DxilContainerReflection::GetPartCount(UINT32 *pResult) { return S_OK; } -_Use_decl_annotations_ -HRESULT DxilContainerReflection::GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) { +HRESULT DxilContainerReflection::GetPartKind(UINT32 idx, UINT32 *pResult) { if (pResult == nullptr) return E_POINTER; if (!IsLoaded()) return E_NOT_VALID_STATE; if (idx >= m_pHeader->PartCount) return E_BOUNDS; @@ -389,8 +396,8 @@ HRESULT DxilContainerReflection::GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) return S_OK; } -_Use_decl_annotations_ -HRESULT DxilContainerReflection::GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) { +HRESULT DxilContainerReflection::GetPartContent(UINT32 idx, + IDxcBlob **ppResult) { if (ppResult == nullptr) return E_POINTER; *ppResult = nullptr; if (!IsLoaded()) return E_NOT_VALID_STATE; @@ -403,8 +410,8 @@ HRESULT DxilContainerReflection::GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlo return DxcCreateBlobFromBlob(m_container, offset, length, ppResult); } -_Use_decl_annotations_ -HRESULT DxilContainerReflection::FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) { +HRESULT DxilContainerReflection::FindFirstPartKind(UINT32 kind, + UINT32 *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = 0; if (!IsLoaded()) return E_NOT_VALID_STATE; @@ -414,7 +421,6 @@ HRESULT DxilContainerReflection::FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pR return S_OK; } -_Use_decl_annotations_ HRESULT DxilContainerReflection::GetPartReflection(UINT32 idx, REFIID iid, void **ppvObject) { if (ppvObject == nullptr) return E_POINTER; *ppvObject = nullptr; @@ -499,15 +505,15 @@ class CShaderReflectionType final : public ID3D12ShaderReflectionType STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(LPCSTR Name); STDMETHOD_(LPCSTR, GetMemberTypeName)(UINT Index); - STDMETHOD(IsEqual)(THIS_ ID3D12ShaderReflectionType* pType); - STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS); - STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS); - STDMETHOD_(UINT, GetNumInterfaces)(THIS); - STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ UINT uIndex); - STDMETHOD(IsOfType)(THIS_ ID3D12ShaderReflectionType* pType); - STDMETHOD(ImplementsInterface)(THIS_ ID3D12ShaderReflectionType* pBase); + STDMETHOD(IsEqual)(ID3D12ShaderReflectionType *pType); + STDMETHOD_(ID3D12ShaderReflectionType *, GetSubType)(); + STDMETHOD_(ID3D12ShaderReflectionType *, GetBaseClass)(); + STDMETHOD_(UINT, GetNumInterfaces)(); + STDMETHOD_(ID3D12ShaderReflectionType *, GetInterfaceByIndex)(UINT uIndex); + STDMETHOD(IsOfType)(ID3D12ShaderReflectionType *pType); + STDMETHOD(ImplementsInterface)(ID3D12ShaderReflectionType *pBase); - bool CheckEqual(_In_ CShaderReflectionType *pOther) { + bool CheckEqual(CShaderReflectionType *pOther) { return m_Identity == pOther->m_Identity; } @@ -535,7 +541,7 @@ class CShaderReflectionVariable final : public ID3D12ShaderReflectionVariable STDMETHOD_(ID3D12ShaderReflectionType*, GetType)(); STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(); - STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT uArrayIndex); + STDMETHOD_(UINT, GetInterfaceSlot)(UINT uArrayIndex); }; class CShaderReflectionConstantBuffer final : public ID3D12ShaderReflectionConstantBuffer @@ -587,13 +593,15 @@ class CInvalidSRType final : public ID3D12ShaderReflectionType { STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(LPCSTR Name); STDMETHOD_(LPCSTR, GetMemberTypeName)(UINT Index) { return "$Invalid"; } - STDMETHOD(IsEqual)(THIS_ ID3D12ShaderReflectionType* pType) { return E_FAIL; } - STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS); - STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS); - STDMETHOD_(UINT, GetNumInterfaces)(THIS) { return 0; } - STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ UINT uIndex); - STDMETHOD(IsOfType)(THIS_ ID3D12ShaderReflectionType* pType) { return E_FAIL; } - STDMETHOD(ImplementsInterface)(THIS_ ID3D12ShaderReflectionType* pBase) { return E_FAIL; } + STDMETHOD(IsEqual)(ID3D12ShaderReflectionType *pType) { return E_FAIL; } + STDMETHOD_(ID3D12ShaderReflectionType *, GetSubType)(); + STDMETHOD_(ID3D12ShaderReflectionType *, GetBaseClass)(); + STDMETHOD_(UINT, GetNumInterfaces)() { return 0; } + STDMETHOD_(ID3D12ShaderReflectionType *, GetInterfaceByIndex)(UINT uIndex); + STDMETHOD(IsOfType)(ID3D12ShaderReflectionType *pType) { return E_FAIL; } + STDMETHOD(ImplementsInterface)(ID3D12ShaderReflectionType *pBase) { + return E_FAIL; + } }; static CInvalidSRType g_InvalidSRType; @@ -609,7 +617,7 @@ class CInvalidSRVariable final : public ID3D12ShaderReflectionVariable { STDMETHOD_(ID3D12ShaderReflectionType*, GetType)() { return &g_InvalidSRType; } STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(); - STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT uIndex) { return UINT_MAX; } + STDMETHOD_(UINT, GetInterfaceSlot)(UINT uIndex) { return UINT_MAX; } }; static CInvalidSRVariable g_InvalidSRVariable; @@ -622,26 +630,41 @@ class CInvalidSRConstantBuffer final : public ID3D12ShaderReflectionConstantBuff static CInvalidSRConstantBuffer g_InvalidSRConstantBuffer; class CInvalidFunctionParameter final : public ID3D12FunctionParameterReflection { - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) { return E_FAIL; } + STDMETHOD(GetDesc)(D3D12_PARAMETER_DESC *pDesc) { return E_FAIL; } }; CInvalidFunctionParameter g_InvalidFunctionParameter; class CInvalidFunction final : public ID3D12FunctionReflection { - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) { return E_FAIL; } + STDMETHOD(GetDesc)(D3D12_FUNCTION_DESC *pDesc) { return E_FAIL; } - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) { return &g_InvalidSRConstantBuffer; } - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) { return &g_InvalidSRConstantBuffer; } + STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex) + (UINT BufferIndex) { + return &g_InvalidSRConstantBuffer; + } + STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName) + (LPCSTR Name) { + return &g_InvalidSRConstantBuffer; + } - STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) { return E_FAIL; } + STDMETHOD(GetResourceBindingDesc) + (UINT ResourceIndex, D3D12_SHADER_INPUT_BIND_DESC *pDesc) { + return E_FAIL; + } - STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) { return nullptr; } + STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(LPCSTR Name) { + return nullptr; + } - STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name, - _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) { return E_FAIL; } + STDMETHOD(GetResourceBindingDescByName) + (LPCSTR Name, D3D12_SHADER_INPUT_BIND_DESC *pDesc) { + return E_FAIL; + } // Use D3D_RETURN_PARAMETER_INDEX to get description of the return value. - STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) { return &g_InvalidFunctionParameter; } + STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter) + (INT ParameterIndex) { + return &g_InvalidFunctionParameter; + } }; CInvalidFunction g_InvalidFunction; @@ -710,44 +733,42 @@ STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetMemberTypeB return nullptr; } -STDMETHODIMP CShaderReflectionType::IsEqual(THIS_ ID3D12ShaderReflectionType* pType) -{ +STDMETHODIMP CShaderReflectionType::IsEqual(ID3D12ShaderReflectionType *pType) { // TODO: implement this check, if users actually depend on it return S_FALSE; } -STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetSubType(THIS) -{ +STDMETHODIMP_(ID3D12ShaderReflectionType *) +CShaderReflectionType::GetSubType() { // TODO: implement `class`-related features, if requested return nullptr; } -STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetBaseClass(THIS) -{ +STDMETHODIMP_(ID3D12ShaderReflectionType *) +CShaderReflectionType::GetBaseClass() { // TODO: implement `class`-related features, if requested return nullptr; } -STDMETHODIMP_(UINT) CShaderReflectionType::GetNumInterfaces(THIS) -{ +STDMETHODIMP_(UINT) CShaderReflectionType::GetNumInterfaces() { // HLSL interfaces have been deprecated return 0; } -STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetInterfaceByIndex(THIS_ UINT uIndex) -{ +STDMETHODIMP_(ID3D12ShaderReflectionType *) +CShaderReflectionType::GetInterfaceByIndex(UINT uIndex) { // HLSL interfaces have been deprecated return nullptr; } -STDMETHODIMP CShaderReflectionType::IsOfType(THIS_ ID3D12ShaderReflectionType* pType) -{ +STDMETHODIMP +CShaderReflectionType::IsOfType(ID3D12ShaderReflectionType *pType) { // TODO: implement `class`-related features, if requested return S_FALSE; } -STDMETHODIMP CShaderReflectionType::ImplementsInterface(THIS_ ID3D12ShaderReflectionType* pBase) -{ +STDMETHODIMP +CShaderReflectionType::ImplementsInterface(ID3D12ShaderReflectionType *pBase) { // HLSL interfaces have been deprecated return S_FALSE; } @@ -2166,7 +2187,6 @@ HRESULT DxilShaderReflection::Load(const DxilProgramHeader *pProgramHeader, cons CATCH_CPP_RETURN_HRESULT(); } -_Use_decl_annotations_ HRESULT DxilShaderReflection::GetDesc(D3D12_SHADER_DESC *pDesc) { if (nullptr == pDesc) return E_POINTER; memcpy(pDesc, &m_Desc, sizeof(D3D12_SHADER_DESC)); @@ -2363,7 +2383,6 @@ void DxilShaderReflection::InitDesc() { // Macro instructions are a <= DX9 concept. } -_Use_decl_annotations_ ID3D12ShaderReflectionConstantBuffer* DxilShaderReflection::GetConstantBufferByIndex(UINT Index) { return DxilModuleReflection::_GetConstantBufferByIndex(Index); } @@ -2374,7 +2393,6 @@ ID3D12ShaderReflectionConstantBuffer* DxilModuleReflection::_GetConstantBufferBy return m_CBs[Index].get(); } -_Use_decl_annotations_ ID3D12ShaderReflectionConstantBuffer* DxilShaderReflection::GetConstantBufferByName(LPCSTR Name) { return DxilModuleReflection::_GetConstantBufferByName(Name); } @@ -2400,13 +2418,12 @@ ID3D12ShaderReflectionConstantBuffer* DxilModuleReflection::_GetConstantBufferBy return &g_InvalidSRConstantBuffer; } -_Use_decl_annotations_ -HRESULT DxilShaderReflection::GetResourceBindingDesc(UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) { +HRESULT DxilShaderReflection::GetResourceBindingDesc( + UINT ResourceIndex, D3D12_SHADER_INPUT_BIND_DESC *pDesc) { return DxilModuleReflection::_GetResourceBindingDesc(ResourceIndex, pDesc, m_PublicAPI); } -HRESULT DxilModuleReflection::_GetResourceBindingDesc(UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc, PublicAPI api) { +HRESULT DxilModuleReflection::_GetResourceBindingDesc( + UINT ResourceIndex, D3D12_SHADER_INPUT_BIND_DESC *pDesc, PublicAPI api) { IFRBOOL(pDesc != nullptr, E_INVALIDARG); IFRBOOL(ResourceIndex < m_Resources.size(), E_INVALIDARG); if (api != PublicAPI::D3D12) { @@ -2418,9 +2435,8 @@ HRESULT DxilModuleReflection::_GetResourceBindingDesc(UINT ResourceIndex, return S_OK; } -_Use_decl_annotations_ -HRESULT DxilShaderReflection::GetInputParameterDesc(UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) { +HRESULT DxilShaderReflection::GetInputParameterDesc( + UINT ParameterIndex, D3D12_SIGNATURE_PARAMETER_DESC *pDesc) { IFRBOOL(pDesc != nullptr, E_INVALIDARG); IFRBOOL(ParameterIndex < m_InputSignature.size(), E_INVALIDARG); if (m_PublicAPI != PublicAPI::D3D11_43) @@ -2433,7 +2449,6 @@ HRESULT DxilShaderReflection::GetInputParameterDesc(UINT ParameterIndex, return S_OK; } -_Use_decl_annotations_ HRESULT DxilShaderReflection::GetOutputParameterDesc(UINT ParameterIndex, D3D12_SIGNATURE_PARAMETER_DESC *pDesc) { IFRBOOL(pDesc != nullptr, E_INVALIDARG); @@ -2448,7 +2463,6 @@ HRESULT DxilShaderReflection::GetOutputParameterDesc(UINT ParameterIndex, return S_OK; } -_Use_decl_annotations_ HRESULT DxilShaderReflection::GetPatchConstantParameterDesc(UINT ParameterIndex, D3D12_SIGNATURE_PARAMETER_DESC *pDesc) { IFRBOOL(pDesc != nullptr, E_INVALIDARG); @@ -2463,7 +2477,6 @@ HRESULT DxilShaderReflection::GetPatchConstantParameterDesc(UINT ParameterIndex, return S_OK; } -_Use_decl_annotations_ ID3D12ShaderReflectionVariable* DxilShaderReflection::GetVariableByName(LPCSTR Name) { return DxilModuleReflection::_GetVariableByName(Name); } @@ -2481,7 +2494,6 @@ ID3D12ShaderReflectionVariable* DxilModuleReflection::_GetVariableByName(LPCSTR return &g_InvalidSRVariable; } -_Use_decl_annotations_ HRESULT DxilShaderReflection::GetResourceBindingDescByName(LPCSTR Name, D3D12_SHADER_INPUT_BIND_DESC *pDesc) { return DxilModuleReflection::_GetResourceBindingDescByName(Name, pDesc, m_PublicAPI); @@ -2523,13 +2535,11 @@ BOOL DxilShaderReflection::IsSampleFrequencyShader() { UINT DxilShaderReflection::GetNumInterfaceSlots() { return 0; } -_Use_decl_annotations_ HRESULT DxilShaderReflection::GetMinFeatureLevel(enum D3D_FEATURE_LEVEL* pLevel) { IFR(AssignToOut(D3D_FEATURE_LEVEL_12_0, pLevel)); return S_OK; } -_Use_decl_annotations_ UINT DxilShaderReflection::GetThreadGroupSize(UINT *pSizeX, UINT *pSizeY, UINT *pSizeZ) { if (!m_pDxilModule->GetShaderModel()->IsCS() && !m_pDxilModule->GetShaderModel()->IsMS() && @@ -2600,27 +2610,29 @@ class CFunctionReflection final : public ID3D12FunctionReflection { } // ID3D12FunctionReflection - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc); + STDMETHOD(GetDesc)(D3D12_FUNCTION_DESC *pDesc); // BufferIndex relative to used constant buffers here - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex); - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name); + STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex) + (UINT BufferIndex); + STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName) + (LPCSTR Name); - STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc); + STDMETHOD(GetResourceBindingDesc) + (UINT ResourceIndex, D3D12_SHADER_INPUT_BIND_DESC *pDesc); - STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name); + STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(LPCSTR Name); - STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name, - _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc); + STDMETHOD(GetResourceBindingDescByName) + (LPCSTR Name, D3D12_SHADER_INPUT_BIND_DESC *pDesc); // Use D3D_RETURN_PARAMETER_INDEX to get description of the return value. - STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) { + STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter) + (INT ParameterIndex) { return &g_InvalidFunctionParameter; } }; -_Use_decl_annotations_ HRESULT CFunctionReflection::GetDesc(D3D12_FUNCTION_DESC *pDesc) { DXASSERT_NOMSG(m_pLibraryReflection); IFR(ZeroMemoryToOut(pDesc)); @@ -2837,7 +2849,6 @@ HRESULT DxilLibraryReflection::Load(const DxilProgramHeader *pProgramHeader, con CATCH_CPP_RETURN_HRESULT(); } -_Use_decl_annotations_ HRESULT DxilLibraryReflection::GetDesc(D3D12_LIBRARY_DESC * pDesc) { IFR(ZeroMemoryToOut(pDesc)); //Unset: LPCSTR Creator; // The name of the originator of the library. @@ -2847,7 +2858,6 @@ HRESULT DxilLibraryReflection::GetDesc(D3D12_LIBRARY_DESC * pDesc) { return S_OK; } -_Use_decl_annotations_ ID3D12FunctionReflection *DxilLibraryReflection::GetFunctionByIndex(INT FunctionIndex) { if ((UINT)FunctionIndex >= m_FunctionVector.size()) return &g_InvalidFunction; diff --git a/lib/HLSL/DxilPatchShaderRecordBindings.cpp b/lib/HLSL/DxilPatchShaderRecordBindings.cpp index 95053fe886..c43eb099c7 100644 --- a/lib/HLSL/DxilPatchShaderRecordBindings.cpp +++ b/lib/HLSL/DxilPatchShaderRecordBindings.cpp @@ -125,23 +125,16 @@ class DxilPatchShaderRecordBindings : public ModulePass { unsigned int dataOffsetInShaderRecord); void PatchCreateHandleToUseDescriptorIndex( - _In_ Module &M, - _In_ IRBuilder<> &Builder, - _In_ DXIL::ResourceKind &resourceKind, - _In_ DXIL::ResourceClass &resourceClass, - _In_ llvm::Type *resourceType, - _In_ llvm::Value *descriptorIndex, - _Inout_ DxilInst_CreateHandleForLib &createHandleInstr); + Module &M, IRBuilder<> &Builder, DXIL::ResourceKind &resourceKind, + DXIL::ResourceClass &resourceClass, llvm::Type *resourceType, + llvm::Value *descriptorIndex, + DxilInst_CreateHandleForLib &createHandleInstr); - - bool GetHandleInfo( - Module &M, - DxilInst_CreateHandleForLib &createHandleStructForLib, - _Out_ unsigned int &shaderRegister, - _Out_ unsigned int ®isterSpace, - _Out_ DXIL::ResourceKind &kind, - _Out_ DXIL::ResourceClass &resClass, - _Out_ llvm::Type *&resType); + bool GetHandleInfo(Module &M, + DxilInst_CreateHandleForLib &createHandleStructForLib, + unsigned int &shaderRegister, unsigned int ®isterSpace, + DXIL::ResourceKind &kind, DXIL::ResourceClass &resClass, + llvm::Type *&resType); llvm::Value * GetAliasedDescriptorHeapHandle(Module &M, llvm::Type *, DXIL::ResourceClass resClass, DXIL::ResourceKind resKind); @@ -704,14 +697,10 @@ unsigned int GetResolvedRangeID(DXIL::ResourceClass resClass, Value *rangeIdVal) // TODO: This code is quite inefficient bool DxilPatchShaderRecordBindings::GetHandleInfo( - Module &M, - DxilInst_CreateHandleForLib &createHandleStructForLib, - _Out_ unsigned int &shaderRegister, - _Out_ unsigned int ®isterSpace, - _Out_ DXIL::ResourceKind &kind, - _Out_ DXIL::ResourceClass &resClass, - _Out_ llvm::Type *&resType) -{ + Module &M, DxilInst_CreateHandleForLib &createHandleStructForLib, + unsigned int &shaderRegister, unsigned int ®isterSpace, + DXIL::ResourceKind &kind, DXIL::ResourceClass &resClass, + llvm::Type *&resType) { DxilModule &DM = M.GetOrCreateDxilModule(); LoadInst *loadRangeId = cast(createHandleStructForLib.get_Resource()); Value *ResourceSymbol = loadRangeId->getPointerOperand(); @@ -800,27 +789,25 @@ llvm::Value *DxilPatchShaderRecordBindings::LoadShaderRecordData( } void DxilPatchShaderRecordBindings::PatchCreateHandleToUseDescriptorIndex( - _In_ Module &M, - _In_ IRBuilder<> &Builder, - _In_ DXIL::ResourceKind &resourceKind, - _In_ DXIL::ResourceClass &resourceClass, - _In_ llvm::Type *resourceType, - _In_ llvm::Value *descriptorIndex, - _Inout_ DxilInst_CreateHandleForLib &createHandleInstr) -{ - DxilModule &DM = M.GetOrCreateDxilModule(); - OP *HlslOP = DM.GetOP(); - - llvm::Value *descriptorHeapSymbol = GetAliasedDescriptorHeapHandle(M, resourceType, resourceClass, resourceKind); - llvm::Value *viewSymbol = Builder.CreateGEP(descriptorHeapSymbol, { HlslOP->GetU32Const(0), descriptorIndex }, "IndexIntoDH"); - DxilMDHelper::MarkNonUniform(cast(viewSymbol)); - llvm::Value *handle = Builder.CreateLoad(viewSymbol); - - auto callInst = cast(createHandleInstr.Instr); - callInst->setCalledFunction(HlslOP->GetOpFunc( - DXIL::OpCode::CreateHandleForLib, - handle->getType())); - createHandleInstr.set_Resource(handle); + Module &M, IRBuilder<> &Builder, DXIL::ResourceKind &resourceKind, + DXIL::ResourceClass &resourceClass, llvm::Type *resourceType, + llvm::Value *descriptorIndex, + DxilInst_CreateHandleForLib &createHandleInstr) { + DxilModule &DM = M.GetOrCreateDxilModule(); + OP *HlslOP = DM.GetOP(); + + llvm::Value *descriptorHeapSymbol = GetAliasedDescriptorHeapHandle( + M, resourceType, resourceClass, resourceKind); + llvm::Value *viewSymbol = Builder.CreateGEP( + descriptorHeapSymbol, {HlslOP->GetU32Const(0), descriptorIndex}, + "IndexIntoDH"); + DxilMDHelper::MarkNonUniform(cast(viewSymbol)); + llvm::Value *handle = Builder.CreateLoad(viewSymbol); + + auto callInst = cast(createHandleInstr.Instr); + callInst->setCalledFunction( + HlslOP->GetOpFunc(DXIL::OpCode::CreateHandleForLib, handle->getType())); + createHandleInstr.set_Resource(handle); } void DxilPatchShaderRecordBindings::InitializeViewTable() { diff --git a/lib/HLSL/DxilValidation.cpp b/lib/HLSL/DxilValidation.cpp index 3863c88c2d..65a6eba4ee 100644 --- a/lib/HLSL/DxilValidation.cpp +++ b/lib/HLSL/DxilValidation.cpp @@ -5388,9 +5388,7 @@ static void ValidateUninitializedOutput(ValidationContext &ValCtx) { } } -_Use_decl_annotations_ HRESULT ValidateDxilModule( - llvm::Module *pModule, - llvm::Module *pDebugModule) { +HRESULT ValidateDxilModule(llvm::Module *pModule, llvm::Module *pDebugModule) { DxilModule *pDxilModule = DxilModule::TryGetDxilModule(pModule); if (!pDxilModule) { return DXC_E_IR_VERIFICATION_FAILED; @@ -5435,11 +5433,9 @@ _Use_decl_annotations_ HRESULT ValidateDxilModule( // DXIL Container Verification Functions -static void VerifyBlobPartMatches(_In_ ValidationContext &ValCtx, - _In_ LPCSTR pName, - DxilPartWriter *pWriter, - _In_reads_bytes_opt_(Size) const void *pData, - _In_ uint32_t Size) { +static void VerifyBlobPartMatches(ValidationContext &ValCtx, LPCSTR pName, + DxilPartWriter *pWriter, const void *pData, + uint32_t Size) { if (!pData && pWriter->size()) { // No blob part, but writer says non-zero size is expected. ValCtx.EmitFormatError(ValidationRule::ContainerPartMissing, {pName}); @@ -5471,10 +5467,9 @@ static void VerifyBlobPartMatches(_In_ ValidationContext &ValCtx, return; } -static void VerifySignatureMatches(_In_ ValidationContext &ValCtx, +static void VerifySignatureMatches(ValidationContext &ValCtx, DXIL::SignatureKind SigKind, - _In_reads_bytes_opt_(SigSize) const void *pSigData, - _In_ uint32_t SigSize) { + const void *pSigData, uint32_t SigSize) { // Generate corresponding signature from module and memcmp const char *pName = nullptr; @@ -5500,7 +5495,6 @@ static void VerifySignatureMatches(_In_ ValidationContext &ValCtx, VerifyBlobPartMatches(ValCtx, pName, pWriter.get(), pSigData, SigSize); } -_Use_decl_annotations_ bool VerifySignatureMatches(llvm::Module *pModule, DXIL::SignatureKind SigKind, const void *pSigData, @@ -5510,9 +5504,8 @@ bool VerifySignatureMatches(llvm::Module *pModule, return !ValCtx.Failed; } -static void VerifyPSVMatches(_In_ ValidationContext &ValCtx, - _In_reads_bytes_(PSVSize) const void *pPSVData, - _In_ uint32_t PSVSize) { +static void VerifyPSVMatches(ValidationContext &ValCtx, const void *pPSVData, + uint32_t PSVSize) { uint32_t PSVVersion = MAX_PSV_VERSION; // This should be set to the newest version unique_ptr pWriter(NewPSVWriter(ValCtx.DxilMod, PSVVersion)); // Try each version in case an earlier version matches module @@ -5524,7 +5517,6 @@ static void VerifyPSVMatches(_In_ ValidationContext &ValCtx, VerifyBlobPartMatches(ValCtx, "Pipeline State Validation", pWriter.get(), pPSVData, PSVSize); } -_Use_decl_annotations_ bool VerifyPSVMatches(llvm::Module *pModule, const void *pPSVData, uint32_t PSVSize) { @@ -5533,9 +5525,9 @@ bool VerifyPSVMatches(llvm::Module *pModule, return !ValCtx.Failed; } -static void VerifyFeatureInfoMatches(_In_ ValidationContext &ValCtx, - _In_reads_bytes_(FeatureInfoSize) const void *pFeatureInfoData, - _In_ uint32_t FeatureInfoSize) { +static void VerifyFeatureInfoMatches(ValidationContext &ValCtx, + const void *pFeatureInfoData, + uint32_t FeatureInfoSize) { // generate Feature Info data from module and memcmp unique_ptr pWriter(NewFeatureInfoWriter(ValCtx.DxilMod)); VerifyBlobPartMatches(ValCtx, "Feature Info", pWriter.get(), pFeatureInfoData, FeatureInfoSize); @@ -5615,9 +5607,8 @@ bool ValidateCompilerVersionPart(const void *pBlobPtr, UINT blobSize) { return true; } -static void VerifyRDATMatches(_In_ ValidationContext &ValCtx, - _In_reads_bytes_(RDATSize) const void *pRDATData, - _In_ uint32_t RDATSize) { +static void VerifyRDATMatches(ValidationContext &ValCtx, const void *pRDATData, + uint32_t RDATSize) { const char *PartName = "Runtime Data (RDAT)"; // If DxilModule subobjects already loaded, validate these against the RDAT blob, // otherwise, load subobject into DxilModule to generate reference RDAT. @@ -5645,7 +5636,6 @@ static void VerifyRDATMatches(_In_ ValidationContext &ValCtx, } } -_Use_decl_annotations_ bool VerifyRDATMatches(llvm::Module *pModule, const void *pRDATData, uint32_t RDATSize) { @@ -5654,7 +5644,6 @@ bool VerifyRDATMatches(llvm::Module *pModule, return !ValCtx.Failed; } -_Use_decl_annotations_ bool VerifyFeatureInfoMatches(llvm::Module *pModule, const void *pFeatureInfoData, uint32_t FeatureInfoSize) { @@ -5663,7 +5652,6 @@ bool VerifyFeatureInfoMatches(llvm::Module *pModule, return !ValCtx.Failed; } -_Use_decl_annotations_ HRESULT ValidateDxilContainerParts(llvm::Module *pModule, llvm::Module *pDebugModule, const DxilContainerHeader *pContainer, @@ -5847,10 +5835,8 @@ HRESULT ValidateDxilContainerParts(llvm::Module *pModule, return S_OK; } -static HRESULT FindDxilPart(_In_reads_bytes_(ContainerSize) const void *pContainerBytes, - _In_ uint32_t ContainerSize, - _In_ DxilFourCC FourCC, - _In_ const DxilPartHeader **ppPart) { +static HRESULT FindDxilPart(const void *pContainerBytes, uint32_t ContainerSize, + DxilFourCC FourCC, const DxilPartHeader **ppPart) { const DxilContainerHeader *pContainer = IsDxilContainerLike(pContainerBytes, ContainerSize); @@ -5878,7 +5864,6 @@ static HRESULT FindDxilPart(_In_reads_bytes_(ContainerSize) const void *pContain return S_OK; } -_Use_decl_annotations_ HRESULT ValidateLoadModule(const char *pIL, uint32_t ILLength, unique_ptr &pModule, @@ -5908,10 +5893,8 @@ HRESULT ValidateLoadModule(const char *pIL, return S_OK; } -HRESULT ValidateDxilBitcode( - _In_reads_bytes_(ILLength) const char *pIL, - _In_ uint32_t ILLength, - _In_ llvm::raw_ostream &DiagStream) { +HRESULT ValidateDxilBitcode(const char *pIL, uint32_t ILLength, + llvm::raw_ostream &DiagStream) { LLVMContext Ctx; std::unique_ptr pModule; @@ -5962,11 +5945,10 @@ HRESULT ValidateDxilBitcode( } static HRESULT ValidateLoadModuleFromContainer( - _In_reads_bytes_(ILLength) const void *pContainer, - _In_ uint32_t ContainerSize, _In_ std::unique_ptr &pModule, - _In_ std::unique_ptr &pDebugModule, - _In_ llvm::LLVMContext &Ctx, LLVMContext &DbgCtx, - _In_ llvm::raw_ostream &DiagStream, _In_ unsigned bLazyLoad) { + const void *pContainer, uint32_t ContainerSize, + std::unique_ptr &pModule, + std::unique_ptr &pDebugModule, llvm::LLVMContext &Ctx, + LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream, unsigned bLazyLoad) { llvm::DiagnosticPrinterRawOStream DiagPrinter(DiagStream); PrintDiagnosticContext DiagContext(DiagPrinter); DiagRestore DR(Ctx, &DiagContext); @@ -6004,29 +5986,26 @@ static HRESULT ValidateLoadModuleFromContainer( return S_OK; } -_Use_decl_annotations_ HRESULT ValidateLoadModuleFromContainer( - _In_reads_bytes_(ContainerSize) const void *pContainer, - _In_ uint32_t ContainerSize, _In_ std::unique_ptr &pModule, - _In_ std::unique_ptr &pDebugModule, - _In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx, - _In_ llvm::raw_ostream &DiagStream) { +HRESULT ValidateLoadModuleFromContainer( + const void *pContainer, uint32_t ContainerSize, + std::unique_ptr &pModule, + std::unique_ptr &pDebugModule, llvm::LLVMContext &Ctx, + llvm::LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream) { return ValidateLoadModuleFromContainer(pContainer, ContainerSize, pModule, pDebugModule, Ctx, DbgCtx, DiagStream, /*bLazyLoad*/ false); } // Lazy loads module from container, validating load, but not module. -_Use_decl_annotations_ HRESULT ValidateLoadModuleFromContainerLazy( - _In_reads_bytes_(ContainerSize) const void *pContainer, - _In_ uint32_t ContainerSize, _In_ std::unique_ptr &pModule, - _In_ std::unique_ptr &pDebugModule, - _In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx, - _In_ llvm::raw_ostream &DiagStream) { +HRESULT ValidateLoadModuleFromContainerLazy( + const void *pContainer, uint32_t ContainerSize, + std::unique_ptr &pModule, + std::unique_ptr &pDebugModule, llvm::LLVMContext &Ctx, + llvm::LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream) { return ValidateLoadModuleFromContainer(pContainer, ContainerSize, pModule, pDebugModule, Ctx, DbgCtx, DiagStream, /*bLazyLoad*/ true); } -_Use_decl_annotations_ HRESULT ValidateDxilContainer(const void *pContainer, uint32_t ContainerSize, const void *pOptDebugBitcode, @@ -6062,7 +6041,6 @@ HRESULT ValidateDxilContainer(const void *pContainer, IsDxilContainerLike(pContainer, ContainerSize), ContainerSize); } -_Use_decl_annotations_ HRESULT ValidateDxilContainer(const void *pContainer, uint32_t ContainerSize, llvm::raw_ostream &DiagStream) { diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index 755da73102..c4a77de4f6 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -4227,7 +4227,7 @@ void TranslateAtomicBinaryOperation(AtomicHelper &helper, if (addr->getType()->isVectorTy()) { unsigned vectorNumElements = addr->getType()->getVectorNumElements(); DXASSERT(vectorNumElements <= 3, "up to 3 elements for atomic binary op"); - _Analysis_assume_(vectorNumElements <= 3); + assert(vectorNumElements <= 3); for (unsigned i = 0; i < vectorNumElements; i++) { Value *Elt = Builder.CreateExtractElement(addr, i); args[DXIL::OperandIndex::kAtomicBinOpCoord0OpIdx + i] = Elt; @@ -4349,7 +4349,7 @@ void TranslateAtomicCmpXChg(AtomicHelper &helper, IRBuilder<> &Builder, if (addr->getType()->isVectorTy()) { unsigned vectorNumElements = addr->getType()->getVectorNumElements(); DXASSERT(vectorNumElements <= 3, "up to 3 elements in atomic op"); - _Analysis_assume_(vectorNumElements <= 3); + assert(vectorNumElements <= 3); for (unsigned i = 0; i < vectorNumElements; i++) { Value *Elt = Builder.CreateExtractElement(addr, i); args[DXIL::OperandIndex::kAtomicCmpExchangeCoord0OpIdx + i] = Elt; @@ -6116,7 +6116,7 @@ void TranslateCBAddressUser(Instruction *user, Value *handle, Value *baseOffset, if (resultType->isVectorTy()) resultSize = resultType->getVectorNumElements(); DXASSERT(resultSize <= 16, "up to 4x4 elements in vector or matrix"); - _Analysis_assume_(resultSize <= 16); + assert(resultSize <= 16); Value *idxList[16]; switch (subOp) { @@ -6537,7 +6537,7 @@ void TranslateCBAddressUserLegacy(Instruction *user, Value *handle, if (resultType->isVectorTy()) resultSize = resultType->getVectorNumElements(); DXASSERT(resultSize <= 16, "up to 4x4 elements in vector or matrix"); - _Analysis_assume_(resultSize <= 16); + assert(resultSize <= 16); Value *idxList[16]; bool colMajor = subOp == HLSubscriptOpcode::ColMatSubscript || subOp == HLSubscriptOpcode::ColMatElement; @@ -7300,7 +7300,7 @@ void TranslateStructBufMatSubscript(CallInst *CI, if (resultType->isVectorTy()) resultSize = resultType->getVectorNumElements(); DXASSERT(resultSize <= 16, "up to 4x4 elements in vector or matrix"); - _Analysis_assume_(resultSize <= 16); + assert(resultSize <= 16); std::vector idxList(resultSize); switch (subOp) { @@ -7565,7 +7565,7 @@ void TranslateStructBufSubscriptUser( if (Ty->isVectorTy()) { unsigned vectorNumElements = Ty->getVectorNumElements(); DXASSERT(vectorNumElements <= 4, "up to 4 elements in vector"); - _Analysis_assume_(vectorNumElements <= 4); + assert(vectorNumElements <= 4); for (unsigned i = 0; i < vectorNumElements; i++) { vals[i] = Builder.CreateExtractElement(val, i); mask |= (1< Tys) { +std::string Intrinsic::getName(ID id, ArrayRef Tys) { assert(id < num_intrinsics && "Invalid intrinsic ID!"); static const char * const Table[] = { "not_intrinsic", diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index d89f5ffe48..a9ca80034c 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -62,7 +62,7 @@ bool Type::isIntegerTy(unsigned Bitwidth) const { // canLosslesslyBitCastTo - Return true if this type can be converted to // 'Ty' without any reinterpretation of bits. For example, i8* to i32*. // -bool Type::canLosslesslyBitCastTo(_In_ Type *Ty) const { +bool Type::canLosslesslyBitCastTo(Type *Ty) const { // Identity cast means no change so return true if (this == Ty) return true; diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index fd2e555ff5..3dd49f62c5 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1795,7 +1795,7 @@ bool Linker::LinkModules(Module *Dest, Module *Src) { // C API. //===----------------------------------------------------------------------===// -_Use_decl_annotations_ + LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, LLVMLinkerMode Unused, char **OutMessages) { Module *D = unwrap(Dest); diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index 97c41c1542..716d76a79f 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -238,7 +238,6 @@ static void emitLatency(LLVMDisasmContext *DC, const MCInst &Inst) { // returns zero the caller will have to pick how many bytes they want to step // over by printing a .byte, .long etc. to continue. // -_Use_decl_annotations_ // HLSL Change size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize){ diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 88c696df63..4b217bdba7 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -76,7 +76,7 @@ void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) { /// EmitIntValue - Special case of EmitValue that avoids the client having to /// pass in a MCExpr for constant integers. -_Use_decl_annotations_ + void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) { assert(1 <= Size && Size <= 8 && "Invalid size"); assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) && diff --git a/lib/MSSupport/MSFileSystemImpl.cpp b/lib/MSSupport/MSFileSystemImpl.cpp index b7a77ad3fd..38fc105d7a 100644 --- a/lib/MSSupport/MSFileSystemImpl.cpp +++ b/lib/MSSupport/MSFileSystemImpl.cpp @@ -6,7 +6,8 @@ // This file is distributed under the University of Illinois Open Source // // License. See LICENSE.TXT for details. // // // -// This file implements the DXCompiler specific implementation of the Path API.// +// This file implements the DXCompiler specific implementation of the Path // +// API. // // // /////////////////////////////////////////////////////////////////////////////// @@ -19,65 +20,90 @@ #include #endif -#include -#include -#include #include #include +#include +#include +#include #include "dxc/Support/WinIncludes.h" #include "dxc/WinAdapter.h" #include "llvm/Support/MSFileSystem.h" -/////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Externally visible functions. -HRESULT CreateMSFileSystemForDisk(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw(); +HRESULT +CreateMSFileSystemForDisk(::llvm::sys::fs::MSFileSystem **pResult) throw(); -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Win32-and-CRT-based MSFileSystem implementation with direct filesystem access. +//////////////////////////////////////////////////////////////////////////////// +// Win32-and-CRT-based MSFileSystem implementation with direct filesystem +// access. namespace llvm { -namespace sys { +namespace sys { namespace fs { -class MSFileSystemForDisk : public MSFileSystem -{ +class MSFileSystemForDisk : public MSFileSystem { public: unsigned _defaultAttributes; MSFileSystemForDisk(); - virtual BOOL FindNextFileW(_In_ HANDLE hFindFile, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override; - virtual HANDLE FindFirstFileW(_In_ LPCWSTR lpFileName, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override; + virtual BOOL + FindNextFileW(HANDLE hFindFile, + LPWIN32_FIND_DATAW lpFindFileData) throw() override; + virtual HANDLE + FindFirstFileW(LPCWSTR lpFileName, + LPWIN32_FIND_DATAW lpFindFileData) throw() override; virtual void FindClose(HANDLE findHandle) throw() override; - virtual HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes) throw() override; - virtual BOOL SetFileTime(_In_ HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw() override; - virtual BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override; - virtual DWORD GetFileType(_In_ HANDLE hFile) throw() override; - virtual BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() override; - virtual BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() override; - virtual DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() override; - virtual BOOL CloseHandle(_In_ HANDLE hObject) throw() override; - virtual BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() override; - virtual BOOL RemoveDirectoryW(_In_ LPCWSTR lpFileName) throw() override; - virtual BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() override; - _Success_(return != 0 && return < nBufferLength) - virtual DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() override; - _Success_(return != 0 && return < nSize) - virtual DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return + 1) LPWSTR lpFilename, DWORD nSize) throw() override; - virtual DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() override; - virtual BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() override; + virtual HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, + DWORD dwShareMode, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes) throw() override; + virtual BOOL SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) throw() override; + virtual BOOL GetFileInformationByHandle( + HANDLE hFile, + LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override; + virtual DWORD GetFileType(HANDLE hFile) throw() override; + virtual BOOL CreateHardLinkW(LPCWSTR lpFileName, + LPCWSTR lpExistingFileName) throw() override; + virtual BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, + DWORD dwFlags) throw() override; + virtual DWORD GetFileAttributesW(LPCWSTR lpFileName) throw() override; + virtual BOOL CloseHandle(HANDLE hObject) throw() override; + virtual BOOL DeleteFileW(LPCWSTR lpFileName) throw() override; + virtual BOOL RemoveDirectoryW(LPCWSTR lpFileName) throw() override; + virtual BOOL CreateDirectoryW(LPCWSTR lpPathName) throw() override; + virtual DWORD GetCurrentDirectoryW(DWORD nBufferLength, + + LPWSTR lpBuffer) throw() override; + virtual DWORD GetMainModuleFileNameW(LPWSTR lpFilename, + DWORD nSize) throw() override; + virtual DWORD GetTempPathW(DWORD nBufferLength, + + LPWSTR lpBuffer) throw() override; + virtual BOOLEAN CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, + LPCWSTR lpTargetFileName, + DWORD dwFlags) throw() override; virtual bool SupportsCreateSymbolicLink() throw() override; - virtual BOOL ReadFile(_In_ HANDLE hFile, _Out_bytecap_(nNumberOfBytesToRead) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() override; - virtual HANDLE CreateFileMappingW(_In_ HANDLE hFile, _In_ DWORD flProtect, _In_ DWORD dwMaximumSizeHigh, _In_ DWORD dwMaximumSizeLow) throw() override; - virtual LPVOID MapViewOfFile(_In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, _In_ DWORD dwFileOffsetHigh, _In_ DWORD dwFileOffsetLow, _In_ SIZE_T dwNumberOfBytesToMap) throw() override; - virtual BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() override; - + virtual BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() override; + virtual HANDLE CreateFileMappingW(HANDLE hFile, DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow) throw() override; + virtual LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap) throw() override; + virtual BOOL UnmapViewOfFile(LPCVOID lpBaseAddress) throw() override; + // Console APIs. virtual bool FileDescriptorIsDisplayed(int fd) throw() override; virtual unsigned GetColumnCount(DWORD nStdHandle) throw() override; virtual unsigned GetConsoleOutputTextAttributes() throw() override; - virtual void SetConsoleOutputTextAttributes(unsigned attributes) throw() override; + virtual void + SetConsoleOutputTextAttributes(unsigned attributes) throw() override; virtual void ResetConsoleOutputTextAttributes() throw() override; // CRT APIs. @@ -86,404 +112,386 @@ class MSFileSystemForDisk : public MSFileSystem virtual int close(int fd) throw() override; virtual long lseek(int fd, long offset, int origin) throw() override; virtual int setmode(int fd, int mode) throw() override; - virtual errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() override; - virtual int Read(int fd, _Out_bytecap_(count) void* buffer, unsigned int count) throw() override; - virtual int Write(int fd, _In_bytecount_(count) const void* buffer, unsigned int count) throw() override; + virtual errno_t resize_file(LPCWSTR path, uint64_t size) throw() override; + virtual int Read(int fd, void *buffer, unsigned int count) throw() override; + virtual int Write(int fd, const void *buffer, + unsigned int count) throw() override; #ifndef _WIN32 - virtual int Open(const char *lpFileName, int flags, mode_t mode) throw() override; - virtual int Stat(const char *lpFileName, struct stat *Status) throw() override; + virtual int Open(const char *lpFileName, int flags, + mode_t mode) throw() override; + virtual int Stat(const char *lpFileName, + struct stat *Status) throw() override; virtual int Fstat(int FD, struct stat *Status) throw() override; #endif }; -MSFileSystemForDisk::MSFileSystemForDisk() -{ - #ifdef _WIN32 +MSFileSystemForDisk::MSFileSystemForDisk() { +#ifdef _WIN32 _defaultAttributes = GetConsoleOutputTextAttributes(); - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::FindNextFileW( + HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData) throw() { +#ifdef _WIN32 return ::FindNextFileW(hFindFile, lpFindFileData); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -HANDLE MSFileSystemForDisk::FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) throw() -{ - #ifdef _WIN32 +HANDLE +MSFileSystemForDisk::FindFirstFileW(LPCWSTR lpFileName, + LPWIN32_FIND_DATAW lpFindFileData) throw() { +#ifdef _WIN32 return ::FindFirstFileW(lpFileName, lpFindFileData); - #else +#else assert(false && "Not implemented for Unix"); return nullptr; - #endif +#endif } -void MSFileSystemForDisk::FindClose(HANDLE findHandle) throw() -{ - #ifdef _WIN32 +void MSFileSystemForDisk::FindClose(HANDLE findHandle) throw() { +#ifdef _WIN32 ::FindClose(findHandle); - #else +#else assert(false && "Not implemented for Unix"); - #endif +#endif } -_Use_decl_annotations_ -HANDLE MSFileSystemForDisk::CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes) throw() -{ - #ifdef _WIN32 - return ::CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition, dwFlagsAndAttributes, nullptr); - #else +HANDLE MSFileSystemForDisk::CreateFileW(LPCWSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes) throw() { +#ifdef _WIN32 + return ::CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, nullptr, + dwCreationDisposition, dwFlagsAndAttributes, nullptr); +#else assert(false && "Not implemented for Unix"); return nullptr; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::SetFileTime(HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw() -{ - #ifdef _WIN32 - return ::SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime); - #else +BOOL MSFileSystemForDisk::SetFileTime(HANDLE hFile, + const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) throw() { +#ifdef _WIN32 + return ::SetFileTime(hFile, lpCreationTime, lpLastAccessTime, + lpLastWriteTime); +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::GetFileInformationByHandle( + HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() { +#ifdef _WIN32 return ::GetFileInformationByHandle(hFile, lpFileInformation); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -DWORD MSFileSystemForDisk::GetFileType(HANDLE hFile) throw() -{ - #ifdef _WIN32 +DWORD +MSFileSystemForDisk::GetFileType(HANDLE hFile) throw() { +#ifdef _WIN32 return ::GetFileType(hFile); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::CreateHardLinkW(LPCWSTR lpFileName, LPCWSTR lpExistingFileName) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::CreateHardLinkW(LPCWSTR lpFileName, + LPCWSTR lpExistingFileName) throw() { +#ifdef _WIN32 return ::CreateHardLinkW(lpFileName, lpExistingFileName, nullptr); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::MoveFileExW(LPCWSTR lpExistingFileName, + LPCWSTR lpNewFileName, + DWORD dwFlags) throw() { +#ifdef _WIN32 return ::MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -DWORD MSFileSystemForDisk::GetFileAttributesW(LPCWSTR lpFileName) throw() -{ - #ifdef _WIN32 +DWORD +MSFileSystemForDisk::GetFileAttributesW(LPCWSTR lpFileName) throw() { +#ifdef _WIN32 return ::GetFileAttributesW(lpFileName); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::CloseHandle(HANDLE hObject) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::CloseHandle(HANDLE hObject) throw() { +#ifdef _WIN32 return ::CloseHandle(hObject); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::DeleteFileW(LPCWSTR lpFileName) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::DeleteFileW(LPCWSTR lpFileName) throw() { +#ifdef _WIN32 return ::DeleteFileW(lpFileName); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::RemoveDirectoryW(LPCWSTR lpFileName) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::RemoveDirectoryW(LPCWSTR lpFileName) throw() { +#ifdef _WIN32 return ::RemoveDirectoryW(lpFileName); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::CreateDirectoryW(LPCWSTR lpPathName) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::CreateDirectoryW(LPCWSTR lpPathName) throw() { +#ifdef _WIN32 return ::CreateDirectoryW(lpPathName, nullptr); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -DWORD MSFileSystemForDisk::GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) throw() -{ - #ifdef _WIN32 +DWORD MSFileSystemForDisk::GetCurrentDirectoryW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() { +#ifdef _WIN32 return ::GetCurrentDirectoryW(nBufferLength, lpBuffer); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -_Use_decl_annotations_ -DWORD MSFileSystemForDisk::GetMainModuleFileNameW(LPWSTR lpFilename, DWORD nSize) throw() -{ - #ifdef _WIN32 +DWORD MSFileSystemForDisk::GetMainModuleFileNameW(LPWSTR lpFilename, + DWORD nSize) throw() { +#ifdef _WIN32 // Add some code to ensure that the result is null terminated. - if (nSize <= 1) - { + if (nSize <= 1) { ::SetLastError(ERROR_INSUFFICIENT_BUFFER); return 0; } DWORD result = ::GetModuleFileNameW(nullptr, lpFilename, nSize - 1); - if (result == 0) return result; + if (result == 0) + return result; lpFilename[result] = L'\0'; return result; - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -_Use_decl_annotations_ -DWORD MSFileSystemForDisk::GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) throw() -{ - #ifdef _WIN32 +DWORD MSFileSystemForDisk::GetTempPathW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() { +#ifdef _WIN32 return ::GetTempPathW(nBufferLength, lpBuffer); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } #ifdef _WIN32 namespace { - typedef BOOLEAN(WINAPI *PtrCreateSymbolicLinkW)( +typedef BOOLEAN(WINAPI *PtrCreateSymbolicLinkW)( /*__in*/ LPCWSTR lpSymlinkFileName, /*__in*/ LPCWSTR lpTargetFileName, /*__in*/ DWORD dwFlags); - PtrCreateSymbolicLinkW create_symbolic_link_api = - PtrCreateSymbolicLinkW(::GetProcAddress( - ::GetModuleHandleW(L"Kernel32.dll"), "CreateSymbolicLinkW")); -} +PtrCreateSymbolicLinkW create_symbolic_link_api = + PtrCreateSymbolicLinkW(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), + "CreateSymbolicLinkW")); +} // namespace #endif -_Use_decl_annotations_ -BOOLEAN MSFileSystemForDisk::CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName, DWORD dwFlags) throw() -{ - #ifdef _WIN32 +BOOLEAN MSFileSystemForDisk::CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, + LPCWSTR lpTargetFileName, + DWORD dwFlags) throw() { +#ifdef _WIN32 return create_symbolic_link_api(lpSymlinkFileName, lpTargetFileName, dwFlags); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -bool MSFileSystemForDisk::SupportsCreateSymbolicLink() throw() -{ - #ifdef _WIN32 +bool MSFileSystemForDisk::SupportsCreateSymbolicLink() throw() { +#ifdef _WIN32 return create_symbolic_link_api != nullptr; - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() -{ - #ifdef _WIN32 - return ::ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, nullptr); - #else +BOOL MSFileSystemForDisk::ReadFile(HANDLE hFile, LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() { +#ifdef _WIN32 + return ::ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, + nullptr); +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -_Use_decl_annotations_ -HANDLE MSFileSystemForDisk::CreateFileMappingW(HANDLE hFile, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow) throw() -{ - #ifdef _WIN32 - return ::CreateFileMappingW(hFile, nullptr, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, nullptr); - #else +HANDLE MSFileSystemForDisk::CreateFileMappingW(HANDLE hFile, DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow) throw() { +#ifdef _WIN32 + return ::CreateFileMappingW(hFile, nullptr, flProtect, dwMaximumSizeHigh, + dwMaximumSizeLow, nullptr); +#else assert(false && "Not implemented for Unix"); return nullptr; - #endif +#endif } -_Use_decl_annotations_ -LPVOID MSFileSystemForDisk::MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) throw() -{ - #ifdef _WIN32 - return ::MapViewOfFile(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap); - #else +LPVOID MSFileSystemForDisk::MapViewOfFile(HANDLE hFileMappingObject, + DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, + DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap) throw() { +#ifdef _WIN32 + return ::MapViewOfFile(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, + dwFileOffsetLow, dwNumberOfBytesToMap); +#else assert(false && "Not implemented for Unix"); return nullptr; - #endif +#endif } -_Use_decl_annotations_ -BOOL MSFileSystemForDisk::UnmapViewOfFile(LPCVOID lpBaseAddress) throw() -{ - #ifdef _WIN32 +BOOL MSFileSystemForDisk::UnmapViewOfFile(LPCVOID lpBaseAddress) throw() { +#ifdef _WIN32 return ::UnmapViewOfFile(lpBaseAddress); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -bool MSFileSystemForDisk::FileDescriptorIsDisplayed(int fd) throw() -{ - #ifdef _WIN32 - DWORD Mode; // Unused +bool MSFileSystemForDisk::FileDescriptorIsDisplayed(int fd) throw() { +#ifdef _WIN32 + DWORD Mode; // Unused return (GetConsoleMode((HANDLE)_get_osfhandle(fd), &Mode) != 0); - #else +#else assert(false && "Not implemented for Unix"); return false; - #endif +#endif } -unsigned MSFileSystemForDisk::GetColumnCount(DWORD nStdHandle) throw() -{ - #ifdef _WIN32 +unsigned MSFileSystemForDisk::GetColumnCount(DWORD nStdHandle) throw() { +#ifdef _WIN32 unsigned Columns = 0; CONSOLE_SCREEN_BUFFER_INFO csbi; if (::GetConsoleScreenBufferInfo(GetStdHandle(nStdHandle), &csbi)) Columns = csbi.dwSize.X; return Columns; - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -unsigned MSFileSystemForDisk::GetConsoleOutputTextAttributes() throw() -{ - #ifdef _WIN32 +unsigned MSFileSystemForDisk::GetConsoleOutputTextAttributes() throw() { +#ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbi; if (::GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) return csbi.wAttributes; return 0; - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -void MSFileSystemForDisk::SetConsoleOutputTextAttributes(unsigned attributes) throw() -{ - #ifdef _WIN32 +void MSFileSystemForDisk::SetConsoleOutputTextAttributes( + unsigned attributes) throw() { +#ifdef _WIN32 ::SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), attributes); - #else +#else assert(false && "Not implemented for Unix"); - #endif +#endif } -void MSFileSystemForDisk::ResetConsoleOutputTextAttributes() throw() -{ - #ifdef _WIN32 - ::SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), _defaultAttributes); - #else +void MSFileSystemForDisk::ResetConsoleOutputTextAttributes() throw() { +#ifdef _WIN32 + ::SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + _defaultAttributes); +#else assert(false && "Not implemented for Unix"); - #endif +#endif } -int MSFileSystemForDisk::open_osfhandle(intptr_t osfhandle, int flags) throw() -{ - #ifdef _WIN32 +int MSFileSystemForDisk::open_osfhandle(intptr_t osfhandle, int flags) throw() { +#ifdef _WIN32 return ::_open_osfhandle(osfhandle, flags); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -intptr_t MSFileSystemForDisk::get_osfhandle(int fd) throw() -{ - #ifdef _WIN32 +intptr_t MSFileSystemForDisk::get_osfhandle(int fd) throw() { +#ifdef _WIN32 return ::_get_osfhandle(fd); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -int MSFileSystemForDisk::close(int fd) throw() -{ - #ifdef _WIN32 +int MSFileSystemForDisk::close(int fd) throw() { +#ifdef _WIN32 return ::_close(fd); - #else +#else return ::close(fd); - #endif +#endif } -long MSFileSystemForDisk::lseek(int fd, long offset, int origin) throw() -{ - #ifdef _WIN32 +long MSFileSystemForDisk::lseek(int fd, long offset, int origin) throw() { +#ifdef _WIN32 return ::_lseek(fd, offset, origin); - #else +#else return ::lseek(fd, offset, origin); - #endif +#endif } -int MSFileSystemForDisk::setmode(int fd, int mode) throw() -{ - #ifdef _WIN32 +int MSFileSystemForDisk::setmode(int fd, int mode) throw() { +#ifdef _WIN32 return ::_setmode(fd, mode); - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -_Use_decl_annotations_ -errno_t MSFileSystemForDisk::resize_file(LPCWSTR path, uint64_t size) throw() -{ - #ifdef _WIN32 +errno_t MSFileSystemForDisk::resize_file(LPCWSTR path, uint64_t size) throw() { +#ifdef _WIN32 int fd = ::_wopen(path, O_BINARY | _O_RDWR, S_IWRITE); if (fd == -1) return errno; @@ -495,38 +503,38 @@ errno_t MSFileSystemForDisk::resize_file(LPCWSTR path, uint64_t size) throw() ::_close(fd); return error; - #else +#else assert(false && "Not implemented for Unix"); return 0; - #endif +#endif } -_Use_decl_annotations_ -int MSFileSystemForDisk::Read(int fd, void* buffer, unsigned int count) throw() -{ - #ifdef _WIN32 +int MSFileSystemForDisk::Read(int fd, void *buffer, + unsigned int count) throw() { +#ifdef _WIN32 return ::_read(fd, buffer, count); - #else +#else return ::read(fd, buffer, count); - #endif +#endif } -_Use_decl_annotations_ -int MSFileSystemForDisk::Write(int fd, const void* buffer, unsigned int count) throw() -{ - #ifdef _WIN32 +int MSFileSystemForDisk::Write(int fd, const void *buffer, + unsigned int count) throw() { +#ifdef _WIN32 return ::_write(fd, buffer, count); - #else +#else return ::write(fd, buffer, count); - #endif +#endif } #ifndef _WIN32 -int MSFileSystemForDisk::Open(const char *lpFileName, int flags, mode_t mode) throw() { +int MSFileSystemForDisk::Open(const char *lpFileName, int flags, + mode_t mode) throw() { return ::open(lpFileName, flags, mode); } -int MSFileSystemForDisk::Stat(const char *lpFileName, struct stat *Status) throw() { +int MSFileSystemForDisk::Stat(const char *lpFileName, + struct stat *Status) throw() { return ::stat(lpFileName, Status); } @@ -542,8 +550,8 @@ int MSFileSystemForDisk::Fstat(int FD, struct stat *Status) throw() { /////////////////////////////////////////////////////////////////////////////////////////////////// // Externally visible functions. -HRESULT CreateMSFileSystemForDisk(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw() -{ - *pResult = new (std::nothrow) ::llvm::sys::fs::MSFileSystemForDisk(); +HRESULT +CreateMSFileSystemForDisk(::llvm::sys::fs::MSFileSystem **pResult) throw() { + *pResult = new (std::nothrow)::llvm::sys::fs::MSFileSystemForDisk(); return (*pResult != nullptr) ? S_OK : E_OUTOFMEMORY; } diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 9e8416bd6f..3c76c72271 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -527,8 +527,8 @@ static const char NaNU[] = "NAN"; significant nibble. Write out exactly COUNT hexdigits, return COUNT. */ static unsigned int -partAsHex (_Out_writes_(count) char *dst, integerPart part, unsigned int count, - _In_count_(16) const char *hexDigitChars) +partAsHex (char *dst, integerPart part, unsigned int count, + const char *hexDigitChars) { unsigned int result = count; @@ -545,7 +545,7 @@ partAsHex (_Out_writes_(count) char *dst, integerPart part, unsigned int count, /* Write out an unsigned decimal integer. */ static char * -writeUnsignedDecimal (_Out_writes_(10) char *dst, unsigned int n) // HLSL Change: '4294967295' is ten characters +writeUnsignedDecimal (char *dst, unsigned int n) { char buff[40], *p; @@ -563,7 +563,7 @@ writeUnsignedDecimal (_Out_writes_(10) char *dst, unsigned int n) // HLSL Change /* Write out a signed decimal integer. */ static char * -writeSignedDecimal(_Out_writes_(11) char *dst, int value) // HLSL Change: '-2147483648' is eleven characters +writeSignedDecimal(char *dst, int value) { if (value < 0) { *dst++ = '-'; diff --git a/lib/Support/ConvertUTFWrapper.cpp b/lib/Support/ConvertUTFWrapper.cpp index aab7d2cfe4..1bbef233b8 100644 --- a/lib/Support/ConvertUTFWrapper.cpp +++ b/lib/Support/ConvertUTFWrapper.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "dxc/WinAdapter.h" // HLSL Change #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/SwapByteOrder.h" #include @@ -15,7 +14,6 @@ namespace llvm { -_Use_decl_annotations_ // HLSL Change bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, char *&ResultPtr, const UTF8 *&ErrorPtr) { assert(WideCharWidth == 1 || WideCharWidth == 2 || WideCharWidth == 4); @@ -62,7 +60,6 @@ bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, return result == conversionOK; } -_Use_decl_annotations_ // HLSL Change bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) { const UTF32 *SourceStart = &Source; const UTF32 *SourceEnd = SourceStart + 1; diff --git a/lib/Support/MSFileSystemBasic.cpp b/lib/Support/MSFileSystemBasic.cpp index 496b294085..2586e665c2 100644 --- a/lib/Support/MSFileSystemBasic.cpp +++ b/lib/Support/MSFileSystemBasic.cpp @@ -13,6 +13,8 @@ #ifdef _WIN32 #include "dxc/Support/WinIncludes.h" + +#include #include #include #include @@ -33,10 +35,13 @@ // Externally visible functions. /// Creates an implementation based on IDxcSystemAccess. -HRESULT CreateMSFileSystemForIface(_In_ IUnknown* pService, _COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw(); +HRESULT +CreateMSFileSystemForIface(IUnknown *pService, + ::llvm::sys::fs::MSFileSystem **pResult) throw(); /// Creates an implementation with no access to system resources. -HRESULT CreateMSFileSystemBlocked(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw(); +HRESULT +CreateMSFileSystemBlocked(::llvm::sys::fs::MSFileSystem **pResult) throw(); /////////////////////////////////////////////////////////////////////////////////////////////////// // Helper functions. @@ -56,9 +61,8 @@ DWORD WIN32_FROM_HRESULT(HRESULT hr) return ERROR_FUNCTION_FAILED; } -static -HRESULT CopyStatStg(_In_ const STATSTG* statStg, _Out_ LPWIN32_FIND_DATAW lpFindFileData) -{ +static HRESULT CopyStatStg(const STATSTG *statStg, + LPWIN32_FIND_DATAW lpFindFileData) { HRESULT hr = S_OK; lpFindFileData->dwFileAttributes = FILE_ATTRIBUTE_NORMAL; lpFindFileData->ftCreationTime = statStg->ctime; @@ -75,9 +79,7 @@ HRESULT CopyStatStg(_In_ const STATSTG* statStg, _Out_ LPWIN32_FIND_DATAW lpFind return hr; } -static -void ClearStatStg(_Inout_ STATSTG* statStg) -{ +static void ClearStatStg(STATSTG *statStg) { DXASSERT_NOMSG(statStg != nullptr); if (statStg->pwcsName != nullptr) { @@ -160,49 +162,71 @@ class MSFileSystemForIface : public MSFileSystem MSFileSystemHandle m_knownHandle1; MSFileSystemHandle m_knownHandle2; - HRESULT AddFindHandle(_In_ IEnumSTATSTG* enumStatStg, _Out_ HANDLE* pResult) throw(); - HRESULT AddFileHandle(_In_ IUnknown* storage, _In_ IStream* stream, _Out_ HANDLE* pResult) throw(); - HRESULT AddMappingHandle(_In_ IUnknown* mapping, _Out_ HANDLE* pResult) throw(); - HRESULT AddMappingView(_In_ ID3D10Blob* blob) throw(); + HRESULT AddFindHandle(IEnumSTATSTG *enumStatStg, HANDLE *pResult) throw(); + HRESULT AddFileHandle(IUnknown *storage, IStream *stream, + HANDLE *pResult) throw(); + HRESULT AddMappingHandle(IUnknown *mapping, HANDLE *pResult) throw(); + HRESULT AddMappingView(ID3D10Blob *blob) throw(); HRESULT EnsureFDAvailable(int fd); HANDLE GetHandleForFD(int fd) throw(); - void GetFindHandle(HANDLE findHandle, _Outptr_ IEnumSTATSTG** enumStatStg) throw(); + void GetFindHandle(HANDLE findHandle, IEnumSTATSTG **enumStatStg) throw(); int GetHandleFD(HANDLE fileHandle) throw(); - void GetHandleMapping(HANDLE fileHandle, _Outptr_ IUnknown** pResult) throw(); - void GetHandleStorage(HANDLE fileHandle, _Outptr_ IUnknown** pResult) throw(); - void GetHandleStream(HANDLE fileHandle, _Outptr_ IStream** pResult) throw(); + void GetHandleMapping(HANDLE fileHandle, IUnknown **pResult) throw(); + void GetHandleStorage(HANDLE fileHandle, IUnknown **pResult) throw(); + void GetHandleStream(HANDLE fileHandle, IStream **pResult) throw(); void CloseInternalHandle(HANDLE findHandle) throw(); - void RemoveMappingView(_In_ LPCVOID address) throw(); + void RemoveMappingView(LPCVOID address) throw(); public: - MSFileSystemForIface(_In_ IDxcSystemAccess* access); - - virtual BOOL FindNextFileW(_In_ HANDLE hFindFile, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override; - virtual HANDLE FindFirstFileW(_In_ LPCWSTR lpFileName, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override; + MSFileSystemForIface(IDxcSystemAccess *access); + + virtual BOOL + FindNextFileW(HANDLE hFindFile, + LPWIN32_FIND_DATAW lpFindFileData) throw() override; + virtual HANDLE + FindFirstFileW(LPCWSTR lpFileName, + LPWIN32_FIND_DATAW lpFindFileData) throw() override; virtual void FindClose(HANDLE findHandle) throw() override; - virtual HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes) throw() override; - virtual BOOL SetFileTime(_In_ HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw() override; - virtual BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override; - virtual DWORD GetFileType(_In_ HANDLE hFile) throw() override; - virtual BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() override; - virtual BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() override; - virtual DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() override; - virtual BOOL CloseHandle(_In_ HANDLE hObject) throw() override; - virtual BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() override; - virtual BOOL RemoveDirectoryW(_In_ LPCWSTR lpFileName) throw() override; - virtual BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() override; - _Success_(return != 0 && return < nBufferLength) - virtual DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return +1) LPWSTR lpBuffer) throw() override; - _Success_(return != 0 && return < nSize) - virtual DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return +1) LPWSTR lpFilename, DWORD nSize) throw() override; - virtual DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return +1) LPWSTR lpBuffer) throw() override; - virtual BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() override; + virtual HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, + DWORD dwShareMode, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes) throw() override; + virtual BOOL SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) throw() override; + virtual BOOL GetFileInformationByHandle( + HANDLE hFile, + LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override; + virtual DWORD GetFileType(HANDLE hFile) throw() override; + virtual BOOL CreateHardLinkW(LPCWSTR lpFileName, + LPCWSTR lpExistingFileName) throw() override; + virtual BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, + DWORD dwFlags) throw() override; + virtual DWORD GetFileAttributesW(LPCWSTR lpFileName) throw() override; + virtual BOOL CloseHandle(HANDLE hObject) throw() override; + virtual BOOL DeleteFileW(LPCWSTR lpFileName) throw() override; + virtual BOOL RemoveDirectoryW(LPCWSTR lpFileName) throw() override; + virtual BOOL CreateDirectoryW(LPCWSTR lpPathName) throw() override; + virtual DWORD GetCurrentDirectoryW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() override; + virtual DWORD GetMainModuleFileNameW(LPWSTR lpFilename, + DWORD nSize) throw() override; + virtual DWORD GetTempPathW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() override; + virtual BOOLEAN CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, + LPCWSTR lpTargetFileName, + DWORD dwFlags) throw() override; virtual bool SupportsCreateSymbolicLink() throw() override; - virtual BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() override; - virtual HANDLE CreateFileMappingW(_In_ HANDLE hFile, _In_ DWORD flProtect, _In_ DWORD dwMaximumSizeHigh, _In_ DWORD dwMaximumSizeLow) throw() override; - virtual LPVOID MapViewOfFile(_In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, _In_ DWORD dwFileOffsetHigh, _In_ DWORD dwFileOffsetLow, _In_ SIZE_T dwNumberOfBytesToMap) throw() override; - virtual BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() override; - + virtual BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() override; + virtual HANDLE CreateFileMappingW(HANDLE hFile, DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow) throw() override; + virtual LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap) throw() override; + virtual BOOL UnmapViewOfFile(LPCVOID lpBaseAddress) throw() override; + // Console APIs. virtual bool FileDescriptorIsDisplayed(int fd) throw() override; virtual unsigned GetColumnCount(DWORD nStdHandle) throw() override; @@ -216,9 +240,10 @@ class MSFileSystemForIface : public MSFileSystem virtual int close(int fd) throw() override; virtual long lseek(int fd, long offset, int origin) throw() override; virtual int setmode(int fd, int mode) throw() override; - virtual errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() override; - virtual int Read(int fd, _Out_bytecap_(count) void* buffer, unsigned int count) throw() override; - virtual int Write(int fd, _In_bytecount_(count) const void* buffer, unsigned int count) throw() override; + virtual errno_t resize_file(LPCWSTR path, uint64_t size) throw() override; + virtual int Read(int fd, void *buffer, unsigned int count) throw() override; + virtual int Write(int fd, const void *buffer, + unsigned int count) throw() override; #ifndef _WIN32 virtual int Open(const char *lpFileName, int flags, mode_t mode) throw() override; virtual int Stat(const char *lpFileName, struct stat *Status) throw() override; @@ -226,7 +251,6 @@ class MSFileSystemForIface : public MSFileSystem #endif }; -_Use_decl_annotations_ MSFileSystemForIface::MSFileSystemForIface(IDxcSystemAccess* systemAccess) : m_system(systemAccess) , m_knownHandle0(0) @@ -235,7 +259,6 @@ MSFileSystemForIface::MSFileSystemForIface(IDxcSystemAccess* systemAccess) { } -_Use_decl_annotations_ HRESULT MSFileSystemForIface::AddMappingHandle(IUnknown* mapping, HANDLE* pResult) throw() { DXASSERT_NOMSG(mapping != nullptr); @@ -252,7 +275,6 @@ HRESULT MSFileSystemForIface::AddMappingHandle(IUnknown* mapping, HANDLE* pResul return hr; } -_Use_decl_annotations_ HRESULT MSFileSystemForIface::AddMappingView(ID3D10Blob* blob) throw() { DXASSERT_NOMSG(blob != nullptr); @@ -269,7 +291,6 @@ HRESULT MSFileSystemForIface::AddMappingView(ID3D10Blob* blob) throw() return S_OK; } -_Use_decl_annotations_ HRESULT MSFileSystemForIface::AddFindHandle(IEnumSTATSTG* enumStatStg, HANDLE* pResult) throw() { DXASSERT_NOMSG(enumStatStg != nullptr); @@ -286,7 +307,6 @@ HRESULT MSFileSystemForIface::AddFindHandle(IEnumSTATSTG* enumStatStg, HANDLE* p return hr; } -_Use_decl_annotations_ HRESULT MSFileSystemForIface::AddFileHandle(IUnknown* storage, IStream* stream, HANDLE* pResult) throw() { DXASSERT_NOMSG(storage != nullptr); @@ -319,7 +339,6 @@ void MSFileSystemForIface::CloseInternalHandle(HANDLE handle) throw() } } -_Use_decl_annotations_ void MSFileSystemForIface::RemoveMappingView(LPCVOID address) throw() { TViewMap::iterator i = m_mappingViews.find(address); @@ -329,7 +348,6 @@ void MSFileSystemForIface::RemoveMappingView(LPCVOID address) throw() m_mappingViews.erase(i); } -_Use_decl_annotations_ void MSFileSystemForIface::GetFindHandle(HANDLE findHandle, IEnumSTATSTG** enumStatStg) throw() { DXASSERT_NOMSG(findHandle != nullptr); @@ -354,9 +372,8 @@ int MSFileSystemForIface::GetHandleFD(HANDLE fileHandle) throw() return fsHandle->fd; } -_Use_decl_annotations_ -void MSFileSystemForIface::GetHandleMapping(HANDLE mapping, _Outptr_ IUnknown** pResult) throw() -{ +void MSFileSystemForIface::GetHandleMapping(HANDLE mapping, + IUnknown **pResult) throw() { DXASSERT_NOMSG(mapping != nullptr); DXASSERT_NOMSG(pResult != nullptr); @@ -369,9 +386,8 @@ void MSFileSystemForIface::GetHandleMapping(HANDLE mapping, _Outptr_ IUnknown** (*pResult)->AddRef(); } -_Use_decl_annotations_ -void MSFileSystemForIface::GetHandleStorage(HANDLE fileHandle, _Outptr_ IUnknown** pResult) throw() -{ +void MSFileSystemForIface::GetHandleStorage(HANDLE fileHandle, + IUnknown **pResult) throw() { DXASSERT_NOMSG(fileHandle != nullptr); DXASSERT_NOMSG(pResult != nullptr); @@ -384,9 +400,8 @@ void MSFileSystemForIface::GetHandleStorage(HANDLE fileHandle, _Outptr_ IUnknown (*pResult)->AddRef(); } -_Use_decl_annotations_ -void MSFileSystemForIface::GetHandleStream(HANDLE fileHandle, _Outptr_ IStream** pResult) throw() -{ +void MSFileSystemForIface::GetHandleStream(HANDLE fileHandle, + IStream **pResult) throw() { DXASSERT_NOMSG(fileHandle != nullptr); DXASSERT_NOMSG(pResult != nullptr); @@ -399,8 +414,6 @@ void MSFileSystemForIface::GetHandleStream(HANDLE fileHandle, _Outptr_ IStream** (*pResult)->AddRef(); } - -_Use_decl_annotations_ HANDLE MSFileSystemForIface::FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) throw() { HRESULT hr = S_OK; @@ -437,7 +450,6 @@ HANDLE MSFileSystemForIface::FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DAT return resultValue; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData) throw() { HRESULT hr = S_OK; @@ -475,7 +487,6 @@ void MSFileSystemForIface::FindClose(HANDLE findHandle) throw() CloseInternalHandle(findHandle); } -_Use_decl_annotations_ HANDLE MSFileSystemForIface::CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes) throw() { HRESULT hr = S_OK; @@ -497,9 +508,9 @@ HANDLE MSFileSystemForIface::CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAcce return resultHandle; } -_Use_decl_annotations_ -BOOL MSFileSystemForIface::SetFileTime(HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw() -{ +BOOL MSFileSystemForIface::SetFileTime( + HANDLE hFile, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime) throw() { HRESULT hr = S_OK; CComPtr storage; @@ -516,7 +527,6 @@ BOOL MSFileSystemForIface::SetFileTime(HANDLE hFile, _In_opt_ const FILETIME *lp return TRUE; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() { HRESULT hr = S_OK; @@ -535,7 +545,6 @@ BOOL MSFileSystemForIface::GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_ return TRUE; } -_Use_decl_annotations_ DWORD MSFileSystemForIface::GetFileType(HANDLE hFile) throw() { HRESULT hr = S_OK; @@ -559,21 +568,18 @@ DWORD MSFileSystemForIface::GetFileType(HANDLE hFile) throw() return fileType; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::CreateHardLinkW(LPCWSTR lpFileName, LPCWSTR lpExistingFileName) throw() { SetLastError(ERROR_FUNCTION_NOT_CALLED); return FALSE; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags) throw() { SetLastError(ERROR_FUNCTION_NOT_CALLED); return FALSE; } -_Use_decl_annotations_ DWORD MSFileSystemForIface::GetFileAttributesW(LPCWSTR lpFileName) throw() { HRESULT hr = S_OK; @@ -591,35 +597,30 @@ DWORD MSFileSystemForIface::GetFileAttributesW(LPCWSTR lpFileName) throw() return attributes; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::CloseHandle(HANDLE hObject) throw() { this->CloseInternalHandle(hObject); return TRUE; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::DeleteFileW(LPCWSTR lpFileName) throw() { SetLastError(ERROR_FUNCTION_NOT_CALLED); return FALSE; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::RemoveDirectoryW(LPCWSTR lpFileName) throw() { SetLastError(ERROR_FUNCTION_NOT_CALLED); return FALSE; } -_Use_decl_annotations_ BOOL MSFileSystemForIface::CreateDirectoryW(LPCWSTR lpPathName) throw() { SetLastError(ERROR_FUNCTION_NOT_CALLED); return FALSE; } -_Use_decl_annotations_ DWORD MSFileSystemForIface::GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) throw() { DWORD written = 0; @@ -637,7 +638,6 @@ DWORD MSFileSystemForIface::GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpB return written; } -_Use_decl_annotations_ DWORD MSFileSystemForIface::GetMainModuleFileNameW(LPWSTR lpFilename, DWORD nSize) throw() { DWORD written = 0; @@ -655,7 +655,6 @@ DWORD MSFileSystemForIface::GetMainModuleFileNameW(LPWSTR lpFilename, DWORD nSiz return written; } -_Use_decl_annotations_ DWORD MSFileSystemForIface::GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) throw() { DWORD written = 0; @@ -673,7 +672,6 @@ DWORD MSFileSystemForIface::GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) t return written; } -_Use_decl_annotations_ BOOLEAN MSFileSystemForIface::CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName, DWORD dwFlags) throw() { SetLastError(ERROR_FUNCTION_NOT_CALLED); @@ -685,9 +683,9 @@ bool MSFileSystemForIface::SupportsCreateSymbolicLink() throw() return false; } -_Use_decl_annotations_ -BOOL MSFileSystemForIface::ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() -{ +BOOL MSFileSystemForIface::ReadFile(HANDLE hFile, LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() { HRESULT hr = S_OK; CComPtr stream; GetHandleStream(hFile, &stream); @@ -708,7 +706,6 @@ BOOL MSFileSystemForIface::ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumber return TRUE; } -_Use_decl_annotations_ HANDLE MSFileSystemForIface::CreateFileMappingW(HANDLE hFile, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow) throw() { HRESULT hr = S_OK; @@ -730,7 +727,6 @@ HANDLE MSFileSystemForIface::CreateFileMappingW(HANDLE hFile, DWORD flProtect, D return result; } -_Use_decl_annotations_ LPVOID MSFileSystemForIface::MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) throw() { HRESULT hr = S_OK; @@ -751,7 +747,6 @@ LPVOID MSFileSystemForIface::MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDe return blob->GetBufferPointer(); } -_Use_decl_annotations_ BOOL MSFileSystemForIface::UnmapViewOfFile(LPCVOID lpBaseAddress) throw() { RemoveMappingView(lpBaseAddress); @@ -886,13 +881,11 @@ int MSFileSystemForIface::setmode(int fd, int mode) throw() return 0; } -_Use_decl_annotations_ errno_t MSFileSystemForIface::resize_file(LPCWSTR path, uint64_t size) throw() { return EBADF; } -_Use_decl_annotations_ int MSFileSystemForIface::Read(int fd, void* buffer, unsigned int count) throw() { HRESULT hr = S_OK; @@ -917,7 +910,6 @@ int MSFileSystemForIface::Read(int fd, void* buffer, unsigned int count) throw() return (int)cbRead; } -_Use_decl_annotations_ int MSFileSystemForIface::Write(int fd, const void* buffer, unsigned int count) throw() { HRESULT hr = S_OK; @@ -1009,72 +1001,111 @@ class MSFileSystemBlocked : public MSFileSystem public: MSFileSystemBlocked(); - virtual BOOL FindNextFileW(_In_ HANDLE , _Out_ LPWIN32_FIND_DATAW ) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL FindNextFileW(HANDLE, LPWIN32_FIND_DATAW) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual HANDLE FindFirstFileW(_In_ LPCWSTR lpFileName, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override - { return MSFileSystemBlockedHandle(); } + virtual HANDLE + FindFirstFileW(LPCWSTR lpFileName, + LPWIN32_FIND_DATAW lpFindFileData) throw() override { + return MSFileSystemBlockedHandle(); + } virtual void FindClose(HANDLE findHandle) throw() override { MSFileSystemBlockedCalled(); } - virtual HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes) throw() override - { return MSFileSystemBlockedHandle(); } + virtual HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, + DWORD dwShareMode, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes) throw() override { + return MSFileSystemBlockedHandle(); + } - virtual BOOL SetFileTime(_In_ HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL GetFileInformationByHandle( + HANDLE hFile, + LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual DWORD GetFileType(_In_ HANDLE hFile) throw() override - { MSFileSystemBlockedErrWin32(); return FILE_TYPE_UNKNOWN; } + virtual DWORD GetFileType(HANDLE hFile) throw() override { + MSFileSystemBlockedErrWin32(); + return FILE_TYPE_UNKNOWN; + } - virtual BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL CreateHardLinkW(LPCWSTR lpFileName, + LPCWSTR lpExistingFileName) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, + DWORD dwFlags) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() override - { MSFileSystemBlockedErrWin32(); return 0; } + virtual DWORD GetFileAttributesW(LPCWSTR lpFileName) throw() override { + MSFileSystemBlockedErrWin32(); + return 0; + } - virtual BOOL CloseHandle(_In_ HANDLE hObject) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL CloseHandle(HANDLE hObject) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL DeleteFileW(LPCWSTR lpFileName) throw() override { + return MSFileSystemBlockedErrWin32(); + } virtual BOOL RemoveDirectoryW(LPCWSTR lpFileName) throw() override { return MSFileSystemBlockedErrWin32(); } - virtual BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() override - { return MSFileSystemBlockedErrWin32(); } - - _Success_(return != 0 && return < nBufferLength) - virtual DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return +1) LPWSTR lpBuffer) throw() override; - virtual DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return +1) LPWSTR lpFilename, DWORD nSize) throw() override; - _Success_(return != 0 && return < nBufferLength) - virtual DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return +1) LPWSTR lpBuffer) throw() override; + virtual BOOL CreateDirectoryW(LPCWSTR lpPathName) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual DWORD GetCurrentDirectoryW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() override; + virtual DWORD GetMainModuleFileNameW(LPWSTR lpFilename, + DWORD nSize) throw() override; + virtual DWORD GetTempPathW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() override; + + virtual BOOLEAN CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, + LPCWSTR lpTargetFileName, + DWORD dwFlags) throw() override { + return MSFileSystemBlockedErrWin32(); + } virtual bool SupportsCreateSymbolicLink() throw() override { MSFileSystemBlockedErrWin32(); return false; } - virtual BOOL ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() override - { return MSFileSystemBlockedErrWin32(); } + virtual BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, + DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual HANDLE CreateFileMappingW(_In_ HANDLE hFile, _In_ DWORD flProtect, _In_ DWORD dwMaximumSizeHigh, _In_ DWORD dwMaximumSizeLow) throw() override - { return MSFileSystemBlockedHandle(); } + virtual HANDLE CreateFileMappingW(HANDLE hFile, DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow) throw() override { + return MSFileSystemBlockedHandle(); + } - virtual LPVOID MapViewOfFile(_In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, _In_ DWORD dwFileOffsetHigh, _In_ DWORD dwFileOffsetLow, _In_ SIZE_T dwNumberOfBytesToMap) throw() override - { MSFileSystemBlockedErrWin32(); return nullptr; } + virtual LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap) throw() override { + MSFileSystemBlockedErrWin32(); + return nullptr; + } + + virtual BOOL UnmapViewOfFile(LPCVOID lpBaseAddress) throw() override { + return MSFileSystemBlockedErrWin32(); + } - virtual BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() override - { return MSFileSystemBlockedErrWin32(); } - // Console APIs. virtual bool FileDescriptorIsDisplayed(int fd) throw() override { MSFileSystemBlockedCalled(); return false; } @@ -1107,8 +1138,9 @@ class MSFileSystemBlocked : public MSFileSystem virtual int setmode(int fd, int mode) throw() override { return MSFileSystemBlockedErrno(); } - virtual errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() override - { return MSFileSystemBlockedErrnoT(); } + virtual errno_t resize_file(LPCWSTR path, uint64_t size) throw() override { + return MSFileSystemBlockedErrnoT(); + } virtual int Read(int fd, void* buffer, unsigned int count) throw() override { return MSFileSystemBlockedErrno(); } @@ -1134,7 +1166,6 @@ MSFileSystemBlocked::MSFileSystemBlocked() { } -_Use_decl_annotations_ DWORD MSFileSystemBlocked::GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) throw() { if (nBufferLength > 1) @@ -1145,14 +1176,12 @@ DWORD MSFileSystemBlocked::GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBu return 1; } -_Use_decl_annotations_ DWORD MSFileSystemBlocked::GetMainModuleFileNameW(LPWSTR lpFilename, DWORD nSize) throw() { SetLastError(NO_ERROR); return 0; } -_Use_decl_annotations_ DWORD MSFileSystemBlocked::GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) throw() { if (nBufferLength > 1) @@ -1171,7 +1200,6 @@ DWORD MSFileSystemBlocked::GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) th /////////////////////////////////////////////////////////////////////////////////////////////////// // Externally visible functions. -_Use_decl_annotations_ HRESULT CreateMSFileSystemForIface(IUnknown* pService, ::llvm::sys::fs::MSFileSystem** pResult) throw() { DXASSERT_NOMSG(pService != nullptr); @@ -1185,7 +1213,6 @@ HRESULT CreateMSFileSystemForIface(IUnknown* pService, ::llvm::sys::fs::MSFileSy return (*pResult != nullptr) ? S_OK : E_OUTOFMEMORY; } -_Use_decl_annotations_ HRESULT CreateMSFileSystemBlocked(::llvm::sys::fs::MSFileSystem** pResult) throw() { DXASSERT_NOMSG(pResult != nullptr); diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index 700955c784..315cf1ac44 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -56,7 +56,7 @@ void MemoryBuffer::init(const char *BufStart, const char *BufEnd, /// CopyStringRef - Copies contents of a StringRef into a block of memory and /// null-terminates it. -static void CopyStringRef(_Out_cap_x_(Data.size()+1) char *Memory, StringRef Data) { +static void CopyStringRef(char *Memory, StringRef Data) { if (!Data.empty()) memcpy(Memory, Data.data(), Data.size()); Memory[Data.size()] = 0; // Null terminate string. diff --git a/lib/Support/Windows/MSFileSystem.inc.cpp b/lib/Support/Windows/MSFileSystem.inc.cpp index 69bd3bc4e5..49fbda05e4 100644 --- a/lib/Support/Windows/MSFileSystem.inc.cpp +++ b/lib/Support/Windows/MSFileSystem.inc.cpp @@ -209,9 +209,8 @@ int msf_setmode(int fd, int mode) throw() typedef llvm::sys::fs::MSFileSystemRef MSFileSystemRef; -static -error_code GetCurrentThreadFileSystemOrError(_Outptr_ MSFileSystemRef* pResult) throw() -{ +static error_code +GetCurrentThreadFileSystemOrError(MSFileSystemRef *pResult) throw() { *pResult = ::llvm::sys::fs::GetCurrentThreadFileSystem(); // It is an error to have an I/O API invoked without having installed support diff --git a/lib/Support/assert.cpp b/lib/Support/assert.cpp index 13e0263d15..abc9888e2b 100644 --- a/lib/Support/assert.cpp +++ b/lib/Support/assert.cpp @@ -14,9 +14,9 @@ #include "windows.h" #include "dxc/Support/Global.h" -void llvm_assert(_In_z_ const char *_Message, - _In_z_ const char *_File, - _In_ unsigned _Line, +void llvm_assert(const char *_Message, + const char *_File, + unsigned _Line, const char *_Function) { OutputDebugFormatA("Error: assert(%s)\nFile:\n%s(%d)\nFunc:\t%s\n", _Message, _File, _Line, _Function); RaiseException(STATUS_LLVM_ASSERT, 0, 0, 0); diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index efa35fc0d3..b11ffb15d5 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -88,7 +88,7 @@ void raw_ostream::SetBuffered() { SetUnbuffered(); } -void raw_ostream::SetBufferAndMode(_In_opt_ char *BufferStart, size_t Size, +void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode) { assert(((Mode == Unbuffered && !BufferStart && Size == 0) || (Mode != Unbuffered && BufferStart && Size != 0)) && @@ -454,7 +454,7 @@ raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) { while (N) { uintptr_t x = N % 16; assert(CurPtr > NumberBuffer && "else FN values inconsistent"); // HLSL Change - _Analysis_assume_(CurPtr > NumberBuffer); // HLSL Change + assert(CurPtr > NumberBuffer); // HLSL Change *--CurPtr = (x < 10 ? '0' + x : A + x - 10); N /= 16; } diff --git a/lib/Support/regcomp.c b/lib/Support/regcomp.c index 55a05e247e..002521a2e2 100644 --- a/lib/Support/regcomp.c +++ b/lib/Support/regcomp.c @@ -1096,7 +1096,7 @@ allocset(struct parse *p) p->g->setbits = ptr; for (i = 0; i < no; i++) { - _Analysis_assume_(i < nc); // HLSL Change + assert(i < nc); // HLSL Change p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); } diff --git a/lib/Support/regengine.inc b/lib/Support/regengine.inc index 4699e038d0..9494eb9adb 100644 --- a/lib/Support/regengine.inc +++ b/lib/Support/regengine.inc @@ -92,7 +92,7 @@ static const char *backref(struct match *, const char *, const char *, sopno, sopno, sopno, int); static const char *fast(struct match *, const char *, const char *, sopno, sopno); static const char *slow(struct match *, const char *, const char *, sopno, sopno); -static states step(struct re_guts *, sopno, sopno, _states_param_ states, int, _states_param_ states); +static states step(struct re_guts *, sopno, sopno, states, int, states); #define MAX_RECURSION 100 #define BOL (OUT+1) #define EOL (BOL+1) @@ -849,9 +849,9 @@ static states step(struct re_guts *g, sopno start, /* start state within strip */ sopno stop, /* state after stop state within strip */ -_states_param_ states bef, /* states reachable before */ + states bef, /* states reachable before */ int ch, /* character or NONCHAR code */ -_states_param_ states aft) /* states already known reachable after */ + states aft) /* states already known reachable after */ { cset *cs; sop s; diff --git a/lib/Support/regerror.c b/lib/Support/regerror.c index 782b75deaf..13eb7f30ef 100644 --- a/lib/Support/regerror.c +++ b/lib/Support/regerror.c @@ -53,7 +53,7 @@ static const char *regatoi( const llvm_regex_t *preg, - _Out_writes_all_(localbufsize) char *localbuf, + char *localbuf, int localbufsize ); @@ -87,14 +87,13 @@ static struct rerr { */ /* ARGSUSED */ size_t -llvm_regerror(int errcode, const llvm_regex_t *preg, _Out_writes_all_(errbuf_size) char *errbuf, size_t errbuf_size) +llvm_regerror(int errcode, const llvm_regex_t *preg, char *errbuf, size_t errbuf_size) { struct rerr *r; size_t len; int target = errcode &~ REG_ITOA; const char *s; char convbuf[50]; - _Analysis_assume_nullterminated_(convbuf); if (errcode == REG_ATOI) s = regatoi(preg, convbuf, sizeof convbuf); @@ -136,7 +135,7 @@ llvm_regerror(int errcode, const llvm_regex_t *preg, _Out_writes_all_(errbuf_siz static const char * regatoi( const llvm_regex_t *preg, - _Out_writes_all_(localbufsize) char *localbuf, + char *localbuf, int localbufsize) { struct rerr *r; diff --git a/lib/Support/regex_impl.h b/lib/Support/regex_impl.h index 1b05eaad1f..0c669ecf66 100644 --- a/lib/Support/regex_impl.h +++ b/lib/Support/regex_impl.h @@ -107,12 +107,12 @@ void llvm_regfree(llvm_regex_t *); size_t llvm_regerror( int errcode, const llvm_regex_t *preg, - _Out_writes_all_(errbuf_size) char *errbuf, + char *errbuf, size_t errbuf_size); size_t llvm_strlcpy( - _Out_writes_z_(siz) char *dst, - _In_z_ const char *src, + char *dst, + const char *src, size_t siz); #ifdef __cplusplus diff --git a/lib/Support/regexec.c b/lib/Support/regexec.c index b161f056e5..bae0bda68d 100644 --- a/lib/Support/regexec.c +++ b/lib/Support/regexec.c @@ -78,7 +78,6 @@ #define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0) /* function names */ #define SNAMES /* engine.inc looks after details */ -#define _states_param_ /* define to nothing when not a pointer */ #include "regengine.inc" /* now undo things */ @@ -101,7 +100,6 @@ #undef BACK #undef ISSETBACK #undef SNAMES -#undef _states_param_ /* macros for manipulating states, large version */ #define states char * @@ -130,7 +128,6 @@ #define ISSETBACK(v, n) ((v)[here - (n)]) /* function names */ #define LNAMES /* flag */ -#define _states_param_ __inexpressible_readableTo(stopmarker) #include "regengine.inc" diff --git a/lib/Support/regstrlcpy.c b/lib/Support/regstrlcpy.c index 570624d9ba..e29aa9e847 100644 --- a/lib/Support/regstrlcpy.c +++ b/lib/Support/regstrlcpy.c @@ -25,7 +25,7 @@ * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ -_Use_decl_annotations_ + size_t llvm_strlcpy(char *dst, const char *src, size_t siz) { diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index f0fcbfb79d..507e271051 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1646,8 +1646,7 @@ void FunctionStackPoisoner::poisonRedZones(ArrayRef ShadowBytes, // Fake stack allocator (asan_fake_stack.h) has 11 size classes // for every power of 2 from kMinStackMallocSize to kMaxAsanStackMallocSizeClass -_Ret_range_(0, kMaxAsanStackMallocSizeClass) -static int StackMallocSizeClass(_In_range_(0, kMaxAsanStackMallocSizeClass) uint64_t LocalStackSize) { +static int StackMallocSizeClass(uint64_t LocalStackSize) { assert(LocalStackSize <= kMaxStackMallocSize); uint64_t MaxSize = kMinStackMallocSize; for (int i = 0;; i++, MaxSize *= 2) diff --git a/projects/dxilconv/include/ShaderBinary/ShaderBinary.h b/projects/dxilconv/include/ShaderBinary/ShaderBinary.h index f690d1dcf8..33b8c47f9d 100644 --- a/projects/dxilconv/include/ShaderBinary/ShaderBinary.h +++ b/projects/dxilconv/include/ShaderBinary/ShaderBinary.h @@ -2422,7 +2422,8 @@ class CShaderAsm { Reserve(FullSizeInUINTs); } - __analysis_assume(m_Index + FullSizeInUINTs < m_BufferSize); // Otherwise there's a bug in Reserve() + assert(m_Index + FullSizeInUINTs < + m_BufferSize); // Otherwise there's a bug in Reserve() m_dwFunc[m_Index++] = ENCODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataClass); m_dwFunc[m_Index++] = FullSizeInUINTs; memcpy(&m_dwFunc[m_Index],pCustomData,sizeof(UINT)*SizeInUINTs); @@ -2469,8 +2470,8 @@ class CShaderAsm } if( bExtendedLength ) { - __analysis_assume(m_StartOpIndex + 1 < m_Index); - m_dwFunc[m_StartOpIndex + 1] = m_Index - m_StartOpIndex; + assert(m_StartOpIndex + 1 < m_Index); + m_dwFunc[m_StartOpIndex + 1] = m_Index - m_StartOpIndex; } Reserve(MAX_INSTRUCTION_LENGTH); m_StatementIndex++; diff --git a/projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp b/projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp index 21a056fd6a..47f529fef3 100644 --- a/projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp +++ b/projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp @@ -22,91 +22,85 @@ namespace hlsl { -__override HRESULT STDMETHODCALLTYPE DxbcConverter::Convert(_In_reads_bytes_(DxbcSize) LPCVOID pDxbc, - _In_ UINT32 DxbcSize, - _In_opt_z_ LPCWSTR pExtraOptions, - _Outptr_result_bytebuffer_maybenull_(*pDxilSize) LPVOID *ppDxil, - _Out_ UINT32 *pDxilSize, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag) { - DxcThreadMalloc TM(m_pMalloc); - LARGE_INTEGER start, end; - QueryPerformanceCounter(&start); - DxcRuntimeEtw_DxcTranslate_Start(); - HRESULT hr = S_OK; - try { - sys::fs::MSFileSystem *pFSPtr; - IFT(CreateMSFileSystemForDisk(&pFSPtr)); - unique_ptr pFS(pFSPtr); - sys::fs::AutoPerThreadSystem pTS(pFS.get()); - IFTLLVM(pTS.error_code()); - - struct StdErrFlusher { - ~StdErrFlusher() { dbgs().flush(); } - } S; - - ConvertImpl(pDxbc, DxbcSize, pExtraOptions, ppDxil, pDxilSize, ppDiag); - - DxcRuntimeEtw_DxcTranslate_TranslateStats(DxbcSize, DxbcSize, (const BYTE *)pDxbc, *pDxilSize); - hr = S_OK; - } - CATCH_CPP_ASSIGN_HRESULT(); - DxcRuntimeEtw_DxcTranslate_Stop(hr); - QueryPerformanceCounter(&end); - LogConvertResult(false, &start, &end, pDxbc, DxbcSize, pExtraOptions, *ppDxil, *pDxilSize, hr); - return hr; +__override HRESULT STDMETHODCALLTYPE +DxbcConverter::Convert(LPCVOID pDxbc, UINT32 DxbcSize, LPCWSTR pExtraOptions, + LPVOID *ppDxil, UINT32 *pDxilSize, LPWSTR *ppDiag) { + DxcThreadMalloc TM(m_pMalloc); + LARGE_INTEGER start, end; + QueryPerformanceCounter(&start); + DxcRuntimeEtw_DxcTranslate_Start(); + HRESULT hr = S_OK; + try { + sys::fs::MSFileSystem *pFSPtr; + IFT(CreateMSFileSystemForDisk(&pFSPtr)); + unique_ptr pFS(pFSPtr); + sys::fs::AutoPerThreadSystem pTS(pFS.get()); + IFTLLVM(pTS.error_code()); + + struct StdErrFlusher { + ~StdErrFlusher() { dbgs().flush(); } + } S; + + ConvertImpl(pDxbc, DxbcSize, pExtraOptions, ppDxil, pDxilSize, ppDiag); + + DxcRuntimeEtw_DxcTranslate_TranslateStats(DxbcSize, DxbcSize, + (const BYTE *)pDxbc, *pDxilSize); + hr = S_OK; + } + CATCH_CPP_ASSIGN_HRESULT(); + DxcRuntimeEtw_DxcTranslate_Stop(hr); + QueryPerformanceCounter(&end); + LogConvertResult(false, &start, &end, pDxbc, DxbcSize, pExtraOptions, *ppDxil, + *pDxilSize, hr); + return hr; } -__override HRESULT STDMETHODCALLTYPE DxbcConverter::ConvertInDriver(_In_reads_bytes_(8) const UINT32 *pBytecode, - _In_opt_z_ LPCVOID pInputSignature, - _In_ UINT32 NumInputSignatureElements, - _In_opt_z_ LPCVOID pOutputSignature, - _In_ UINT32 NumOutputSignatureElements, - _In_opt_z_ LPCVOID pPatchConstantSignature, - _In_ UINT32 NumPatchConstantSignatureElements, - _In_opt_z_ LPCWSTR pExtraOptions, - _Out_ IDxcBlob **ppDxilModule, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag) { - DxcThreadMalloc TM(m_pMalloc); - LARGE_INTEGER start, end; - QueryPerformanceCounter(&start); - DxcRuntimeEtw_DxcTranslate_Start(); - HRESULT hr = S_OK; - UINT32 bcSize = pBytecode[1] * sizeof(UINT32); - const BYTE *pDxilBytes = nullptr; - UINT32 DxilByteCount = 0; - try { - sys::fs::MSFileSystem *pFSPtr; - IFT(CreateMSFileSystemForDisk(&pFSPtr)); - unique_ptr pFS(pFSPtr); - sys::fs::AutoPerThreadSystem pTS(pFS.get()); - IFTLLVM(pTS.error_code()); - - struct StdErrFlusher { - ~StdErrFlusher() { dbgs().flush(); } - } S; - - ConvertInDriverImpl(pBytecode, - (const D3D12DDIARG_SIGNATURE_ENTRY_0012 *)pInputSignature, - NumInputSignatureElements, - (const D3D12DDIARG_SIGNATURE_ENTRY_0012 *)pOutputSignature, - NumOutputSignatureElements, - (const D3D12DDIARG_SIGNATURE_ENTRY_0012 *)pPatchConstantSignature, - NumPatchConstantSignatureElements, - pExtraOptions, - ppDxilModule, - ppDiag); - - pDxilBytes = (const BYTE *)(*ppDxilModule)->GetBufferPointer(); - DxilByteCount = (*ppDxilModule)->GetBufferSize(); - DxcRuntimeEtw_DxcTranslate_TranslateStats(bcSize, bcSize, (const BYTE *)pBytecode, DxilByteCount); - - hr = S_OK; - } - CATCH_CPP_ASSIGN_HRESULT(); - DxcRuntimeEtw_DxcTranslate_Stop(hr); - QueryPerformanceCounter(&end); - LogConvertResult(true, &start, &end, pBytecode, bcSize, pExtraOptions, pDxilBytes, DxilByteCount, hr); - return hr; +__override HRESULT STDMETHODCALLTYPE DxbcConverter::ConvertInDriver( + const UINT32 *pBytecode, LPCVOID pInputSignature, + UINT32 NumInputSignatureElements, LPCVOID pOutputSignature, + UINT32 NumOutputSignatureElements, LPCVOID pPatchConstantSignature, + UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions, + IDxcBlob **ppDxilModule, LPWSTR *ppDiag) { + DxcThreadMalloc TM(m_pMalloc); + LARGE_INTEGER start, end; + QueryPerformanceCounter(&start); + DxcRuntimeEtw_DxcTranslate_Start(); + HRESULT hr = S_OK; + UINT32 bcSize = pBytecode[1] * sizeof(UINT32); + const BYTE *pDxilBytes = nullptr; + UINT32 DxilByteCount = 0; + try { + sys::fs::MSFileSystem *pFSPtr; + IFT(CreateMSFileSystemForDisk(&pFSPtr)); + unique_ptr pFS(pFSPtr); + sys::fs::AutoPerThreadSystem pTS(pFS.get()); + IFTLLVM(pTS.error_code()); + + struct StdErrFlusher { + ~StdErrFlusher() { dbgs().flush(); } + } S; + + ConvertInDriverImpl( + pBytecode, (const D3D12DDIARG_SIGNATURE_ENTRY_0012 *)pInputSignature, + NumInputSignatureElements, + (const D3D12DDIARG_SIGNATURE_ENTRY_0012 *)pOutputSignature, + NumOutputSignatureElements, + (const D3D12DDIARG_SIGNATURE_ENTRY_0012 *)pPatchConstantSignature, + NumPatchConstantSignatureElements, pExtraOptions, ppDxilModule, ppDiag); + + pDxilBytes = (const BYTE *)(*ppDxilModule)->GetBufferPointer(); + DxilByteCount = (*ppDxilModule)->GetBufferSize(); + DxcRuntimeEtw_DxcTranslate_TranslateStats( + bcSize, bcSize, (const BYTE *)pBytecode, DxilByteCount); + + hr = S_OK; + } + CATCH_CPP_ASSIGN_HRESULT(); + DxcRuntimeEtw_DxcTranslate_Stop(hr); + QueryPerformanceCounter(&end); + LogConvertResult(true, &start, &end, pBytecode, bcSize, pExtraOptions, + pDxilBytes, DxilByteCount, hr); + return hr; } DxbcConverter::DxbcConverter() @@ -161,12 +155,9 @@ void WritePart(AbstractMemoryStream *pStream, const SmallVectorImpl &Data) WritePart(pStream, Data.data(), Data.size()); } -void DxbcConverter::ConvertImpl(_In_reads_bytes_(DxbcSize) LPCVOID pDxbc, - _In_ UINT32 DxbcSize, - _In_opt_z_ LPCWSTR pExtraOptions, - _Outptr_result_bytebuffer_maybenull_(*pDxilSize) LPVOID *ppDxil, - _Out_ UINT32 *pDxilSize, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag) { +void DxbcConverter::ConvertImpl(LPCVOID pDxbc, UINT32 DxbcSize, + LPCWSTR pExtraOptions, LPVOID *ppDxil, + UINT32 *pDxilSize, LPWSTR *ppDiag) { IFTARG(pDxbc); IFTARG(ppDxil); IFTARG(pDxilSize); @@ -346,16 +337,15 @@ void DxbcConverter::ConvertImpl(_In_reads_bytes_(DxbcSize) LPCVOID pDxbc, *ppDiag = nullptr; } -void DxbcConverter::ConvertInDriverImpl(_In_reads_bytes_(8) const UINT32 *pByteCode, - _In_opt_z_ const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pInputSignature, - _In_ UINT32 NumInputSignatureElements, - _In_opt_z_ const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pOutputSignature, - _In_ UINT32 NumOutputSignatureElements, - _In_opt_z_ const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pPatchConstantSignature, - _In_ UINT32 NumPatchConstantSignatureElements, - _In_opt_z_ LPCWSTR pExtraOptions, - _Out_ IDxcBlob **ppDxcBlob, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag) { +void DxbcConverter::ConvertInDriverImpl( + const UINT32 *pByteCode, + const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pInputSignature, + UINT32 NumInputSignatureElements, + const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pOutputSignature, + UINT32 NumOutputSignatureElements, + const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pPatchConstantSignature, + UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions, + IDxcBlob **ppDxcBlob, LPWSTR *ppDiag) { IFTARG(pByteCode); IFTARG(ppDxcBlob); UINT SizeInUINTs = pByteCode[1]; @@ -4514,10 +4504,12 @@ void DxbcConverter::ConvertInstructions(D3D10ShaderBinary::CShaderCodeParser &Pa CleanupGEP(); } -void DxbcConverter::LogConvertResult(bool InDriver, _In_ const LARGE_INTEGER *pQPCConvertStart, - _In_ const LARGE_INTEGER *pQPCConvertEnd, _In_reads_bytes_(DxbcSize) LPCVOID pDxbc, _In_ UINT32 DxbcSize, - _In_opt_z_ LPCWSTR pExtraOptions, _In_reads_bytes_(ConvertedSize) LPCVOID pConverted, _In_opt_ UINT32 ConvertedSize, - HRESULT hr) { +void DxbcConverter::LogConvertResult(bool InDriver, + const LARGE_INTEGER *pQPCConvertStart, + const LARGE_INTEGER *pQPCConvertEnd, + LPCVOID pDxbc, UINT32 DxbcSize, + LPCWSTR pExtraOptions, LPCVOID pConverted, + UINT32 ConvertedSize, HRESULT hr) { // intentionaly empty - override to report conversion results } @@ -7362,7 +7354,7 @@ void DxbcConverter::SerializeDxil(SmallVectorImpl &DxilBitcode) { } // namespace hlsl -HRESULT CreateDxbcConverter(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxbcConverter(REFIID riid, LPVOID *ppv) { try { CComPtr result(hlsl::DxbcConverter::Alloc(DxcGetThreadMallocNoRef())); IFROOM(result.p); @@ -7370,5 +7362,3 @@ HRESULT CreateDxbcConverter(_In_ REFIID riid, _Out_ LPVOID *ppv) { } CATCH_CPP_RETURN_HRESULT(); } - - diff --git a/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h b/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h index 5855942856..7aea128478 100644 --- a/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h +++ b/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h @@ -283,23 +283,18 @@ class DxbcConverter : public IDxbcConverter { ~DxbcConverter(); - __override HRESULT STDMETHODCALLTYPE Convert(_In_reads_bytes_(DxbcSize) LPCVOID pDxbc, - _In_ UINT32 DxbcSize, - _In_opt_z_ LPCWSTR pExtraOptions, - _Outptr_result_bytebuffer_maybenull_(*pDxilSize) LPVOID *ppDxil, - _Out_ UINT32 *pDxilSize, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag); - - __override HRESULT STDMETHODCALLTYPE ConvertInDriver(_In_reads_bytes_(8) const UINT32 *pBytecode, - _In_opt_z_ LPCVOID pInputSignature, - _In_ UINT32 NumInputSignatureElements, - _In_opt_z_ LPCVOID pOutputSignature, - _In_ UINT32 NumOutputSignatureElements, - _In_opt_z_ LPCVOID pPatchConstantSignature, - _In_ UINT32 NumPatchConstantSignatureElements, - _In_opt_z_ LPCWSTR pExtraOptions, - _Out_ IDxcBlob **ppDxilModule, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag); + __override HRESULT STDMETHODCALLTYPE Convert(LPCVOID pDxbc, UINT32 DxbcSize, + LPCWSTR pExtraOptions, + LPVOID *ppDxil, + UINT32 *pDxilSize, + LPWSTR *ppDiag); + + __override HRESULT STDMETHODCALLTYPE ConvertInDriver( + const UINT32 *pBytecode, LPCVOID pInputSignature, + UINT32 NumInputSignatureElements, LPCVOID pOutputSignature, + UINT32 NumOutputSignatureElements, LPCVOID pPatchConstantSignature, + UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions, + IDxcBlob **ppDxilModule, LPWSTR *ppDiag); protected: LLVMContext m_Ctx; @@ -498,34 +493,26 @@ class DxbcConverter : public IDxbcConverter { unsigned m_FcallCount; protected: - virtual void ConvertImpl(_In_reads_bytes_(DxbcSize) LPCVOID pDxbc, - _In_ UINT32 DxbcSize, - _In_opt_z_ LPCWSTR pExtraOptions, - _Outptr_result_bytebuffer_maybenull_(*pDxilSize) LPVOID *ppDxil, - _Out_ UINT32 *pDxilSize, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag); - - virtual void ConvertInDriverImpl(_In_reads_bytes_(8) const UINT32 *pByteCode, - _In_opt_ const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pInputSignature, - _In_ UINT32 NumInputSignatureElements, - _In_opt_ const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pOutputSignature, - _In_ UINT32 NumOutputSignatureElements, - _In_opt_ const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pPatchConstantSignature, - _In_ UINT32 NumPatchConstantSignatureElements, - _In_opt_z_ LPCWSTR pExtraOptions, - _Out_ IDxcBlob **ppDxcBlob, - _Outptr_result_maybenull_z_ LPWSTR *ppDiag); + virtual void ConvertImpl(LPCVOID pDxbc, UINT32 DxbcSize, + LPCWSTR pExtraOptions, LPVOID *ppDxil, + UINT32 *pDxilSize, LPWSTR *ppDiag); + + virtual void ConvertInDriverImpl( + const UINT32 *pByteCode, + const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pInputSignature, + UINT32 NumInputSignatureElements, + const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pOutputSignature, + UINT32 NumOutputSignatureElements, + const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pPatchConstantSignature, + UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions, + IDxcBlob **ppDxcBlob, LPWSTR *ppDiag); virtual void LogConvertResult(bool InDriver, - _In_ const LARGE_INTEGER *pQPCConvertStart, - _In_ const LARGE_INTEGER *pQPCConvertEnd, - _In_reads_bytes_(DxbcSize) LPCVOID pDxbc, - _In_ UINT32 DxbcSize, - _In_opt_z_ LPCWSTR pExtraOptions, - _In_reads_bytes_(ConvertedSize) LPCVOID pConverted, - _In_opt_ UINT32 ConvertedSize, - HRESULT hr); - + const LARGE_INTEGER *pQPCConvertStart, + const LARGE_INTEGER *pQPCConvertEnd, + LPCVOID pDxbc, UINT32 DxbcSize, + LPCWSTR pExtraOptions, LPCVOID pConverted, + UINT32 ConvertedSize, HRESULT hr); // Callbacks added to support conversion of custom intrinsics. virtual HRESULT PreConvertHook(const CShaderToken *pByteCode); diff --git a/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h b/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h index 2d3098eba7..47f1664798 100644 --- a/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h +++ b/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h @@ -24,4 +24,8 @@ #include "ShaderBinary/ShaderBinary.h" // clang-format on -#define ASSUME( _exp ) { assert( _exp ); __analysis_assume( _exp ); __assume( _exp ); } +#define ASSUME(_exp) \ + { \ + assert(_exp); \ + __assume(_exp); \ + } diff --git a/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp b/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp index cfda8bd08c..c7ffd878c9 100644 --- a/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp +++ b/projects/dxilconv/tools/dxbc2dxil/dxbc2dxil.cpp @@ -44,7 +44,7 @@ class Converter { public: Converter(); static void PrintUsage(); - void ParseCommandLine(int NumArgs, _In_z_count_(NumArgs + 1) wchar_t **ppArgs); + void ParseCommandLine(int NumArgs, wchar_t **ppArgs); static void CmdLineError(const wchar_t *pFormat, ...); void Run(); @@ -61,9 +61,9 @@ class Converter { DxcCreateInstanceProc m_pfnDXCompiler_DxcCreateInstance; DxcCreateInstanceProc m_pfnDxilConv_DxcCreateInstance; - HRESULT CreateDxcLibrary(_Outptr_ IDxcLibrary **ppLibrary); - HRESULT CreateDxcCompiler(_Outptr_ IDxcCompiler **ppCompiler); - HRESULT CreateDxbcConverter(_Outptr_ IDxbcConverter **ppConverter); + HRESULT CreateDxcLibrary(IDxcLibrary **ppLibrary); + HRESULT CreateDxcCompiler(IDxcCompiler **ppCompiler); + HRESULT CreateDxbcConverter(IDxbcConverter **ppConverter); HRESULT GetDxcCreateInstance(LPCWSTR dllFileName, DxcCreateInstanceProc *ppFn); static bool CheckOption(const wchar_t *pStr, const wchar_t *pOption); @@ -100,7 +100,7 @@ bool Converter::CheckOption(const wchar_t *pStr, const wchar_t *pOption) { return _wcsicmp(&pStr[1], pOption) == 0; } -void Converter::ParseCommandLine(int NumArgs, _In_z_count_(NumArgs + 1) wchar_t **ppArgs) { +void Converter::ParseCommandLine(int NumArgs, wchar_t **ppArgs) { try { bool bSeenHelp = false; bool bSeenInputFile = false; @@ -184,7 +184,7 @@ void Converter::CmdLineError(const wchar_t *pFormat, ...) { // idx is the number of characters written, not including the terminating // null character, or a negative value if an output error occurs if (idx < 0) idx = 0; - _Analysis_assume_(0 <= idx && idx <= kBufSize); + assert(0 <= idx && idx <= kBufSize); buf[idx] = L'\0'; throw wstring(buf); @@ -294,7 +294,7 @@ void Converter::Run() { IFT(hlsl::WriteBinaryFile(m_OutputFile.c_str(), pOutput, OutputSize)); } -HRESULT Converter::CreateDxcLibrary(_Outptr_ IDxcLibrary **ppLibrary) { +HRESULT Converter::CreateDxcLibrary(IDxcLibrary **ppLibrary) { if (m_pfnDXCompiler_DxcCreateInstance == nullptr) { IFR(GetDxcCreateInstance(L"dxcompiler.dll", &m_pfnDXCompiler_DxcCreateInstance)); } @@ -302,7 +302,7 @@ HRESULT Converter::CreateDxcLibrary(_Outptr_ IDxcLibrary **ppLibrary) { return S_OK; } -HRESULT Converter::CreateDxcCompiler(_Outptr_ IDxcCompiler **ppCompiler) { +HRESULT Converter::CreateDxcCompiler(IDxcCompiler **ppCompiler) { if (m_pfnDXCompiler_DxcCreateInstance == nullptr) { IFR(GetDxcCreateInstance(L"dxcompiler.dll", &m_pfnDXCompiler_DxcCreateInstance)); } @@ -310,7 +310,7 @@ HRESULT Converter::CreateDxcCompiler(_Outptr_ IDxcCompiler **ppCompiler) { return S_OK; } -HRESULT Converter::CreateDxbcConverter(_Outptr_ IDxbcConverter **ppConverter) { +HRESULT Converter::CreateDxbcConverter(IDxbcConverter **ppConverter) { if (m_pfnDxilConv_DxcCreateInstance == nullptr) { IFR(GetDxcCreateInstance(L"dxilconv.dll", &m_pfnDxilConv_DxcCreateInstance)); } @@ -333,7 +333,7 @@ HRESULT Converter::GetDxcCreateInstance(LPCWSTR dllFileName, DxcCreateInstancePr return S_OK; } -int __cdecl wmain(int argc, _In_z_count_(argc + 1) wchar_t **argv) { +int __cdecl wmain(int argc, wchar_t **argv) { llvm_shutdown_obj Y; try { diff --git a/projects/dxilconv/tools/dxilconv/dxilconv.cpp b/projects/dxilconv/tools/dxilconv/dxilconv.cpp index 5134c7953b..bf8e2884d7 100644 --- a/projects/dxilconv/tools/dxilconv/dxilconv.cpp +++ b/projects/dxilconv/tools/dxilconv/dxilconv.cpp @@ -28,7 +28,7 @@ #include "DxbcConverter.h" // Defined in DxbcConverter.lib (projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp) -HRESULT CreateDxbcConverter(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxbcConverter(REFIID riid, LPVOID *ppv); /// /// Creates a single uninitialized object of the class associated with a specified CLSID. @@ -39,37 +39,31 @@ HRESULT CreateDxbcConverter(_In_ REFIID riid, _Out_ LPVOID *ppv); /// /// While this function is similar to CoCreateInstance, there is no COM involvement. /// -static HRESULT ThreadMallocDxcCreateInstance( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { - *ppv = nullptr; - if (IsEqualCLSID(rclsid, CLSID_DxbcConverter)) { - return CreateDxbcConverter(riid, ppv); - } - return REGDB_E_CLASSNOTREG; +static HRESULT ThreadMallocDxcCreateInstance(REFCLSID rclsid, REFIID riid, + LPVOID *ppv) { + *ppv = nullptr; + if (IsEqualCLSID(rclsid, CLSID_DxbcConverter)) { + return CreateDxbcConverter(riid, ppv); + } + return REGDB_E_CLASSNOTREG; } -DXC_API_IMPORT HRESULT __stdcall -DxcCreateInstance(_In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { - HRESULT hr = S_OK; - DxcEtw_DXCompilerCreateInstance_Start(); - DxcThreadMalloc TM(nullptr); - hr = ThreadMallocDxcCreateInstance(rclsid, riid, ppv); - DxcEtw_DXCompilerCreateInstance_Stop(hr); - return hr; +DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance(REFCLSID rclsid, REFIID riid, + LPVOID *ppv) { + HRESULT hr = S_OK; + DxcEtw_DXCompilerCreateInstance_Start(); + DxcThreadMalloc TM(nullptr); + hr = ThreadMallocDxcCreateInstance(rclsid, riid, ppv); + DxcEtw_DXCompilerCreateInstance_Stop(hr); + return hr; } -DXC_API_IMPORT HRESULT __stdcall -DxcCreateInstance2(_In_ IMalloc *pMalloc, - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { - if (ppv == nullptr) { - return E_POINTER; - } +DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2(IMalloc *pMalloc, + REFCLSID rclsid, + REFIID riid, LPVOID *ppv) { + if (ppv == nullptr) { + return E_POINTER; + } #ifdef DXC_DISABLE_ALLOCATOR_OVERRIDES if (pMalloc != DxcGetThreadMallocNoRef()) { return E_INVALIDARG; @@ -84,7 +78,6 @@ DxcCreateInstance2(_In_ IMalloc *pMalloc, return hr; } - // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) static HRESULT InitMaybeFail() throw() { HRESULT hr; diff --git a/tools/clang/include/clang/AST/HlslTypes.h b/tools/clang/include/clang/AST/HlslTypes.h index a7b5160b49..9c1100a9fa 100644 --- a/tools/clang/include/clang/AST/HlslTypes.h +++ b/tools/clang/include/clang/AST/HlslTypes.h @@ -115,8 +115,7 @@ struct MatrixMemberAccessPositions { (R3_Row == R2_Row && R3_Col == R2_Col))) ); } - void GetPosition(uint32_t index, _Out_ uint32_t* row, _Out_ uint32_t* col) const - { + void GetPosition(uint32_t index, uint32_t *row, uint32_t *col) const { assert(index < 4); switch (index) { @@ -166,8 +165,7 @@ struct VectorMemberAccessPositions { (Swz3 == Swz2))) ); } - void GetPosition(uint32_t index, _Out_ uint32_t* col) const - { + void GetPosition(uint32_t index, uint32_t *col) const { assert(index < 4); switch (index) { @@ -300,20 +298,17 @@ struct SemanticDecl : public UnusualAnnotation }; /// Returns a ParameterModifier initialized as per the attribute list. -ParameterModifier -ParamModFromAttributeList(_In_opt_ clang::AttributeList *pAttributes); +ParameterModifier ParamModFromAttributeList(clang::AttributeList *pAttributes); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // AST manipulation functions. -void AddHLSLMatrixTemplate( - clang::ASTContext& context, - _In_ clang::ClassTemplateDecl* vectorTemplateDecl, - _Outptr_ clang::ClassTemplateDecl** matrixTemplateDecl); +void AddHLSLMatrixTemplate(clang::ASTContext &context, + clang::ClassTemplateDecl *vectorTemplateDecl, + clang::ClassTemplateDecl **matrixTemplateDecl); -void AddHLSLVectorTemplate( - clang::ASTContext& context, - _Outptr_ clang::ClassTemplateDecl** vectorTemplateDecl); +void AddHLSLVectorTemplate(clang::ASTContext &context, + clang::ClassTemplateDecl **vectorTemplateDecl); clang::CXXRecordDecl* DeclareRecordTypeWithHandle( clang::ASTContext& context, llvm::StringRef name); @@ -330,18 +325,15 @@ void AddStdIsEqualImplementation(clang::ASTContext& context, clang::Sema& sema); /// AST context to which template will be added. /// Number of template arguments (one or two). /// If assigned, the default argument for the element template. -clang::CXXRecordDecl* DeclareTemplateTypeWithHandle( - clang::ASTContext& context, - llvm::StringRef name, - uint8_t templateArgCount, - _In_opt_ clang::TypeSourceInfo* defaultTypeArgValue); - -clang::CXXRecordDecl* DeclareTemplateTypeWithHandleInDeclContext( - clang::ASTContext& context, - clang::DeclContext *declContext, - llvm::StringRef name, - uint8_t templateArgCount, - _In_opt_ clang::TypeSourceInfo* defaultTypeArgValue); +clang::CXXRecordDecl * +DeclareTemplateTypeWithHandle(clang::ASTContext &context, llvm::StringRef name, + uint8_t templateArgCount, + clang::TypeSourceInfo *defaultTypeArgValue); + +clang::CXXRecordDecl *DeclareTemplateTypeWithHandleInDeclContext( + clang::ASTContext &context, clang::DeclContext *declContext, + llvm::StringRef name, uint8_t templateArgCount, + clang::TypeSourceInfo *defaultTypeArgValue); clang::CXXRecordDecl* DeclareUIntTemplatedTypeWithHandle( clang::ASTContext& context, llvm::StringRef typeName, llvm::StringRef templateParamName); @@ -362,12 +354,12 @@ clang::VarDecl *DeclareBuiltinGlobal(llvm::StringRef name, clang::QualType Ty, /// Declarations for templates to the function. /// Count of template declarations. /// A new function template declaration already declared in the class scope. -clang::FunctionTemplateDecl* CreateFunctionTemplateDecl( - clang::ASTContext& context, - _In_ clang::CXXRecordDecl* recordDecl, - _In_ clang::CXXMethodDecl* functionDecl, - _In_count_(templateParamNamedDeclsCount) clang::NamedDecl** templateParamNamedDecls, - size_t templateParamNamedDeclsCount); +clang::FunctionTemplateDecl * +CreateFunctionTemplateDecl(clang::ASTContext &context, + clang::CXXRecordDecl *recordDecl, + clang::CXXMethodDecl *functionDecl, + clang::NamedDecl **templateParamNamedDecls, + size_t templateParamNamedDeclsCount); clang::TypedefDecl* CreateMatrixSpecializationShorthand( clang::ASTContext& context, @@ -458,71 +450,39 @@ bool IsPatchConstantFunctionDecl(const clang::FunctionDecl *FD); /// Name for function. /// Whether the function is a const function. /// The method declaration for the function. -clang::CXXMethodDecl* CreateObjectFunctionDeclarationWithParams( - clang::ASTContext& context, - _In_ clang::CXXRecordDecl* recordDecl, - clang::QualType resultType, - llvm::ArrayRef paramTypes, - llvm::ArrayRef paramNames, - clang::DeclarationName declarationName, - bool isConst, - bool isTemplateFunction = false); +clang::CXXMethodDecl *CreateObjectFunctionDeclarationWithParams( + clang::ASTContext &context, clang::CXXRecordDecl *recordDecl, + clang::QualType resultType, llvm::ArrayRef paramTypes, + llvm::ArrayRef paramNames, + clang::DeclarationName declarationName, bool isConst, + bool isTemplateFunction = false); DXIL::ResourceClass GetResourceClassForType(const clang::ASTContext &context, clang::QualType Ty); -_Success_(return != false) -bool TryParseMatrixShorthand( - _In_count_(typeNameLen) - const char* typeName, - size_t typeNameLen, - _Out_ HLSLScalarType* parsedType, - _Out_ int* rowCount, - _Out_ int* colCount, - _In_ const clang::LangOptions& langOption); - -_Success_(return != false) -bool TryParseVectorShorthand( - _In_count_(typeNameLen) - const char* typeName, - size_t typeNameLen, - _Out_ HLSLScalarType* parsedType, - _Out_ int* elementCount, - _In_ const clang::LangOptions& langOption); - -_Success_(return != false) -bool TryParseScalar( - _In_count_(typenameLen) - const char* typeName, - size_t typeNameLen, - _Out_ HLSLScalarType *parsedType, - _In_ const clang::LangOptions& langOption); - -_Success_(return != false) -bool TryParseAny( - _In_count_(typenameLen) - const char* typeName, - size_t typeNameLen, - _Out_ HLSLScalarType *parsedType, - _Out_ int *rowCount, - _Out_ int *colCount, - _In_ const clang::LangOptions& langOption); - -_Success_(return != false) -bool TryParseString( - _In_count_(typenameLen) - const char* typeName, - size_t typeNameLen, - _In_ const clang::LangOptions& langOptions); - -_Success_(return != false) -bool TryParseMatrixOrVectorDimension( - _In_count_(typeNameLen) - const char *typeName, - size_t typeNameLen, - _Out_opt_ int *rowCount, - _Out_opt_ int *colCount, - _In_ const clang::LangOptions& langOption); +bool TryParseMatrixShorthand(const char *typeName, size_t typeNameLen, + HLSLScalarType *parsedType, int *rowCount, + int *colCount, + const clang::LangOptions &langOption); + +bool TryParseVectorShorthand(const char *typeName, size_t typeNameLen, + HLSLScalarType *parsedType, int *elementCount, + const clang::LangOptions &langOption); + +bool TryParseScalar(const char *typeName, size_t typeNameLen, + HLSLScalarType *parsedType, + const clang::LangOptions &langOption); + +bool TryParseAny(const char *typeName, size_t typeNameLen, + HLSLScalarType *parsedType, int *rowCount, int *colCount, + const clang::LangOptions &langOption); + +bool TryParseString(const char *typeName, size_t typeNameLen, + const clang::LangOptions &langOptions); + +bool TryParseMatrixOrVectorDimension(const char *typeName, size_t typeNameLen, + int *rowCount, int *colCount, + const clang::LangOptions &langOption); } // end hlsl namespace #endif diff --git a/tools/clang/include/clang/Basic/Diagnostic.h b/tools/clang/include/clang/Basic/Diagnostic.h index cf56e3a720..dc9f781c09 100644 --- a/tools/clang/include/clang/Basic/Diagnostic.h +++ b/tools/clang/include/clang/Basic/Diagnostic.h @@ -988,7 +988,7 @@ class DiagnosticBuilder { assert(isActive() && "Clients must not add to cleared diagnostic!"); assert(NumArgs < DiagnosticsEngine::MaxArguments && "Too many arguments to diagnostic!"); - _Analysis_assume_(NumArgs < DiagnosticsEngine::MaxArguments); + assert(NumArgs < DiagnosticsEngine::MaxArguments); DiagObj->DiagArgumentsKind[NumArgs] = DiagnosticsEngine::ak_std_string; DiagObj->DiagArgumentsStr[NumArgs++] = S; } @@ -997,7 +997,7 @@ class DiagnosticBuilder { assert(isActive() && "Clients must not add to cleared diagnostic!"); assert(NumArgs < DiagnosticsEngine::MaxArguments && "Too many arguments to diagnostic!"); - _Analysis_assume_(NumArgs < DiagnosticsEngine::MaxArguments); + assert(NumArgs < DiagnosticsEngine::MaxArguments); DiagObj->DiagArgumentsKind[NumArgs] = Kind; DiagObj->DiagArgumentsVal[NumArgs++] = V; } diff --git a/tools/clang/include/clang/Basic/PartialDiagnostic.h b/tools/clang/include/clang/Basic/PartialDiagnostic.h index 6b6113b38a..f3d42cd267 100644 --- a/tools/clang/include/clang/Basic/PartialDiagnostic.h +++ b/tools/clang/include/clang/Basic/PartialDiagnostic.h @@ -270,7 +270,7 @@ class PartialDiagnostic { assert(DiagStorage->NumDiagArgs < Storage::MaxArguments && "Too many arguments to diagnostic!"); - _Analysis_assume_(DiagStorage->NumDiagArgs < Storage::MaxArguments); + assert(DiagStorage->NumDiagArgs < Storage::MaxArguments); DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = Kind; DiagStorage->DiagArgumentsVal[DiagStorage->NumDiagArgs++] = V; } @@ -281,7 +281,7 @@ class PartialDiagnostic { assert(DiagStorage->NumDiagArgs < Storage::MaxArguments && "Too many arguments to diagnostic!"); - _Analysis_assume_(DiagStorage->NumDiagArgs < Storage::MaxArguments); + assert(DiagStorage->NumDiagArgs < Storage::MaxArguments); DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = DiagnosticsEngine::ak_std_string; DiagStorage->DiagArgumentsStr[DiagStorage->NumDiagArgs++] = V; diff --git a/tools/clang/include/clang/Parse/ParseHLSL.h b/tools/clang/include/clang/Parse/ParseHLSL.h index 641982425e..8c232871c0 100644 --- a/tools/clang/include/clang/Parse/ParseHLSL.h +++ b/tools/clang/include/clang/Parse/ParseHLSL.h @@ -27,15 +27,15 @@ class RootSignatureHandle; namespace clang { class DiagnosticsEngine; -bool ParseHLSLRootSignature(_In_count_(Len) const char *pData, unsigned Len, +bool ParseHLSLRootSignature(const char *pData, unsigned Len, hlsl::DxilRootSignatureVersion Ver, hlsl::DxilRootSignatureCompilationFlags Flags, hlsl::DxilVersionedRootSignatureDesc **ppDesc, clang::SourceLocation Loc, clang::DiagnosticsEngine &Diags); void ReportHLSLRootSigError(clang::DiagnosticsEngine &Diags, - clang::SourceLocation Loc, - _In_count_(Len) const char *pData, unsigned Len); + clang::SourceLocation Loc, const char *pData, + unsigned Len); void CompileRootSignature(StringRef rootSigStr, DiagnosticsEngine &Diags, SourceLocation SLoc, hlsl::DxilRootSignatureVersion rootSigVer, diff --git a/tools/clang/include/clang/Sema/SemaHLSL.h b/tools/clang/include/clang/Sema/SemaHLSL.h index fd59038278..7cbc9e327f 100644 --- a/tools/clang/include/clang/Sema/SemaHLSL.h +++ b/tools/clang/include/clang/Sema/SemaHLSL.h @@ -112,30 +112,25 @@ bool ShouldSkipNRVO(clang::Sema &sema, clang::QualType returnType, clang::VarDec /// Annotated declaration. /// Single parsed attribute to process. /// After execution, whether this was recognized and handled. -void HandleDeclAttributeForHLSL( - clang::Sema &S, - _In_ clang::Decl *D, - const clang::AttributeList &Attr, - bool& Handled); - -void InitializeInitSequenceForHLSL( - clang::Sema* sema, - const clang::InitializedEntity& Entity, - const clang::InitializationKind& Kind, - clang::MultiExprArg Args, - bool TopLevelOfInitList, - _Inout_ clang::InitializationSequence* initSequence); - -unsigned CaculateInitListArraySizeForHLSL( - _In_ clang::Sema* sema, - _In_ const clang::InitListExpr *InitList, - _In_ const clang::QualType EltTy); - -bool IsConversionToLessOrEqualElements( - _In_ clang::Sema* self, - const clang::ExprResult& sourceExpr, - const clang::QualType& targetType, - bool explicitConversion); +void HandleDeclAttributeForHLSL(clang::Sema &S, clang::Decl *D, + const clang::AttributeList &Attr, + bool &Handled); + +void InitializeInitSequenceForHLSL(clang::Sema *sema, + const clang::InitializedEntity &Entity, + const clang::InitializationKind &Kind, + clang::MultiExprArg Args, + bool TopLevelOfInitList, + clang::InitializationSequence *initSequence); + +unsigned CaculateInitListArraySizeForHLSL(clang::Sema *sema, + const clang::InitListExpr *InitList, + const clang::QualType EltTy); + +bool IsConversionToLessOrEqualElements(clang::Sema *self, + const clang::ExprResult &sourceExpr, + const clang::QualType &targetType, + bool explicitConversion); clang::ExprResult LookupMatrixMemberExprForHLSL( clang::Sema* self, @@ -170,9 +165,7 @@ bool LookupRecordMemberExprForHLSL( clang::SourceLocation MemberLoc, clang::ExprResult &result); -clang::ExprResult MaybeConvertMemberAccess( - _In_ clang::Sema* Self, - _In_ clang::Expr* E); +clang::ExprResult MaybeConvertMemberAccess(clang::Sema *Self, clang::Expr *E); /// Performs the HLSL-specific type conversion steps. /// Sema with context. @@ -181,12 +174,11 @@ clang::ExprResult MaybeConvertMemberAccess( /// Standard conversion sequence from which Second and ComponentConversion will be used. /// Conversion kind. /// Expression result of conversion. -clang::ExprResult PerformHLSLConversion( - _In_ clang::Sema* self, - _In_ clang::Expr* E, - _In_ clang::QualType targetType, - _In_ const clang::StandardConversionSequence &SCS, - _In_ clang::Sema::CheckedConversionKind CCK); +clang::ExprResult +PerformHLSLConversion(clang::Sema *self, clang::Expr *E, + clang::QualType targetType, + const clang::StandardConversionSequence &SCS, + clang::Sema::CheckedConversionKind CCK); /// Processes an attribute for a statement. /// Sema with context. @@ -195,91 +187,67 @@ clang::ExprResult PerformHLSLConversion( /// Range of all attribute lists (useful for FixIts to suggest inclusions). /// After execution, whether this was recognized and handled. /// An attribute instance if processed, nullptr if not recognized or an error was found. -clang::Attr *ProcessStmtAttributeForHLSL( - clang::Sema &S, - _In_ clang::Stmt *St, - const clang::AttributeList &A, - clang::SourceRange Range, - bool& Handled); - -bool TryStaticCastForHLSL( - _In_ clang::Sema* Self, - clang::ExprResult &SrcExpr, - clang::QualType DestType, - clang::Sema::CheckedConversionKind CCK, - const clang::SourceRange &OpRange, - unsigned &msg, - clang::CastKind &Kind, - clang::CXXCastPath &BasePath, - bool ListInitialization, - bool SuppressDiagnostics, - _Inout_opt_ clang::StandardConversionSequence* standard); - -clang::ImplicitConversionSequence TrySubscriptIndexInitialization( - _In_ clang::Sema* Self, - _In_ clang::Expr* SrcExpr, - clang::QualType DestType); +clang::Attr *ProcessStmtAttributeForHLSL(clang::Sema &S, clang::Stmt *St, + const clang::AttributeList &A, + clang::SourceRange Range, + bool &Handled); + +bool TryStaticCastForHLSL(clang::Sema *Self, clang::ExprResult &SrcExpr, + clang::QualType DestType, + clang::Sema::CheckedConversionKind CCK, + const clang::SourceRange &OpRange, unsigned &msg, + clang::CastKind &Kind, clang::CXXCastPath &BasePath, + bool ListInitialization, bool SuppressDiagnostics, + clang::StandardConversionSequence *standard); + +clang::ImplicitConversionSequence +TrySubscriptIndexInitialization(clang::Sema *Self, clang::Expr *SrcExpr, + clang::QualType DestType); bool IsHLSLAttr(clang::attr::Kind AttrKind); void CustomPrintHLSLAttr(const clang::Attr *A, llvm::raw_ostream &Out, const clang::PrintingPolicy &Policy, unsigned int Indentation); void PrintClipPlaneIfPresent(clang::Expr *ClipPlane, llvm::raw_ostream &Out, const clang::PrintingPolicy &Policy); void Indent(unsigned int Indentation, llvm::raw_ostream &Out); -void GetHLSLAttributedTypes( - _In_ clang::Sema *self, clang::QualType type, - _Inout_opt_ const clang::AttributedType **ppMatrixOrientation, - _Inout_opt_ const clang::AttributedType **ppNorm, - _Inout_opt_ const clang::AttributedType **ppGLC); - -bool IsMatrixType( - _In_ clang::Sema* self, - _In_ clang::QualType type); -bool IsVectorType( - _In_ clang::Sema* self, - _In_ clang::QualType type); -clang::QualType GetOriginalMatrixOrVectorElementType( - _In_ clang::QualType type); -clang::QualType GetOriginalElementType( - _In_ clang::Sema* self, - _In_ clang::QualType type); - -bool IsObjectType( - _In_ clang::Sema* self, - _In_ clang::QualType type, - _Inout_opt_ bool *isDeprecatedEffectObject = nullptr); - -bool CanConvert( - _In_ clang::Sema* self, - clang::SourceLocation loc, - _In_ clang::Expr* sourceExpr, - clang::QualType target, - bool explicitConversion, - _Inout_opt_ clang::StandardConversionSequence* standard); +void GetHLSLAttributedTypes(clang::Sema *self, clang::QualType type, + const clang::AttributedType **ppMatrixOrientation, + const clang::AttributedType **ppNorm, + const clang::AttributedType **ppGLC); + +bool IsMatrixType(clang::Sema *self, clang::QualType type); +bool IsVectorType(clang::Sema *self, clang::QualType type); +clang::QualType GetOriginalMatrixOrVectorElementType(clang::QualType type); +clang::QualType GetOriginalElementType(clang::Sema *self, clang::QualType type); + +bool IsObjectType(clang::Sema *self, clang::QualType type, + bool *isDeprecatedEffectObject = nullptr); + +bool CanConvert(clang::Sema *self, clang::SourceLocation loc, + clang::Expr *sourceExpr, clang::QualType target, + bool explicitConversion, + clang::StandardConversionSequence *standard); // This function takes the external sema source rather than the sema object itself // because the wire-up doesn't happen until parsing is initialized and we want // to set this up earlier. If the HLSL constructs in the external sema move to // Sema itself, this can be invoked on the Sema object directly. -void RegisterIntrinsicTable(_In_ clang::ExternalSemaSource* self, IDxcIntrinsicTable* table); - -clang::QualType CheckVectorConditional( - _In_ clang::Sema* self, - _In_ clang::ExprResult &Cond, - _In_ clang::ExprResult &LHS, - _In_ clang::ExprResult &RHS, - _In_ clang::SourceLocation QuestionLoc); - +void RegisterIntrinsicTable(clang::ExternalSemaSource *self, + IDxcIntrinsicTable *table); + +clang::QualType CheckVectorConditional(clang::Sema *self, + clang::ExprResult &Cond, + clang::ExprResult &LHS, + clang::ExprResult &RHS, + clang::SourceLocation QuestionLoc); } -bool IsTypeNumeric(_In_ clang::Sema* self, _In_ clang::QualType &type); +bool IsTypeNumeric(clang::Sema *self, clang::QualType &type); bool IsExprAccessingOutIndicesArray(clang::Expr* BaseExpr); // This function reads the given declaration TSS and returns the corresponding parsedType with the // corresponding type. Replaces the given parsed type with the new type -clang::QualType ApplyTypeSpecSignToParsedType( - _In_ clang::Sema* self, - _In_ clang::QualType &type, - _In_ clang::TypeSpecifierSign TSS, - _In_ clang::SourceLocation Loc -); +clang::QualType ApplyTypeSpecSignToParsedType(clang::Sema *self, + clang::QualType &type, + clang::TypeSpecifierSign TSS, + clang::SourceLocation Loc); #endif diff --git a/tools/clang/lib/AST/ASTContextHLSL.cpp b/tools/clang/lib/AST/ASTContextHLSL.cpp index ce3ff38c30..93dea249fc 100644 --- a/tools/clang/lib/AST/ASTContextHLSL.cpp +++ b/tools/clang/lib/AST/ASTContextHLSL.cpp @@ -667,12 +667,10 @@ void hlsl::AddStdIsEqualImplementation(clang::ASTContext& context, clang::Sema& /// Name of template to create. /// Number of template arguments (one or two). /// If assigned, the default argument for the element template. -CXXRecordDecl* hlsl::DeclareTemplateTypeWithHandle( - ASTContext& context, - StringRef name, - uint8_t templateArgCount, - _In_opt_ TypeSourceInfo* defaultTypeArgValue) -{ +CXXRecordDecl * +hlsl::DeclareTemplateTypeWithHandle(ASTContext &context, StringRef name, + uint8_t templateArgCount, + TypeSourceInfo *defaultTypeArgValue) { return DeclareTemplateTypeWithHandleInDeclContext(context, context.getTranslationUnitDecl(), name, @@ -680,13 +678,9 @@ CXXRecordDecl* hlsl::DeclareTemplateTypeWithHandle( defaultTypeArgValue); } -CXXRecordDecl* hlsl::DeclareTemplateTypeWithHandleInDeclContext( - ASTContext& context, - DeclContext *declContext, - StringRef name, - uint8_t templateArgCount, - _In_opt_ TypeSourceInfo* defaultTypeArgValue) -{ +CXXRecordDecl *hlsl::DeclareTemplateTypeWithHandleInDeclContext( + ASTContext &context, DeclContext *declContext, StringRef name, + uint8_t templateArgCount, TypeSourceInfo *defaultTypeArgValue) { DXASSERT(templateArgCount != 0, "otherwise caller should be creating a class or struct"); DXASSERT(templateArgCount <= 2, "otherwise the function needs to be updated for a different template pattern"); @@ -735,13 +729,9 @@ CXXRecordDecl* hlsl::DeclareTemplateTypeWithHandleInDeclContext( return typeDeclBuilder.getRecordDecl(); } -FunctionTemplateDecl* hlsl::CreateFunctionTemplateDecl( - ASTContext& context, - _In_ CXXRecordDecl* recordDecl, - _In_ CXXMethodDecl* functionDecl, - _In_count_(templateParamNamedDeclsCount) NamedDecl** templateParamNamedDecls, - size_t templateParamNamedDeclsCount) -{ +FunctionTemplateDecl *hlsl::CreateFunctionTemplateDecl( + ASTContext &context, CXXRecordDecl *recordDecl, CXXMethodDecl *functionDecl, + NamedDecl **templateParamNamedDecls, size_t templateParamNamedDeclsCount) { DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(templateParamNamedDecls != nullptr); DXASSERT(templateParamNamedDeclsCount > 0, "otherwise caller shouldn't invoke this function"); @@ -758,12 +748,9 @@ FunctionTemplateDecl* hlsl::CreateFunctionTemplateDecl( return functionTemplate; } -static -void AssociateParametersToFunctionPrototype( - _In_ TypeSourceInfo* tinfo, - _In_count_(numParams) ParmVarDecl** paramVarDecls, - unsigned int numParams) -{ +static void AssociateParametersToFunctionPrototype(TypeSourceInfo *tinfo, + ParmVarDecl **paramVarDecls, + unsigned int numParams) { FunctionProtoTypeLoc protoLoc = tinfo->getTypeLoc().getAs(); DXASSERT(protoLoc.getNumParams() == numParams, "otherwise unexpected number of parameters available"); for (unsigned i = 0; i < numParams; i++) { @@ -773,9 +760,9 @@ void AssociateParametersToFunctionPrototype( } static void CreateConstructorDeclaration( - ASTContext &context, _In_ CXXRecordDecl *recordDecl, QualType resultType, - ArrayRef args, DeclarationName declarationName, bool isConst, - _Out_ CXXConstructorDecl **constructorDecl, _Out_ TypeSourceInfo **tinfo) { + ASTContext &context, CXXRecordDecl *recordDecl, QualType resultType, + ArrayRef args, DeclarationName declarationName, bool isConst, + CXXConstructorDecl **constructorDecl, TypeSourceInfo **tinfo) { DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(constructorDecl != nullptr); @@ -795,9 +782,9 @@ static void CreateConstructorDeclaration( } static void CreateObjectFunctionDeclaration( - ASTContext &context, _In_ CXXRecordDecl *recordDecl, QualType resultType, + ASTContext &context, CXXRecordDecl *recordDecl, QualType resultType, ArrayRef args, DeclarationName declarationName, bool isConst, - _Out_ CXXMethodDecl **functionDecl, _Out_ TypeSourceInfo **tinfo) { + CXXMethodDecl **functionDecl, TypeSourceInfo **tinfo) { DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(functionDecl != nullptr); @@ -816,16 +803,10 @@ static void CreateObjectFunctionDeclaration( (*functionDecl)->setAccess(AccessSpecifier::AS_public); } -CXXMethodDecl* hlsl::CreateObjectFunctionDeclarationWithParams( - ASTContext& context, - _In_ CXXRecordDecl* recordDecl, - QualType resultType, - ArrayRef paramTypes, - ArrayRef paramNames, - DeclarationName declarationName, - bool isConst, - bool isTemplateFunction) -{ +CXXMethodDecl *hlsl::CreateObjectFunctionDeclarationWithParams( + ASTContext &context, CXXRecordDecl *recordDecl, QualType resultType, + ArrayRef paramTypes, ArrayRef paramNames, + DeclarationName declarationName, bool isConst, bool isTemplateFunction) { DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(!resultType.isNull()); DXASSERT_NOMSG(paramTypes.size() == paramNames.size()); @@ -992,8 +973,7 @@ bool hlsl::GetIntrinsicLowering(const clang::FunctionDecl *FD, llvm::StringRef & } /// Parses a column or row digit. -static -bool TryParseColOrRowChar(const char digit, _Out_ int* count) { +static bool TryParseColOrRowChar(const char digit, int *count) { if ('1' <= digit && digit <= '4') { *count = digit - '0'; return true; @@ -1004,7 +984,6 @@ bool TryParseColOrRowChar(const char digit, _Out_ int* count) { } /// Parses a matrix shorthand identifier (eg, float3x2). -_Use_decl_annotations_ bool hlsl::TryParseMatrixShorthand( const char* typeName, size_t typeNameLen, @@ -1034,7 +1013,6 @@ bool hlsl::TryParseMatrixShorthand( } /// Parses a vector shorthand identifier (eg, float3). -_Use_decl_annotations_ bool hlsl::TryParseVectorShorthand( const char* typeName, size_t typeNameLen, @@ -1057,13 +1035,9 @@ bool hlsl::TryParseVectorShorthand( } /// Parses a hlsl scalar type (e.g min16float, uint3x4) -_Use_decl_annotations_ -bool hlsl::TryParseScalar( - _In_count_(typenameLen) - const char* typeName, - size_t typeNameLen, - _Out_ HLSLScalarType *parsedType, - _In_ const clang::LangOptions& langOptions) { +bool hlsl::TryParseScalar(const char *typeName, size_t typeNameLen, + HLSLScalarType *parsedType, + const clang::LangOptions &langOptions) { HLSLScalarType type = FindScalarTypeByName(typeName, typeNameLen, langOptions); if (type!= HLSLScalarType_unknown) { *parsedType = type; @@ -1073,15 +1047,9 @@ bool hlsl::TryParseScalar( } /// Parse any (scalar, vector, matrix) hlsl types (e.g float, int3x4, uint2) -_Use_decl_annotations_ -bool hlsl::TryParseAny( - _In_count_(typenameLen) - const char* typeName, - size_t typeNameLen, - _Out_ HLSLScalarType *parsedType, - int *rowCount, - int *colCount, - _In_ const clang::LangOptions& langOptions) { +bool hlsl::TryParseAny(const char *typeName, size_t typeNameLen, + HLSLScalarType *parsedType, int *rowCount, int *colCount, + const clang::LangOptions &langOptions) { // at least 'int' const size_t MinValidLen = 3; if (typeNameLen >= MinValidLen) { @@ -1098,12 +1066,8 @@ bool hlsl::TryParseAny( } /// Parse string hlsl type -_Use_decl_annotations_ -bool hlsl::TryParseString( - _In_count_(typenameLen) - const char* typeName, - size_t typeNameLen, - _In_ const clang::LangOptions& langOptions) { +bool hlsl::TryParseString(const char *typeName, size_t typeNameLen, + const clang::LangOptions &langOptions) { if (typeNameLen == 6 && typeName[0] == 's' && strncmp(typeName, "string", 6) == 0) { return true; @@ -1114,14 +1078,9 @@ bool hlsl::TryParseString( /// Parse any kind of dimension for vector or matrix (e.g 4,3 in int4x3). /// If it's a matrix type, rowCount and colCount will be nonzero. If it's a vector type, colCount is 0. /// Otherwise both rowCount and colCount is 0. Returns true if either matrix or vector dimensions detected. -_Use_decl_annotations_ bool hlsl::TryParseMatrixOrVectorDimension( - _In_count_(typeNameLen) - const char *typeName, - size_t typeNameLen, - _Out_opt_ int *rowCount, - _Out_opt_ int *colCount, - _In_ const clang::LangOptions& langOptions) { + const char *typeName, size_t typeNameLen, int *rowCount, int *colCount, + const clang::LangOptions &langOptions) { *rowCount = 0; *colCount = 0; size_t MinValidLen = 3; // at least int diff --git a/tools/clang/lib/AST/HlslTypes.cpp b/tools/clang/lib/AST/HlslTypes.cpp index 76e2db9719..0caf37df79 100644 --- a/tools/clang/lib/AST/HlslTypes.cpp +++ b/tools/clang/lib/AST/HlslTypes.cpp @@ -252,8 +252,7 @@ bool HasHLSLGloballyCoherent(clang::QualType type) { /// Checks whether the pAttributes indicate a parameter is inout or out; if /// inout, pIsIn will be set to true. -bool IsParamAttributedAsOut(_In_opt_ clang::AttributeList *pAttributes, - _Out_opt_ bool *pIsIn); +bool IsParamAttributedAsOut(clang::AttributeList *pAttributes, bool *pIsIn); /// Gets the type with structural information (elements and shape) for /// the given type. @@ -840,7 +839,6 @@ unsigned GetHLSLOutputPatchCount(QualType type) { return argList[1].getAsIntegral().getLimitedValue(); } -_Use_decl_annotations_ bool IsParamAttributedAsOut(clang::AttributeList *pAttributes, bool *pIsIn) { bool anyFound = false; bool inFound = false; @@ -871,7 +869,6 @@ bool IsParamAttributedAsOut(clang::AttributeList *pAttributes, bool *pIsIn) { return outFound; } -_Use_decl_annotations_ hlsl::ParameterModifier ParamModFromAttributeList(clang::AttributeList *pAttributes) { bool isIn, isOut; isOut = IsParamAttributedAsOut(pAttributes, &isIn); diff --git a/tools/clang/lib/AST/NestedNameSpecifier.cpp b/tools/clang/lib/AST/NestedNameSpecifier.cpp index 6a253745f3..d449018cb7 100644 --- a/tools/clang/lib/AST/NestedNameSpecifier.cpp +++ b/tools/clang/lib/AST/NestedNameSpecifier.cpp @@ -436,45 +436,46 @@ TypeLoc NestedNameSpecifierLoc::getTypeLoc() const { } namespace { - void Append(_In_reads_to_ptr_(End) char *Start, _In_reads_(0) char *End, _Outref_result_buffer_(BufferSize) char *&Buffer, unsigned &BufferSize, - unsigned &BufferCapacity) { - if (Start == End) - return; +void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize, + unsigned &BufferCapacity) { + if (Start == End) + return; - if (BufferSize + (End - Start) > BufferCapacity) { - // Reallocate the buffer. - unsigned NewCapacity = std::max( - (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2), - (unsigned)(BufferSize + (End - Start))); - char *NewBuffer = new char[NewCapacity]; // HLSL Change: Use overridable operator new - if (BufferCapacity) { - memcpy(NewBuffer, Buffer, BufferSize); - delete[] Buffer; // HLSL Change: Use overridable operator delete - } - Buffer = NewBuffer; - BufferCapacity = NewCapacity; + if (BufferSize + (End - Start) > BufferCapacity) { + // Reallocate the buffer. + unsigned NewCapacity = std::max( + (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2), + (unsigned)(BufferSize + (End - Start))); + char *NewBuffer = + new char[NewCapacity]; // HLSL Change: Use overridable operator new + if (BufferCapacity) { + memcpy(NewBuffer, Buffer, BufferSize); + delete[] Buffer; // HLSL Change: Use overridable operator delete } - - memcpy(Buffer + BufferSize, Start, End - Start); - BufferSize += End-Start; + Buffer = NewBuffer; + BufferCapacity = NewCapacity; } - + + memcpy(Buffer + BufferSize, Start, End - Start); + BufferSize += End - Start; +} + /// \brief Save a source location to the given buffer. - void SaveSourceLocation(SourceLocation Loc, _Outref_result_buffer_(BufferSize) char *&Buffer, - unsigned &BufferSize, unsigned &BufferCapacity) { - unsigned Raw = Loc.getRawEncoding(); - Append(reinterpret_cast(&Raw), - reinterpret_cast(&Raw) + sizeof(unsigned), - Buffer, BufferSize, BufferCapacity); - } - +void SaveSourceLocation(SourceLocation Loc, char *&Buffer, unsigned &BufferSize, + unsigned &BufferCapacity) { + unsigned Raw = Loc.getRawEncoding(); + Append(reinterpret_cast(&Raw), + reinterpret_cast(&Raw) + sizeof(unsigned), Buffer, BufferSize, + BufferCapacity); +} + /// \brief Save a pointer to the given buffer. - void SavePointer(void *Ptr, _Outref_result_buffer_(BufferSize) char *&Buffer, unsigned &BufferSize, - unsigned &BufferCapacity) { - Append(reinterpret_cast(&Ptr), - reinterpret_cast(&Ptr) + sizeof(void *), - Buffer, BufferSize, BufferCapacity); - } +void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize, + unsigned &BufferCapacity) { + Append(reinterpret_cast(&Ptr), + reinterpret_cast(&Ptr) + sizeof(void *), Buffer, BufferSize, + BufferCapacity); +} } NestedNameSpecifierLocBuilder:: diff --git a/tools/clang/lib/Basic/Diagnostic.cpp b/tools/clang/lib/Basic/Diagnostic.cpp index cc7384f7e9..ed48823ab8 100644 --- a/tools/clang/lib/Basic/Diagnostic.cpp +++ b/tools/clang/lib/Basic/Diagnostic.cpp @@ -204,7 +204,7 @@ void DiagnosticsEngine::setSeverity(diag::kind Diag, diag::Severity Map, return; } - _Analysis_assume_(SourceMgr != nullptr); // SourceMgr==nullptr is only valid for invalid locations, which cause an earlier exit + assert(SourceMgr != nullptr); // SourceMgr==nullptr is only valid for invalid locations, which cause an earlier exit // Another common case; modifying diagnostic state in a source location // after the previous one. if ((Loc.isValid() && LastStateChangePos.isInvalid()) || diff --git a/tools/clang/lib/Lex/Lexer.cpp b/tools/clang/lib/Lex/Lexer.cpp index 8828d593fd..089e76b78b 100644 --- a/tools/clang/lib/Lex/Lexer.cpp +++ b/tools/clang/lib/Lex/Lexer.cpp @@ -229,7 +229,7 @@ void Lexer::Stringify(SmallVectorImpl &Str) { /// \brief Slow case of getSpelling. Extract the characters comprising the /// spelling of this token from the provided input buffer. static size_t getSpellingSlow(const Token &Tok, const char *BufPtr, - const LangOptions &LangOpts, _Out_cap_x_(Tok.getLength()) char *Spelling) { + const LangOptions &LangOpts, char *Spelling) { assert(Tok.needsCleaning() && "getSpellingSlow called on simple token"); size_t Length = 0; diff --git a/tools/clang/lib/Lex/LiteralSupport.cpp b/tools/clang/lib/Lex/LiteralSupport.cpp index 803fab0ad6..606c821bb2 100644 --- a/tools/clang/lib/Lex/LiteralSupport.cpp +++ b/tools/clang/lib/Lex/LiteralSupport.cpp @@ -367,7 +367,7 @@ static int MeasureUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf, /// we will likely rework our support for UCN's. static void EncodeUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, - _Out_cap_(4) char *&ResultBuf, bool &HadError, + char *&ResultBuf, bool &HadError, FullSourceLoc Loc, unsigned CharByteWidth, DiagnosticsEngine *Diags, const LangOptions &Features) { diff --git a/tools/clang/lib/Parse/HLSLRootSignature.cpp b/tools/clang/lib/Parse/HLSLRootSignature.cpp index f81f9d847a..8c1bbeb0c5 100644 --- a/tools/clang/lib/Parse/HLSLRootSignature.cpp +++ b/tools/clang/lib/Parse/HLSLRootSignature.cpp @@ -1686,7 +1686,6 @@ HRESULT RootSignatureParser::MarkParameter(bool & bSeen, LPCSTR pName) return hr; } -_Use_decl_annotations_ bool clang::ParseHLSLRootSignature( const char *pData, unsigned Len, hlsl::DxilRootSignatureVersion Ver, hlsl::DxilRootSignatureCompilationFlags Flags, hlsl::DxilVersionedRootSignatureDesc **ppDesc, @@ -1714,7 +1713,6 @@ bool clang::ParseHLSLRootSignature( } } -_Use_decl_annotations_ void clang::ReportHLSLRootSigError(clang::DiagnosticsEngine &Diags, clang::SourceLocation Loc, const char *pData, unsigned Len) { diff --git a/tools/clang/lib/Parse/ParseDecl.cpp b/tools/clang/lib/Parse/ParseDecl.cpp index 6ada5f32b5..62034b667a 100644 --- a/tools/clang/lib/Parse/ParseDecl.cpp +++ b/tools/clang/lib/Parse/ParseDecl.cpp @@ -208,10 +208,10 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, } // HLSL Change Starts: Implementation for Semantic, Register, packoffset semantics. -static void ParseRegisterNumberForHLSL(_In_ const StringRef name, - _Out_ char *registerType, - _Out_ unsigned *registerNumber, - _Out_ unsigned *diagId) { +static void ParseRegisterNumberForHLSL(const StringRef name, + char *registerType, + unsigned *registerNumber, + unsigned *diagId) { DXASSERT_NOMSG(registerType != nullptr); DXASSERT_NOMSG(registerNumber != nullptr); DXASSERT_NOMSG(diagId != nullptr); @@ -248,7 +248,7 @@ static void ParseRegisterNumberForHLSL(_In_ const StringRef name, } static -void ParsePackSubcomponent(_In_ const StringRef name, _Out_ unsigned* subcomponent, _Out_ unsigned* diagId) +void ParsePackSubcomponent(const StringRef name, unsigned* subcomponent, unsigned* diagId) { DXASSERT_NOMSG(subcomponent != nullptr); DXASSERT_NOMSG(diagId != nullptr); @@ -264,9 +264,9 @@ void ParsePackSubcomponent(_In_ const StringRef name, _Out_ unsigned* subcompone static void ParsePackComponent( - _In_ const StringRef name, - _Inout_ hlsl::ConstantPacking* cp, - _Out_ unsigned* diagId) + const StringRef name, + hlsl::ConstantPacking* cp, + unsigned* diagId) { DXASSERT(name.size(), "otherwise an empty string was parsed as an identifier"); *diagId = 0; @@ -287,7 +287,7 @@ void ParsePackComponent( } static -bool IsShaderProfileShort(_In_ const StringRef profile) +bool IsShaderProfileShort(const StringRef profile) { // Look for vs, ps, gs, hs, cs. if (profile.size() != 2) return false; @@ -299,7 +299,7 @@ bool IsShaderProfileShort(_In_ const StringRef profile) } static -bool IsShaderProfileLike(_In_ const StringRef profile) +bool IsShaderProfileLike(const StringRef profile) { bool foundUnderscore = false; bool foundDigit = false; @@ -315,9 +315,9 @@ bool IsShaderProfileLike(_In_ const StringRef profile) return foundUnderscore && foundDigit && foundLetter; } -static void ParseSpaceForHLSL(_In_ const StringRef name, - _Out_ uint32_t *spaceValue, - _Out_ unsigned *diagId) { +static void ParseSpaceForHLSL(const StringRef name, + uint32_t *spaceValue, + unsigned *diagId) { DXASSERT_NOMSG(spaceValue != nullptr); DXASSERT_NOMSG(diagId != nullptr); @@ -330,7 +330,7 @@ static void ParseSpaceForHLSL(_In_ const StringRef name, } // Otherwise, strncmp above would have been != 0. - _Analysis_assume_(name.size() > sizeof("space")); + assert(name.size() >= strlen("space")); StringRef numName = name.substr(sizeof("space")-1); diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index f91188d6ee..ebc78820f7 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -742,14 +742,10 @@ static const bool SampleFalse = false; // a type does not support the static const bool SampleTrue = true; // a type supports the .sample member static const size_t MaxVectorSize = 4; // maximum size for a vector -static -QualType GetOrCreateTemplateSpecialization( - ASTContext& context, - Sema& sema, - _In_ ClassTemplateDecl* templateDecl, - ArrayRef templateArgs - ) -{ +static QualType +GetOrCreateTemplateSpecialization(ASTContext &context, Sema &sema, + ClassTemplateDecl *templateDecl, + ArrayRef templateArgs) { DXASSERT_NOMSG(templateDecl); DeclContext* currentDeclContext = context.getTranslationUnitDecl(); SmallVector templateArgsForDecl; @@ -801,11 +797,9 @@ QualType GetOrCreateTemplateSpecialization( } /// Instantiates a new matrix type specialization or gets an existing one from the AST. -static -QualType GetOrCreateMatrixSpecialization(ASTContext& context, Sema* sema, - _In_ ClassTemplateDecl* matrixTemplateDecl, - QualType elementType, uint64_t rowCount, uint64_t colCount) -{ +static QualType GetOrCreateMatrixSpecialization( + ASTContext &context, Sema *sema, ClassTemplateDecl *matrixTemplateDecl, + QualType elementType, uint64_t rowCount, uint64_t colCount) { DXASSERT_NOMSG(sema); TemplateArgument templateArgs[3] = { @@ -836,11 +830,10 @@ QualType GetOrCreateMatrixSpecialization(ASTContext& context, Sema* sema, } /// Instantiates a new vector type specialization or gets an existing one from the AST. -static -QualType GetOrCreateVectorSpecialization(ASTContext& context, Sema* sema, - _In_ ClassTemplateDecl* vectorTemplateDecl, - QualType elementType, uint64_t colCount) -{ +static QualType +GetOrCreateVectorSpecialization(ASTContext &context, Sema *sema, + ClassTemplateDecl *vectorTemplateDecl, + QualType elementType, uint64_t colCount) { DXASSERT_NOMSG(sema); DXASSERT_NOMSG(vectorTemplateDecl); @@ -866,7 +859,6 @@ QualType GetOrCreateVectorSpecialization(ASTContext& context, Sema* sema, return vectorSpecializationType; } - // Decls.cpp constants start here - these should be refactored or, better, replaced with clang::Type-based constructs. static const LPCSTR kBuiltinIntrinsicTableName = "op"; @@ -1913,13 +1905,11 @@ static void AddHLSLIntrinsicAttr(FunctionDecl *FD, ASTContext &context, FD->addAttr(HLSLWaveSensitiveAttr::CreateImplicit(context)); } -static -FunctionDecl *AddHLSLIntrinsicFunction( - ASTContext &context, _In_ NamespaceDecl *NS, - LPCSTR tableName, LPCSTR lowering, - _In_ const HLSL_INTRINSIC *pIntrinsic, - std::vector *functionArgQualTypesVector) -{ +static FunctionDecl * +AddHLSLIntrinsicFunction(ASTContext &context, NamespaceDecl *NS, + LPCSTR tableName, LPCSTR lowering, + const HLSL_INTRINSIC *pIntrinsic, + std::vector *functionArgQualTypesVector) { DeclContext *currentDeclContext = context.getTranslationUnitDecl(); std::vector &functionArgQualTypes = *functionArgQualTypesVector; const size_t functionArgTypeCount = functionArgQualTypes.size(); @@ -2002,9 +1992,7 @@ FunctionDecl *AddHLSLIntrinsicFunction( /// /// Checks whether the specified expression is a (possibly parenthesized) comma operator. /// -static -bool IsExpressionBinaryComma(_In_ const Expr* expr) -{ +static bool IsExpressionBinaryComma(const Expr *expr) { DXASSERT_NOMSG(expr != nullptr); expr = expr->IgnoreParens(); return @@ -2016,9 +2004,7 @@ bool IsExpressionBinaryComma(_In_ const Expr* expr) /// Silences diagnostics for the initialization sequence, typically because they have already /// been emitted. /// -static -void SilenceSequenceDiagnostics(_Inout_ InitializationSequence* initSequence) -{ +static void SilenceSequenceDiagnostics(InitializationSequence *initSequence) { DXASSERT_NOMSG(initSequence != nullptr); initSequence->SetFailed(InitializationSequence::FK_ListInitializationFailed); } @@ -2098,19 +2084,15 @@ class UsedIntrinsic mutable FunctionDecl* m_functionDecl; }; -template -inline void AssignOpt(T value, _Out_opt_ T* ptr) -{ +template inline void AssignOpt(T value, T *ptr) { if (ptr != nullptr) { *ptr = value; } } -static bool CombineBasicTypes(ArBasicKind LeftKind, - ArBasicKind RightKind, - _Out_ ArBasicKind* pOutKind) -{ +static bool CombineBasicTypes(ArBasicKind LeftKind, ArBasicKind RightKind, + ArBasicKind *pOutKind) { // Make sure the kinds are both valid if ((LeftKind < 0 || LeftKind >= AR_BASIC_MAXIMUM_COUNT) || (RightKind < 0 || RightKind >= AR_BASIC_MAXIMUM_COUNT)) { @@ -2253,9 +2235,9 @@ class UsedIntrinsicStore : public std::set { }; -static -void GetIntrinsicMethods(ArBasicKind kind, _Outptr_result_buffer_(*intrinsicCount) const HLSL_INTRINSIC** intrinsics, _Out_ size_t* intrinsicCount) -{ +static void GetIntrinsicMethods(ArBasicKind kind, + const HLSL_INTRINSIC **intrinsics, + size_t *intrinsicCount) { DXASSERT_NOMSG(intrinsics != nullptr); DXASSERT_NOMSG(intrinsicCount != nullptr); @@ -3038,7 +3020,7 @@ class HLSLExternalSource : public ExternalSemaSource { NamespaceDecl* m_vkNSDecl; // Context being processed. - _Notnull_ ASTContext* m_context; + ASTContext *m_context; // Semantic analyzer being processed. Sema* m_sema; @@ -3086,8 +3068,7 @@ class HLSLExternalSource : public ExternalSemaSource { /// Adds string type QualType for HLSL string declarations void AddHLSLStringType(); - QualType GetTemplateObjectDataType(_In_ CXXRecordDecl* recordDecl) - { + QualType GetTemplateObjectDataType(CXXRecordDecl *recordDecl) { DXASSERT_NOMSG(recordDecl != nullptr); TemplateParameterList* parameterList = recordDecl->getTemplateParameterList(0); NamedDecl* parameterDecl = parameterList->getParam(0); @@ -3126,16 +3107,16 @@ class HLSLExternalSource : public ExternalSemaSource { } // Adds a new template parameter declaration to the specified array and returns the type for the parameter. - QualType AddTemplateParamToArray(_In_z_ const char* name, _Inout_ CXXRecordDecl* recordDecl, int templateDepth, - _Inout_count_c_(g_MaxIntrinsicParamCount + 1) NamedDecl* (&templateParamNamedDecls)[g_MaxIntrinsicParamCount + 1], - _Inout_ size_t* templateParamNamedDeclsCount) - { + QualType AddTemplateParamToArray( + const char *name, CXXRecordDecl *recordDecl, int templateDepth, + NamedDecl *(&templateParamNamedDecls)[g_MaxIntrinsicParamCount + 1], + size_t *templateParamNamedDeclsCount) { DXASSERT_NOMSG(name != nullptr); DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(templateParamNamedDecls != nullptr); DXASSERT_NOMSG(templateParamNamedDeclsCount != nullptr); DXASSERT(*templateParamNamedDeclsCount < _countof(templateParamNamedDecls), "otherwise constants should be updated"); - _Analysis_assume_(*templateParamNamedDeclsCount < _countof(templateParamNamedDecls)); + assert(*templateParamNamedDeclsCount < _countof(templateParamNamedDecls)); // Create the declaration for the template parameter. IdentifierInfo* id = &m_context->Idents.get(StringRef(name)); @@ -3158,15 +3139,15 @@ class HLSLExternalSource : public ExternalSemaSource { // Adds a function specified by the given intrinsic to a record declaration. // The template depth will be zero for records that don't have a "template<>" line // even if conceptual; or one if it does have one. - void AddObjectIntrinsicTemplate(_Inout_ CXXRecordDecl* recordDecl, int templateDepth, _In_ const HLSL_INTRINSIC* intrinsic) - { + void AddObjectIntrinsicTemplate(CXXRecordDecl *recordDecl, int templateDepth, + const HLSL_INTRINSIC *intrinsic) { DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(intrinsic != nullptr); DXASSERT(intrinsic->uNumArgs > 0, "otherwise there isn't even an intrinsic name"); DXASSERT(intrinsic->uNumArgs <= (g_MaxIntrinsicParamCount + 1), "otherwise g_MaxIntrinsicParamCount should be updated"); // uNumArgs includes the result type, g_MaxIntrinsicParamCount doesn't, thus the +1. - _Analysis_assume_(intrinsic->uNumArgs <= (g_MaxIntrinsicParamCount + 1)); + assert(intrinsic->uNumArgs <= (g_MaxIntrinsicParamCount + 1)); // TODO: implement template parameter constraints for HLSL intrinsic methods in declarations @@ -3261,8 +3242,8 @@ class HLSLExternalSource : public ExternalSemaSource { } // Adds all the intrinsic methods that correspond to the specified type. - void AddObjectMethods(ArBasicKind kind, _In_ CXXRecordDecl* recordDecl, int templateDepth) - { + void AddObjectMethods(ArBasicKind kind, CXXRecordDecl *recordDecl, + int templateDepth) { DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(templateDepth >= 0); @@ -3288,14 +3269,11 @@ class HLSLExternalSource : public ExternalSemaSource { } void AddDoubleSubscriptSupport( - _In_ ClassTemplateDecl* typeDecl, - _In_ CXXRecordDecl* recordDecl, - _In_z_ const char* memberName, QualType elementType, TemplateTypeParmDecl* templateTypeParmDecl, - _In_z_ const char* type0Name, - _In_z_ const char* type1Name, - _In_z_ const char* indexer0Name, QualType indexer0Type, - _In_z_ const char* indexer1Name, QualType indexer1Type) - { + ClassTemplateDecl *typeDecl, CXXRecordDecl *recordDecl, + const char *memberName, QualType elementType, + TemplateTypeParmDecl *templateTypeParmDecl, const char *type0Name, + const char *type1Name, const char *indexer0Name, QualType indexer0Type, + const char *indexer1Name, QualType indexer1Type) { DXASSERT_NOMSG(typeDecl != nullptr); DXASSERT_NOMSG(recordDecl != nullptr); DXASSERT_NOMSG(memberName != nullptr); @@ -3377,8 +3355,8 @@ class HLSLExternalSource : public ExternalSemaSource { recordDecl->addDecl(sampleFieldDecl); } - void AddObjectSubscripts(ArBasicKind kind, _In_ ClassTemplateDecl *typeDecl, - _In_ CXXRecordDecl *recordDecl, + void AddObjectSubscripts(ArBasicKind kind, ClassTemplateDecl *typeDecl, + CXXRecordDecl *recordDecl, SubscriptOperatorRecord op) { DXASSERT_NOMSG(typeDecl != nullptr); DXASSERT_NOMSG(recordDecl != nullptr); @@ -3705,7 +3683,7 @@ class HLSLExternalSource : public ExternalSemaSource { effectKindIndex = i; DXASSERT(kind < _countof(g_ArBasicTypeNames), "g_ArBasicTypeNames has the wrong number of entries"); - _Analysis_assume_(kind < _countof(g_ArBasicTypeNames)); + assert(kind < _countof(g_ArBasicTypeNames)); const char* typeName = g_ArBasicTypeNames[kind]; uint8_t templateArgCount = g_ArBasicKindsTemplateCount[i]; CXXRecordDecl* recordDecl = nullptr; @@ -3825,10 +3803,10 @@ class HLSLExternalSource : public ExternalSemaSource { std::sort(m_objectTypeDeclsMap.begin(), m_objectTypeDeclsMap.end(), ObjectTypeDeclMapTypeCmp); } - FunctionDecl* AddSubscriptSpecialization( - _In_ FunctionTemplateDecl* functionTemplate, - QualType objectElement, - const FindStructBasicTypeResult& findResult); + FunctionDecl * + AddSubscriptSpecialization(FunctionTemplateDecl *functionTemplate, + QualType objectElement, + const FindStructBasicTypeResult &findResult); ImplicitCastExpr* CreateLValueToRValueCast(Expr* input) { return ImplicitCastExpr::Create(*m_context, input->getType(), CK_LValueToRValue, input, nullptr, VK_RValue); @@ -3891,8 +3869,7 @@ class HLSLExternalSource : public ExternalSemaSource { ~HLSLExternalSource() { } - static HLSLExternalSource* FromSema(_In_ Sema* self) - { + static HLSLExternalSource *FromSema(Sema *self) { DXASSERT_NOMSG(self != nullptr); ExternalSemaSource* externalSource = self->getExternalSource(); @@ -4372,7 +4349,7 @@ class HLSLExternalSource : public ExternalSemaSource { return AR_BASIC_UNKNOWN; } - void AddIntrinsicTableMethods(_In_ IDxcIntrinsicTable *table) { + void AddIntrinsicTableMethods(IDxcIntrinsicTable *table) { DXASSERT_NOMSG(table != nullptr); // Function intrinsics are added on-demand, objects get template methods. @@ -4407,7 +4384,7 @@ class HLSLExternalSource : public ExternalSemaSource { } } - void RegisterIntrinsicTable(_In_ IDxcIntrinsicTable *table) { + void RegisterIntrinsicTable(IDxcIntrinsicTable *table) { DXASSERT_NOMSG(table != nullptr); m_intrinsicTables.push_back(table); // If already initialized, add methods immediately. @@ -4573,13 +4550,9 @@ class HLSLExternalSource : public ExternalSemaSource { return type; } - QualType NewSimpleAggregateType( - _In_ ArTypeObjectKind ExplicitKind, - _In_ ArBasicKind componentType, - _In_ UINT64 qwQual, - _In_ UINT uRows, - _In_ UINT uCols) - { + QualType NewSimpleAggregateType(ArTypeObjectKind ExplicitKind, + ArBasicKind componentType, UINT64 qwQual, + UINT uRows, UINT uCols) { DXASSERT_VALIDBASICKIND(componentType); QualType pType; // The type to return. @@ -4639,31 +4612,23 @@ class HLSLExternalSource : public ExternalSemaSource { /// After exectuion, type of arguments. /// The first argument to mismatch if any /// On success, argTypes includes the clang Types to use for the signature, with the first being the return type. - bool MatchArguments( - const IntrinsicDefIter &cursor, - _In_ QualType objectElement, - _In_ QualType functionTemplateTypeArg, - _In_ ArrayRef Args, - _Out_ std::vector *, - _Out_ size_t &badArgIdx); + bool MatchArguments(const IntrinsicDefIter &cursor, QualType objectElement, + QualType functionTemplateTypeArg, ArrayRef Args, + std::vector *, size_t &badArgIdx); /// Validate object element on intrinsic to catch case like integer on Sample. /// Intrinsic function to validate. /// Intrinsic opcode to validate. /// Type element on the class intrinsic belongs to; possibly null (eg, 'float' in 'Texture2D'). - bool IsValidObjectElement( - LPCSTR tableName, - _In_ IntrinsicOp op, - _In_ QualType objectElement); + bool IsValidObjectElement(LPCSTR tableName, IntrinsicOp op, + QualType objectElement); // Returns the iterator with the first entry that matches the requirement - IntrinsicDefIter FindIntrinsicByNameAndArgCount( - _In_count_(tableSize) const HLSL_INTRINSIC* table, - size_t tableSize, - StringRef typeName, - StringRef nameIdentifier, - size_t argumentCount) - { + IntrinsicDefIter FindIntrinsicByNameAndArgCount(const HLSL_INTRINSIC *table, + size_t tableSize, + StringRef typeName, + StringRef nameIdentifier, + size_t argumentCount) { // This is implemented by a linear scan for now. // We tested binary search on tables, and there was no performance gain on // samples probably for the following reasons. @@ -4822,7 +4787,7 @@ class HLSLExternalSource : public ExternalSemaSource { } /// Checks whether the specified type is numeric or composed of numeric elements exclusively. - bool IsTypeNumeric(QualType type, _Out_ UINT* count); + bool IsTypeNumeric(QualType type, UINT *count); /// Checks whether the specified type is a scalar type. bool IsScalarType(const QualType& type) { @@ -4934,17 +4899,17 @@ class HLSLExternalSource : public ExternalSemaSource { } /// Checks whether the source type can be converted to the target type. - bool CanConvert(SourceLocation loc, Expr* sourceExpr, QualType target, bool explicitConversion, - _Out_opt_ TYPE_CONVERSION_REMARKS* remarks, - _Inout_opt_ StandardConversionSequence* sequence); - void CollectInfo(QualType type, _Out_ ArTypeInfo* pTypeInfo); + bool CanConvert(SourceLocation loc, Expr *sourceExpr, QualType target, + bool explicitConversion, TYPE_CONVERSION_REMARKS *remarks, + StandardConversionSequence *sequence); + void CollectInfo(QualType type, ArTypeInfo *pTypeInfo); void GetConversionForm( QualType type, bool explicitConversion, ArTypeInfo* pTypeInfo); - bool ValidateCast(SourceLocation Loc, _In_ Expr* source, QualType target, bool explicitConversion, - bool suppressWarnings, bool suppressErrors, - _Inout_opt_ StandardConversionSequence* sequence); + bool ValidateCast(SourceLocation Loc, Expr *source, QualType target, + bool explicitConversion, bool suppressWarnings, + bool suppressErrors, StandardConversionSequence *sequence); bool ValidatePrimitiveTypeForOperand(SourceLocation loc, QualType type, ArTypeObjectKind kind); bool ValidateTypeRequirements( SourceLocation loc, @@ -4990,17 +4955,13 @@ class HLSLExternalSource : public ExternalSemaSource { /// Right hand side. /// Location of question mark in operator. /// Result type of vector conditional expression. - clang::QualType CheckVectorConditional( - _In_ ExprResult &Cond, - _In_ ExprResult &LHS, - _In_ ExprResult &RHS, - _In_ SourceLocation QuestionLoc); - - clang::QualType ApplyTypeSpecSignToParsedType( - _In_ clang::QualType &type, - _In_ TypeSpecifierSign TSS, - _In_ SourceLocation Loc - ); + clang::QualType CheckVectorConditional(ExprResult &Cond, ExprResult &LHS, + ExprResult &RHS, + SourceLocation QuestionLoc); + + clang::QualType ApplyTypeSpecSignToParsedType(clang::QualType &type, + TypeSpecifierSign TSS, + SourceLocation Loc); bool CheckRangedTemplateArgument(SourceLocation diagLoc, llvm::APSInt& sintValue) { @@ -5015,7 +4976,7 @@ class HLSLExternalSource : public ExternalSemaSource { /// Performs HLSL-specific processing of template declarations. bool - CheckTemplateArgumentListForHLSL(_In_ TemplateDecl *Template, + CheckTemplateArgumentListForHLSL(TemplateDecl *Template, SourceLocation /* TemplateLoc */, TemplateArgumentListInfo &TemplateArgList) { DXASSERT_NOMSG(Template != nullptr); @@ -5111,18 +5072,17 @@ class HLSLExternalSource : public ExternalSemaSource { return false; } - FindStructBasicTypeResult FindStructBasicType(_In_ DeclContext* functionDeclContext); + FindStructBasicTypeResult + FindStructBasicType(DeclContext *functionDeclContext); /// Finds the table of intrinsics for the declaration context of a member function. /// Declaration context of function. /// After execution, the name of the object to which the table applies. /// After execution, the intrinsic table. /// After execution, the count of elements in the intrinsic table. - void FindIntrinsicTable( - _In_ DeclContext* functionDeclContext, - _Outptr_result_z_ const char** name, - _Outptr_result_buffer_(*intrinsicCount) const HLSL_INTRINSIC** intrinsics, - _Out_ size_t* intrinsicCount); + void FindIntrinsicTable(DeclContext *functionDeclContext, const char **name, + const HLSL_INTRINSIC **intrinsics, + size_t *intrinsicCount); /// Deduces the template arguments by comparing the argument types and the HLSL intrinsic tables. /// The declaration for the function template being deduced. @@ -5150,12 +5110,10 @@ class HLSLExternalSource : public ExternalSemaSource { /// Arguments to the initialization. /// Whether this is the top-level of an initialization list. /// Initialization sequence description to initialize. - void InitializeInitSequenceForHLSL( - const InitializedEntity& Entity, - const InitializationKind& Kind, - MultiExprArg Args, - bool TopLevelOfInitList, - _Inout_ InitializationSequence* initSequence); + void InitializeInitSequenceForHLSL(const InitializedEntity &Entity, + const InitializationKind &Kind, + MultiExprArg Args, bool TopLevelOfInitList, + InitializationSequence *initSequence); /// /// Checks whether the specified conversion occurs to a type of idential element type but less elements. @@ -5221,18 +5179,15 @@ class HLSLExternalSource : public ExternalSemaSource { /// Constant/TextureBuffer, converts it to const T. /// Expression to convert. /// The result of the conversion; or E if the type is not a scalar. - ExprResult MaybeConvertMemberAccess(_In_ clang::Expr* E); - - clang::Expr *HLSLImpCastToScalar( - _In_ clang::Sema* self, - _In_ clang::Expr* From, - ArTypeObjectKind FromShape, - ArBasicKind EltKind); - clang::ExprResult PerformHLSLConversion( - _In_ clang::Expr* From, - _In_ clang::QualType targetType, - _In_ const clang::StandardConversionSequence &SCS, - _In_ clang::Sema::CheckedConversionKind CCK); + ExprResult MaybeConvertMemberAccess(clang::Expr *E); + + clang::Expr *HLSLImpCastToScalar(clang::Sema *self, clang::Expr *From, + ArTypeObjectKind FromShape, + ArBasicKind EltKind); + clang::ExprResult + PerformHLSLConversion(clang::Expr *From, clang::QualType targetType, + const clang::StandardConversionSequence &SCS, + clang::Sema::CheckedConversionKind CCK); /// Diagnoses an error when precessing the specified type if nesting is too deep. void ReportUnsupportedTypeNesting(SourceLocation loc, QualType type); @@ -5250,13 +5205,13 @@ class HLSLExternalSource : public ExternalSemaSource { /// Whether the cast is in the context of a list initialization. /// Whether warnings should be omitted. /// Whether errors should be omitted. - bool TryStaticCastForHLSL(ExprResult &SrcExpr, - QualType DestType, - Sema::CheckedConversionKind CCK, - const SourceRange &OpRange, unsigned &msg, - CastKind &Kind, CXXCastPath &BasePath, - bool ListInitialization, bool SuppressWarnings, bool SuppressErrors, - _Inout_opt_ StandardConversionSequence* standard); + bool TryStaticCastForHLSL(ExprResult &SrcExpr, QualType DestType, + Sema::CheckedConversionKind CCK, + const SourceRange &OpRange, unsigned &msg, + CastKind &Kind, CXXCastPath &BasePath, + bool ListInitialization, bool SuppressWarnings, + bool SuppressErrors, + StandardConversionSequence *standard); /// /// Checks if a subscript index argument can be initialized from the given expression. @@ -5267,7 +5222,9 @@ class HLSLExternalSource : public ExternalSemaSource { /// Rules for subscript index initialization follow regular implicit casting rules, with the exception that /// no changes in arity are allowed (i.e., int2 can become uint2, but uint or uint3 cannot). /// - ImplicitConversionSequence TrySubscriptIndexInitialization(_In_ clang::Expr* SrcExpr, clang::QualType DestType); + ImplicitConversionSequence + TrySubscriptIndexInitialization(clang::Expr *SrcExpr, + clang::QualType DestType); void CompleteType(TagDecl *Tag) override { if (Tag->isCompleteDefinition() || !isa(Tag)) @@ -5304,15 +5261,12 @@ class HLSLExternalSource : public ExternalSemaSource { recordDecl->completeDefinition(); } - FunctionDecl* AddHLSLIntrinsicMethod( - LPCSTR tableName, - LPCSTR lowering, - _In_ const HLSL_INTRINSIC* intrinsic, - _In_ FunctionTemplateDecl *FunctionTemplate, - ArrayRef Args, - _In_count_(parameterTypeCount) QualType* parameterTypes, - size_t parameterTypeCount) - { + FunctionDecl *AddHLSLIntrinsicMethod(LPCSTR tableName, LPCSTR lowering, + const HLSL_INTRINSIC *intrinsic, + FunctionTemplateDecl *FunctionTemplate, + ArrayRef Args, + QualType *parameterTypes, + size_t parameterTypeCount) { DXASSERT_NOMSG(intrinsic != nullptr); DXASSERT_NOMSG(FunctionTemplate != nullptr); DXASSERT_NOMSG(parameterTypes != nullptr); @@ -5503,7 +5457,7 @@ class FlattenedTypeIterator /// Pushes a tracker for the specified expression; returns true if there is something to evaluate. bool pushTrackerForExpression(MultiExprArg::iterator expression); /// Pushes a tracker for the specified type; returns true if there is something to evaluate. - bool pushTrackerForType(QualType type, _In_opt_ MultiExprArg::iterator expression); + bool pushTrackerForType(QualType type, MultiExprArg::iterator expression); public: /// Constructs a FlattenedTypeIterator for the specified type. @@ -5632,11 +5586,9 @@ void HLSLExternalSource::AddHLSLStringType() { m_hlslStringType = m_context->HLSLStringTy; } -FunctionDecl* HLSLExternalSource::AddSubscriptSpecialization( - _In_ FunctionTemplateDecl* functionTemplate, - QualType objectElement, - const FindStructBasicTypeResult& findResult) -{ +FunctionDecl *HLSLExternalSource::AddSubscriptSpecialization( + FunctionTemplateDecl *functionTemplate, QualType objectElement, + const FindStructBasicTypeResult &findResult) { DXASSERT_NOMSG(functionTemplate != nullptr); DXASSERT_NOMSG(!objectElement.isNull()); DXASSERT_NOMSG(findResult.Found()); @@ -5716,8 +5668,8 @@ FunctionDecl* HLSLExternalSource::AddSubscriptSpecialization( /// and want to treat either side equally you should call it twice, swapping the /// parameter order. /// -static bool CombineObjectTypes(ArBasicKind Target, _In_ ArBasicKind Source, - _Out_opt_ ArBasicKind *pCombined) { +static bool CombineObjectTypes(ArBasicKind Target, ArBasicKind Source, + ArBasicKind *pCombined) { if (Target == Source) { AssignOpt(Target, pCombined); return true; @@ -5885,9 +5837,9 @@ ConcreteLiteralType(Expr *litExpr, ArBasicKind kind, } } -_Use_decl_annotations_ bool -HLSLExternalSource::IsValidObjectElement(LPCSTR tableName, const IntrinsicOp op, - QualType objectElement) { +bool HLSLExternalSource::IsValidObjectElement(LPCSTR tableName, + const IntrinsicOp op, + QualType objectElement) { // Only meant to exclude builtins, assume others are fine if (!IsBuiltinTable(tableName)) return true; @@ -5922,7 +5874,6 @@ HLSLExternalSource::IsValidObjectElement(LPCSTR tableName, const IntrinsicOp op, } } -_Use_decl_annotations_ bool HLSLExternalSource::MatchArguments( const IntrinsicDefIter &cursor, QualType objectElement, @@ -6469,7 +6420,6 @@ bool HLSLExternalSource::MatchArguments( #undef CAB } -_Use_decl_annotations_ HLSLExternalSource::FindStructBasicTypeResult HLSLExternalSource::FindStructBasicType(DeclContext* functionDeclContext) { @@ -6492,7 +6442,6 @@ HLSLExternalSource::FindStructBasicType(DeclContext* functionDeclContext) return HLSLExternalSource::FindStructBasicTypeResult(AR_BASIC_UNKNOWN, 0); } -_Use_decl_annotations_ void HLSLExternalSource::FindIntrinsicTable(DeclContext* functionDeclContext, const char** name, const HLSL_INTRINSIC** intrinsics, size_t* intrinsicCount) { DXASSERT_NOMSG(functionDeclContext != nullptr); @@ -6735,7 +6684,6 @@ ExprResult HLSLExternalSource::PromoteToIntIfBool(ExprResult& E) return E; } -_Use_decl_annotations_ void HLSLExternalSource::CollectInfo(QualType type, ArTypeInfo* pTypeInfo) { DXASSERT_NOMSG(pTypeInfo != nullptr); @@ -7527,12 +7475,9 @@ OverloadingResult HLSLExternalSource::GetBestViableFunction( /// Whether this is the top-level of an initialization list. /// Initialization sequence description to initialize. void HLSLExternalSource::InitializeInitSequenceForHLSL( - const InitializedEntity& Entity, - const InitializationKind& Kind, - MultiExprArg Args, - bool TopLevelOfInitList, - _Inout_ InitializationSequence* initSequence) -{ + const InitializedEntity &Entity, const InitializationKind &Kind, + MultiExprArg Args, bool TopLevelOfInitList, + InitializationSequence *initSequence) { DXASSERT_NOMSG(initSequence != nullptr); // In HLSL there are no default initializers, eg float4x4 m(); @@ -7821,9 +7766,9 @@ MatrixMemberAccessError TryConsumeMatrixDigit(const char*& memberText, uint32_t* return MatrixMemberAccessError_None; } -static -MatrixMemberAccessError TryParseMatrixMemberAccess(_In_z_ const char* memberText, _Out_ MatrixMemberAccessPositions* value) -{ +static MatrixMemberAccessError +TryParseMatrixMemberAccess(const char *memberText, + MatrixMemberAccessPositions *value) { DXASSERT_NOMSG(memberText != nullptr); DXASSERT_NOMSG(value != nullptr); @@ -8070,8 +8015,9 @@ VectorMemberAccessError TryConsumeVectorDigit(const char*& memberText, uint32_t* return VectorMemberAccessError_None; } -static -VectorMemberAccessError TryParseVectorMemberAccess(_In_z_ const char* memberText, _Out_ VectorMemberAccessPositions* value) { +static VectorMemberAccessError +TryParseVectorMemberAccess(const char *memberText, + VectorMemberAccessPositions *value) { DXASSERT_NOMSG(memberText != nullptr); DXASSERT_NOMSG(value != nullptr); @@ -8270,9 +8216,8 @@ ExprResult HLSLExternalSource::LookupArrayMemberExprForHLSL( return ExprError(); } - -ExprResult HLSLExternalSource::MaybeConvertMemberAccess(_In_ clang::Expr* E) { +ExprResult HLSLExternalSource::MaybeConvertMemberAccess(clang::Expr *E) { DXASSERT_NOMSG(E != nullptr); if (IsHLSLBufferViewType(E->getType())) { @@ -8350,12 +8295,10 @@ static clang::CastKind ConvertToComponentCastKind(clang::CastKind CK) { return CK_Invalid; } -clang::Expr *HLSLExternalSource::HLSLImpCastToScalar( - _In_ clang::Sema* self, - _In_ clang::Expr* From, - ArTypeObjectKind FromShape, - ArBasicKind EltKind) -{ +clang::Expr *HLSLExternalSource::HLSLImpCastToScalar(clang::Sema *self, + clang::Expr *From, + ArTypeObjectKind FromShape, + ArBasicKind EltKind) { clang::CastKind CK = CK_Invalid; if (AR_TOBJ_MATRIX == FromShape) CK = CK_HLSLMatrixToScalarCast; @@ -8369,11 +8312,9 @@ clang::Expr *HLSLExternalSource::HLSLImpCastToScalar( } clang::ExprResult HLSLExternalSource::PerformHLSLConversion( - _In_ clang::Expr* From, - _In_ clang::QualType targetType, - _In_ const clang::StandardConversionSequence &SCS, - _In_ clang::Sema::CheckedConversionKind CCK) -{ + clang::Expr *From, clang::QualType targetType, + const clang::StandardConversionSequence &SCS, + clang::Sema::CheckedConversionKind CCK) { QualType sourceType = From->getType(); sourceType = GetStructuralForm(sourceType); targetType = GetStructuralForm(targetType); @@ -8559,9 +8500,8 @@ void HLSLExternalSource::GetConversionForm( } } -static -bool HandleVoidConversion(QualType source, QualType target, bool explicitConversion, _Out_ bool* allowed) -{ +static bool HandleVoidConversion(QualType source, QualType target, + bool explicitConversion, bool *allowed) { DXASSERT_NOMSG(allowed != nullptr); bool applicable = true; *allowed = true; @@ -8886,15 +8826,10 @@ static bool ConvertComponent(ArTypeInfo TargetInfo, ArTypeInfo SourceInfo, return true; } -_Use_decl_annotations_ -bool HLSLExternalSource::CanConvert( - SourceLocation loc, - Expr* sourceExpr, - QualType target, - bool explicitConversion, - _Out_opt_ TYPE_CONVERSION_REMARKS* remarks, - _Inout_opt_ StandardConversionSequence* standard) -{ +bool HLSLExternalSource::CanConvert(SourceLocation loc, Expr *sourceExpr, + QualType target, bool explicitConversion, + TYPE_CONVERSION_REMARKS *remarks, + StandardConversionSequence *standard) { UINT uTSize, uSSize; bool SourceIsAggregate, TargetIsAggregate; // Early declarations due to gotos below @@ -9683,12 +9618,10 @@ QualType HLSLExternalSource::CheckUnaryOpForHLSL( } } -clang::QualType HLSLExternalSource::CheckVectorConditional( - _In_ ExprResult &Cond, - _In_ ExprResult &LHS, - _In_ ExprResult &RHS, - _In_ SourceLocation QuestionLoc) -{ +clang::QualType +HLSLExternalSource::CheckVectorConditional(ExprResult &Cond, ExprResult &LHS, + ExprResult &RHS, + SourceLocation QuestionLoc) { Cond = m_sema->CorrectDelayedTyposInExpr(Cond); LHS = m_sema->CorrectDelayedTyposInExpr(LHS); @@ -9872,9 +9805,10 @@ clang::QualType HLSLExternalSource::CheckVectorConditional( // Apply type specifier sign to the given QualType. // Other than privmitive int type, only allow shorthand vectors and matrices to be unsigned. -clang::QualType HLSLExternalSource::ApplyTypeSpecSignToParsedType( - _In_ clang::QualType &type, _In_ clang::TypeSpecifierSign TSS, - _In_ clang::SourceLocation Loc) { +clang::QualType +HLSLExternalSource::ApplyTypeSpecSignToParsedType(clang::QualType &type, + clang::TypeSpecifierSign TSS, + clang::SourceLocation Loc) { if (TSS == TypeSpecifierSign::TSS_unspecified) { return type; } @@ -10082,14 +10016,11 @@ void HLSLExternalSource::ReportUnsupportedTypeNesting(SourceLocation loc, QualTy m_sema->Diag(loc, diag::err_hlsl_unsupported_type_nesting) << type; } -bool HLSLExternalSource::TryStaticCastForHLSL(ExprResult &SrcExpr, - QualType DestType, - Sema::CheckedConversionKind CCK, - const SourceRange &OpRange, unsigned &msg, - CastKind &Kind, CXXCastPath &BasePath, - bool ListInitialization, bool SuppressWarnings, bool SuppressErrors, - _Inout_opt_ StandardConversionSequence* standard) -{ +bool HLSLExternalSource::TryStaticCastForHLSL( + ExprResult &SrcExpr, QualType DestType, Sema::CheckedConversionKind CCK, + const SourceRange &OpRange, unsigned &msg, CastKind &Kind, + CXXCastPath &BasePath, bool ListInitialization, bool SuppressWarnings, + bool SuppressErrors, StandardConversionSequence *standard) { DXASSERT(!SrcExpr.isInvalid(), "caller should check for invalid expressions and placeholder types"); bool explicitConversion = (CCK == Sema::CCK_CStyleCast || CCK == Sema::CCK_FunctionalCast); @@ -10119,7 +10050,7 @@ bool HLSLExternalSource::TryStaticCastForHLSL(ExprResult &SrcExpr, /// no changes in arity are allowed (i.e., int2 can become uint2, but uint or uint3 cannot). /// ImplicitConversionSequence -HLSLExternalSource::TrySubscriptIndexInitialization(_In_ clang::Expr *SrcExpr, +HLSLExternalSource::TrySubscriptIndexInitialization(clang::Expr *SrcExpr, clang::QualType DestType) { DXASSERT_NOMSG(SrcExpr != nullptr); DXASSERT_NOMSG(!DestType.isNull()); @@ -10271,9 +10202,9 @@ bool IsValueInBasicRange(ArBasicKind basicKind, const APValue& value) } } -static -bool IsPrecisionLossIrrelevant(ASTContext& Ctx, _In_ const Expr* sourceExpr, QualType targetType, ArBasicKind targetKind) -{ +static bool IsPrecisionLossIrrelevant(ASTContext &Ctx, const Expr *sourceExpr, + QualType targetType, + ArBasicKind targetKind) { DXASSERT_NOMSG(!targetType.isNull()); DXASSERT_NOMSG(sourceExpr != nullptr); @@ -10287,15 +10218,11 @@ bool IsPrecisionLossIrrelevant(ASTContext& Ctx, _In_ const Expr* sourceExpr, Qua return false; } -bool HLSLExternalSource::ValidateCast( - SourceLocation OpLoc, - _In_ Expr* sourceExpr, - QualType target, - bool explicitConversion, - bool suppressWarnings, - bool suppressErrors, - _Inout_opt_ StandardConversionSequence* standard) -{ +bool HLSLExternalSource::ValidateCast(SourceLocation OpLoc, Expr *sourceExpr, + QualType target, bool explicitConversion, + bool suppressWarnings, + bool suppressErrors, + StandardConversionSequence *standard) { DXASSERT_NOMSG(sourceExpr != nullptr); if (OpLoc.isInvalid()) @@ -11048,10 +10975,10 @@ static unsigned CaculateInitListSize(HLSLExternalSource *hlslSource, return totalSize; } -unsigned hlsl::CaculateInitListArraySizeForHLSL( - _In_ clang::Sema* sema, - _In_ const clang::InitListExpr *InitList, - _In_ const clang::QualType EltTy) { +unsigned +hlsl::CaculateInitListArraySizeForHLSL(clang::Sema *sema, + const clang::InitListExpr *InitList, + const clang::QualType EltTy) { HLSLExternalSource *hlslSource = HLSLExternalSource::FromSema(sema); unsigned totalSize = CaculateInitListSize(hlslSource, InitList); unsigned eltSize = hlslSource->GetNumBasicElements(EltTy); @@ -11122,11 +11049,8 @@ bool hlsl::ShouldSkipNRVO(clang::Sema& sema, clang::QualType returnType, clang:: } bool hlsl::IsConversionToLessOrEqualElements( - _In_ clang::Sema* self, - const clang::ExprResult& sourceExpr, - const clang::QualType& targetType, - bool explicitConversion) -{ + clang::Sema *self, const clang::ExprResult &sourceExpr, + const clang::QualType &targetType, bool explicitConversion) { return HLSLExternalSource::FromSema(self) ->IsConversionToLessOrEqualElements(sourceExpr, targetType, explicitConversion); } @@ -11193,42 +11117,32 @@ bool hlsl::LookupRecordMemberExprForHLSL( return false; } -clang::ExprResult hlsl::MaybeConvertMemberAccess( - _In_ clang::Sema* self, - _In_ clang::Expr* E) -{ +clang::ExprResult hlsl::MaybeConvertMemberAccess(clang::Sema *self, + clang::Expr *E) { return HLSLExternalSource::FromSema(self)->MaybeConvertMemberAccess(E); } -bool hlsl::TryStaticCastForHLSL(_In_ Sema* self, ExprResult &SrcExpr, - QualType DestType, - Sema::CheckedConversionKind CCK, - const SourceRange &OpRange, unsigned &msg, - CastKind &Kind, CXXCastPath &BasePath, - bool ListInitialization, - bool SuppressDiagnostics, - _Inout_opt_ StandardConversionSequence* standard) -{ +bool hlsl::TryStaticCastForHLSL( + Sema *self, ExprResult &SrcExpr, QualType DestType, + Sema::CheckedConversionKind CCK, const SourceRange &OpRange, unsigned &msg, + CastKind &Kind, CXXCastPath &BasePath, bool ListInitialization, + bool SuppressDiagnostics, StandardConversionSequence *standard) { return HLSLExternalSource::FromSema(self)->TryStaticCastForHLSL( SrcExpr, DestType, CCK, OpRange, msg, Kind, BasePath, ListInitialization, SuppressDiagnostics, SuppressDiagnostics, standard); } -clang::ExprResult hlsl::PerformHLSLConversion( - _In_ clang::Sema* self, - _In_ clang::Expr* From, - _In_ clang::QualType targetType, - _In_ const clang::StandardConversionSequence &SCS, - _In_ clang::Sema::CheckedConversionKind CCK) -{ +clang::ExprResult +hlsl::PerformHLSLConversion(clang::Sema *self, clang::Expr *From, + clang::QualType targetType, + const clang::StandardConversionSequence &SCS, + clang::Sema::CheckedConversionKind CCK) { return HLSLExternalSource::FromSema(self)->PerformHLSLConversion(From, targetType, SCS, CCK); } -clang::ImplicitConversionSequence hlsl::TrySubscriptIndexInitialization( - _In_ clang::Sema* self, - _In_ clang::Expr* SrcExpr, - clang::QualType DestType) -{ +clang::ImplicitConversionSequence +hlsl::TrySubscriptIndexInitialization(clang::Sema *self, clang::Expr *SrcExpr, + clang::QualType DestType) { return HLSLExternalSource::FromSema(self) ->TrySubscriptIndexInitialization(SrcExpr, DestType); } @@ -12014,8 +11928,9 @@ static void ValidateAttributeOnSwitchOrIf(Sema& S, Stmt* St, const AttributeList } } -static StringRef ValidateAttributeStringArg(Sema& S, const AttributeList &A, _In_opt_z_ const char* values, unsigned index = 0) -{ +static StringRef ValidateAttributeStringArg(Sema &S, const AttributeList &A, + const char *values, + unsigned index = 0) { // values is an optional comma-separated list of potential values. if (A.getNumArgs() <= index) return StringRef(); @@ -13418,10 +13333,9 @@ static QualType getUnderlyingType(QualType Type) /// Set pointer to column_major/row_major AttributedType if supplied. /// Set pointer to snorm/unorm AttributedType if supplied. void hlsl::GetHLSLAttributedTypes( - _In_ clang::Sema *self, clang::QualType type, - _Inout_opt_ const clang::AttributedType **ppMatrixOrientation, - _Inout_opt_ const clang::AttributedType **ppNorm, - _Inout_opt_ const clang::AttributedType **ppGLC) { + clang::Sema *self, clang::QualType type, + const clang::AttributedType **ppMatrixOrientation, + const clang::AttributedType **ppNorm, const clang::AttributedType **ppGLC) { AssignOpt(nullptr, ppMatrixOrientation); AssignOpt(nullptr, ppNorm); AssignOpt(nullptr, ppGLC); @@ -13482,29 +13396,22 @@ void hlsl::GetHLSLAttributedTypes( /// Returns true if QualType is an HLSL Matrix type. /// Sema with context. /// QualType to check. -bool hlsl::IsMatrixType( - _In_ clang::Sema* self, - _In_ clang::QualType type) -{ +bool hlsl::IsMatrixType(clang::Sema *self, clang::QualType type) { return HLSLExternalSource::FromSema(self)->GetTypeObjectKind(type) == AR_TOBJ_MATRIX; } /// Returns true if QualType is an HLSL Vector type. /// Sema with context. /// QualType to check. -bool hlsl::IsVectorType( - _In_ clang::Sema* self, - _In_ clang::QualType type) -{ +bool hlsl::IsVectorType(clang::Sema *self, clang::QualType type) { return HLSLExternalSource::FromSema(self)->GetTypeObjectKind(type) == AR_TOBJ_VECTOR; } /// Get element type for an HLSL Matrix or Vector, preserving AttributedType. /// Sema with context. /// Matrix or Vector type. -clang::QualType hlsl::GetOriginalMatrixOrVectorElementType( - _In_ clang::QualType type) -{ +clang::QualType +hlsl::GetOriginalMatrixOrVectorElementType(clang::QualType type) { // TODO: Determine if this is really the best way to get the matrix/vector specialization // without losing the AttributedType on the template parameter if (const Type* Ty = type.getTypePtrOrNull()) { @@ -13535,10 +13442,8 @@ clang::QualType hlsl::GetOriginalMatrixOrVectorElementType( /// Get element type, preserving AttributedType, if vector or matrix, otherwise return the type unmodified. /// Sema with context. /// Input type. -clang::QualType hlsl::GetOriginalElementType( - _In_ clang::Sema* self, - _In_ clang::QualType type) -{ +clang::QualType hlsl::GetOriginalElementType(clang::Sema *self, + clang::QualType type) { ArTypeObjectKind Kind = HLSLExternalSource::FromSema(self)->GetTypeObjectKind(type); if (Kind == AR_TOBJ_MATRIX || Kind == AR_TOBJ_VECTOR) { return GetOriginalMatrixOrVectorElementType(type); @@ -13940,11 +13845,8 @@ void hlsl::PrintClipPlaneIfPresent(clang::Expr *ClipPlane, llvm::raw_ostream &Ou } } -bool hlsl::IsObjectType( - _In_ clang::Sema* self, - _In_ clang::QualType type, - _Inout_opt_ bool *isDeprecatedEffectObject) -{ +bool hlsl::IsObjectType(clang::Sema *self, clang::QualType type, + bool *isDeprecatedEffectObject) { HLSLExternalSource *pExternalSource = HLSLExternalSource::FromSema(self); if (pExternalSource && pExternalSource->GetTypeObjectKind(type) == AR_TOBJ_OBJECT) { if (isDeprecatedEffectObject) @@ -13956,14 +13858,10 @@ bool hlsl::IsObjectType( return false; } -bool hlsl::CanConvert( - _In_ clang::Sema* self, - clang::SourceLocation loc, - _In_ clang::Expr* sourceExpr, - clang::QualType target, - bool explicitConversion, - _Inout_opt_ clang::StandardConversionSequence* standard) -{ +bool hlsl::CanConvert(clang::Sema *self, clang::SourceLocation loc, + clang::Expr *sourceExpr, clang::QualType target, + bool explicitConversion, + clang::StandardConversionSequence *standard) { return HLSLExternalSource::FromSema(self)->CanConvert(loc, sourceExpr, target, explicitConversion, nullptr, standard); } @@ -13973,8 +13871,8 @@ void hlsl::Indent(unsigned int Indentation, llvm::raw_ostream &Out) Out << " "; } -void hlsl::RegisterIntrinsicTable(_In_ clang::ExternalSemaSource* self, _In_ IDxcIntrinsicTable* table) -{ +void hlsl::RegisterIntrinsicTable(clang::ExternalSemaSource *self, + IDxcIntrinsicTable *table) { DXASSERT_NOMSG(self != nullptr); DXASSERT_NOMSG(table != nullptr); @@ -13982,17 +13880,14 @@ void hlsl::RegisterIntrinsicTable(_In_ clang::ExternalSemaSource* self, _In_ IDx source->RegisterIntrinsicTable(table); } -clang::QualType hlsl::CheckVectorConditional( - _In_ clang::Sema* self, - _In_ clang::ExprResult &Cond, - _In_ clang::ExprResult &LHS, - _In_ clang::ExprResult &RHS, - _In_ clang::SourceLocation QuestionLoc) -{ +clang::QualType +hlsl::CheckVectorConditional(clang::Sema *self, clang::ExprResult &Cond, + clang::ExprResult &LHS, clang::ExprResult &RHS, + clang::SourceLocation QuestionLoc) { return HLSLExternalSource::FromSema(self)->CheckVectorConditional(Cond, LHS, RHS, QuestionLoc); } -bool IsTypeNumeric(_In_ clang::Sema* self, _In_ clang::QualType &type) { +bool IsTypeNumeric(clang::Sema *self, clang::QualType &type) { UINT count; return HLSLExternalSource::FromSema(self)->IsTypeNumeric(type, &count); } @@ -14036,14 +13931,12 @@ void Sema::CheckHLSLArrayAccess(const Expr *expr) { } } -clang::QualType ApplyTypeSpecSignToParsedType( - _In_ clang::Sema* self, - _In_ clang::QualType &type, - _In_ clang::TypeSpecifierSign TSS, - _In_ clang::SourceLocation Loc -) -{ - return HLSLExternalSource::FromSema(self)->ApplyTypeSpecSignToParsedType(type, TSS, Loc); +clang::QualType ApplyTypeSpecSignToParsedType(clang::Sema *self, + clang::QualType &type, + clang::TypeSpecifierSign TSS, + clang::SourceLocation Loc) { + return HLSLExternalSource::FromSema(self)->ApplyTypeSpecSignToParsedType( + type, TSS, Loc); } QualType Sema::getHLSLDefaultSpecialization(TemplateDecl *Decl) { diff --git a/tools/clang/lib/Sema/SemaInit.cpp b/tools/clang/lib/Sema/SemaInit.cpp index 6e6604eef3..05119c3168 100644 --- a/tools/clang/lib/Sema/SemaInit.cpp +++ b/tools/clang/lib/Sema/SemaInit.cpp @@ -5036,7 +5036,7 @@ void InitializationSequence::InitializeFrom(Sema &S, assert(Args.size() == 1 && "Zero-argument case handled above"); // HLSL Change Starts assert(Initializer != nullptr && "otherwise prior code changed and Args.size() == 1 no longer reads from first argument"); - _Analysis_assume_(Initializer != nullptr); + assert(Initializer != nullptr); // HLSL Change Ends // - Otherwise, if the source type is a (possibly cv-qualified) class diff --git a/tools/clang/tools/d3dcomp/d3dcomp.cpp b/tools/clang/tools/d3dcomp/d3dcomp.cpp index 93debf3cc0..c53141b711 100644 --- a/tools/clang/tools/d3dcomp/d3dcomp.cpp +++ b/tools/clang/tools/d3dcomp/d3dcomp.cpp @@ -210,12 +210,9 @@ HRESULT WINAPI BridgeD3DCompileFromFile( pTarget, Flags1, Flags2, ppCode, ppErrorMsgs); } -HRESULT WINAPI BridgeD3DDisassemble( - _In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ UINT Flags, - _In_opt_ LPCSTR szComments, - _Out_ ID3DBlob** ppDisassembly) { +HRESULT WINAPI BridgeD3DDisassemble(LPCVOID pSrcData, SIZE_T SrcDataSize, + UINT Flags, LPCSTR szComments, + ID3DBlob **ppDisassembly) { CComPtr library; CComPtr compiler; CComPtr source; @@ -236,11 +233,8 @@ HRESULT WINAPI BridgeD3DDisassemble( return S_OK; } -HRESULT WINAPI BridgeD3DReflect( - _In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ REFIID pInterface, - _Out_ void** ppReflector) { +HRESULT WINAPI BridgeD3DReflect(LPCVOID pSrcData, SIZE_T SrcDataSize, + REFIID pInterface, void **ppReflector) { CComPtr library; CComPtr source; CComPtr reflection; @@ -259,9 +253,7 @@ HRESULT WINAPI BridgeD3DReflect( return S_OK; } -HRESULT WINAPI -BridgeReadFileToBlob(_In_ LPCWSTR pFileName, - _Out_ ID3DBlob** ppContents) { +HRESULT WINAPI BridgeReadFileToBlob(LPCWSTR pFileName, ID3DBlob **ppContents) { if (!ppContents) return E_INVALIDARG; *ppContents = nullptr; @@ -329,13 +321,11 @@ HRESULT PreprocessFromBlob(IDxcBlobEncoding *pSource, LPCWSTR pSourceName, } } -HRESULT WINAPI BridgeD3DPreprocess(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_opt_ LPCSTR pSourceName, - _In_opt_ const D3D_SHADER_MACRO *pDefines, - _In_opt_ ID3DInclude *pInclude, - _Out_ ID3DBlob **ppCodeText, - _Out_opt_ ID3DBlob **ppErrorMsgs) { +HRESULT WINAPI BridgeD3DPreprocess(LPCVOID pSrcData, SIZE_T SrcDataSize, + LPCSTR pSourceName, + const D3D_SHADER_MACRO *pDefines, + ID3DInclude *pInclude, ID3DBlob **ppCodeText, + ID3DBlob **ppErrorMsgs) { CComPtr library; CComPtr source; CComPtr includeHandler; diff --git a/tools/clang/tools/dxa/dxa.cpp b/tools/clang/tools/dxa/dxa.cpp index cf9339afdc..948cf2f603 100644 --- a/tools/clang/tools/dxa/dxa.cpp +++ b/tools/clang/tools/dxa/dxa.cpp @@ -447,7 +447,7 @@ void DxaContext::DumpReflection() { using namespace hlsl::options; #ifdef _WIN32 -int __cdecl main(int argc, _In_reads_z_(argc) char **argv) { +int __cdecl main(int argc, char **argv) { #else int main(int argc, const char **argv) { #endif diff --git a/tools/clang/tools/dxclib/dxc.cpp b/tools/clang/tools/dxclib/dxc.cpp index 717e2dd154..4e643ac1d8 100644 --- a/tools/clang/tools/dxclib/dxc.cpp +++ b/tools/clang/tools/dxclib/dxc.cpp @@ -146,8 +146,8 @@ class DxcContext { int VerifyRootSignature(); template - HRESULT CreateInstance(REFCLSID clsid, _Outptr_ TInterface** pResult) { - return m_dxcSupport.CreateInstance(clsid, pResult); + HRESULT CreateInstance(REFCLSID clsid, TInterface **pResult) { + return m_dxcSupport.CreateInstance(clsid, pResult); } public: @@ -166,7 +166,8 @@ class DxcContext { void GetCompilerVersionInfo(llvm::raw_string_ostream &OS); }; -static void WriteBlobToFile(_In_opt_ IDxcBlob *pBlob, llvm::StringRef FName, UINT32 defaultTextCodePage) { +static void WriteBlobToFile(IDxcBlob *pBlob, llvm::StringRef FName, + UINT32 defaultTextCodePage) { ::dxc::WriteBlobToFile(pBlob, StringRefWide(FName), defaultTextCodePage); } @@ -642,7 +643,8 @@ class DxcIncludeHandlerForInjectedSources : public IDxcIncludeHandler { return DoBasicQueryInterface(this, iid, ppvObject); } - HRESULT insertIncludeFile(_In_ LPCWSTR pFilename, _In_ IDxcBlobEncoding *pBlob, _In_ UINT32 dataLen) { + HRESULT insertIncludeFile(LPCWSTR pFilename, IDxcBlobEncoding *pBlob, + UINT32 dataLen) { try { #ifdef _WIN32 includeFiles.try_emplace(std::wstring(pFilename), pBlob); @@ -657,10 +659,8 @@ class DxcIncludeHandlerForInjectedSources : public IDxcIncludeHandler { return S_OK; } - HRESULT STDMETHODCALLTYPE LoadSource( - _In_ LPCWSTR pFilename, - _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource - ) override { + HRESULT STDMETHODCALLTYPE LoadSource(LPCWSTR pFilename, + IDxcBlob **ppIncludeSource) override { try { // Convert pFilename into native form for indexing as is done when the MD is created std::string FilenameStr8 = Unicode::WideToUTF8StringOrThrow(pFilename); diff --git a/tools/clang/tools/dxcompiler/dxcapi.cpp b/tools/clang/tools/dxcompiler/dxcapi.cpp index 53596beac9..485d486061 100644 --- a/tools/clang/tools/dxcompiler/dxcapi.cpp +++ b/tools/clang/tools/dxcompiler/dxcapi.cpp @@ -28,25 +28,25 @@ #include "dxc/DxilContainer/DxcContainerBuilder.h" #include -HRESULT CreateDxcCompiler(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcDiaDataSource(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcIntelliSense(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcCompilerArgs(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcUtils(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcRewriter(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcAssembler(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcOptimizer(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcContainerBuilder(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcLinker(_In_ REFIID riid, _Out_ LPVOID *ppv); -HRESULT CreateDxcPdbUtils(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcCompiler(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcDiaDataSource(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcIntelliSense(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcCompilerArgs(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcUtils(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcRewriter(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcAssembler(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcOptimizer(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcContainerBuilder(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcLinker(REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcPdbUtils(REFIID riid, _Out_ LPVOID *ppv); namespace hlsl { void CreateDxcContainerReflection(IDxcContainerReflection **ppResult); void CreateDxcLinker(IDxcContainerReflection **ppResult); } -HRESULT CreateDxcContainerReflection(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxcContainerReflection(REFIID riid, _Out_ LPVOID *ppv) { try { CComPtr pReflection; hlsl::CreateDxcContainerReflection(&pReflection); @@ -57,7 +57,7 @@ HRESULT CreateDxcContainerReflection(_In_ REFIID riid, _Out_ LPVOID *ppv) { } } -HRESULT CreateDxcContainerBuilder(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxcContainerBuilder(REFIID riid, _Out_ LPVOID *ppv) { // Call dxil.dll's containerbuilder *ppv = nullptr; const char *warning; @@ -75,10 +75,8 @@ HRESULT CreateDxcContainerBuilder(_In_ REFIID riid, _Out_ LPVOID *ppv) { return Result->QueryInterface(riid, ppv); } -static HRESULT ThreadMallocDxcCreateInstance( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { +static HRESULT ThreadMallocDxcCreateInstance(REFCLSID rclsid, REFIID riid, + _Out_ LPVOID *ppv) { HRESULT hr = S_OK; *ppv = nullptr; if (IsEqualCLSID(rclsid, CLSID_DxcCompiler)) { @@ -133,11 +131,8 @@ static HRESULT ThreadMallocDxcCreateInstance( return hr; } -DXC_API_IMPORT HRESULT __stdcall -DxcCreateInstance( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { +DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance(REFCLSID rclsid, REFIID riid, + _Out_ LPVOID *ppv) { if (ppv == nullptr) { return E_POINTER; } @@ -150,12 +145,10 @@ DxcCreateInstance( return hr; } -DXC_API_IMPORT HRESULT __stdcall -DxcCreateInstance2( - _In_ IMalloc *pMalloc, - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { +DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2(IMalloc *pMalloc, + REFCLSID rclsid, + REFIID riid, + _Out_ LPVOID *ppv) { if (ppv == nullptr) { return E_POINTER; } diff --git a/tools/clang/tools/dxcompiler/dxcassembler.cpp b/tools/clang/tools/dxcompiler/dxcassembler.cpp index 61ea25914f..4af411ea29 100644 --- a/tools/clang/tools/dxcompiler/dxcassembler.cpp +++ b/tools/clang/tools/dxcompiler/dxcassembler.cpp @@ -32,7 +32,7 @@ using namespace llvm; using namespace hlsl; // This declaration is used for the locally-linked validator. -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv); static bool HasDebugInfo(const Module &M) { for (Module::const_named_metadata_iterator NMI = M.named_metadata_begin(), @@ -58,16 +58,17 @@ class DxcAssembler : public IDxcAssembler { // Assemble dxil in ll or llvm bitcode to dxbc container. HRESULT STDMETHODCALLTYPE AssembleToContainer( - _In_ IDxcBlob *pShader, // Shader to assemble. - _COM_Outptr_ IDxcOperationResult **ppResult // Assemble output status, buffer, and errors + IDxcBlob *pShader, // Shader to assemble. + IDxcOperationResult * + *ppResult // Assemble output status, buffer, and errors ) override; }; // Assemble dxil in ll or llvm bitcode to dxbc container. HRESULT STDMETHODCALLTYPE DxcAssembler::AssembleToContainer( - _In_ IDxcBlob *pShader, // Shader to assemble. - _COM_Outptr_ IDxcOperationResult **ppResult // Assemble output status, buffer, and errors - ) { + IDxcBlob *pShader, // Shader to assemble. + IDxcOperationResult **ppResult // Assemble output status, buffer, and errors +) { if (pShader == nullptr || ppResult == nullptr) return E_POINTER; @@ -171,7 +172,7 @@ HRESULT STDMETHODCALLTYPE DxcAssembler::AssembleToContainer( return hr; } -HRESULT CreateDxcAssembler(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxcAssembler(REFIID riid, LPVOID *ppv) { CComPtr result = DxcAssembler::Alloc(DxcGetThreadMallocNoRef()); if (result == nullptr) { *ppv = nullptr; diff --git a/tools/clang/tools/dxcompiler/dxcfilesystem.cpp b/tools/clang/tools/dxcompiler/dxcfilesystem.cpp index 24974ea7ac..5f9d7cb5fb 100644 --- a/tools/clang/tools/dxcompiler/dxcfilesystem.cpp +++ b/tools/clang/tools/dxcompiler/dxcfilesystem.cpp @@ -340,10 +340,10 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { } public: - DxcArgsFileSystemImpl(_In_ IDxcBlobUtf8 *pSource, LPCWSTR pSourceName, - _In_opt_ IDxcIncludeHandler *pHandler, - _In_opt_ UINT32 defaultCodePage) - : m_pSource(pSource), m_pSourceName(pSourceName), m_pOutputStreamName(nullptr), m_includeLoader(pHandler), + DxcArgsFileSystemImpl(IDxcBlobUtf8 *pSource, LPCWSTR pSourceName, + IDxcIncludeHandler *pHandler, UINT32 defaultCodePage) + : m_pSource(pSource), m_pSourceName(pSourceName), + m_pOutputStreamName(nullptr), m_includeLoader(pHandler), m_bDisplayIncludeProcess(false), m_DefaultCodePage(defaultCodePage) { MakeAbsoluteOrCurDirRelativeW(m_pSourceName, m_pAbsSourceName); IFT(CreateReadOnlyBlobStream(m_pSource, &m_pSourceStream)); @@ -360,7 +360,7 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { s.write((char *)m_pStdOutStream->GetPtr(), m_pStdOutStream->GetPtrSize()); s.flush(); } - HRESULT CreateStdStreams(_In_ IMalloc* pMalloc) override { + HRESULT CreateStdStreams(IMalloc *pMalloc) override { DXASSERT(m_pStdOutStream == nullptr, "else already created"); CreateMemoryStream(pMalloc, &m_pStdOutStream); CreateMemoryStream(pMalloc, &m_pStdErrStream); @@ -436,16 +436,14 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { } ~DxcArgsFileSystemImpl() override { }; - BOOL FindNextFileW( - _In_ HANDLE hFindFile, - _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override { + BOOL FindNextFileW(HANDLE hFindFile, + LPWIN32_FIND_DATAW lpFindFileData) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - HANDLE FindFirstFileW( - _In_ LPCWSTR lpFileName, - _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override { + HANDLE FindFirstFileW(LPCWSTR lpFileName, + LPWIN32_FIND_DATAW lpFindFileData) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } @@ -454,12 +452,9 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { __debugbreak(); } - HANDLE CreateFileW( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes) throw() override { + HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, + DWORD dwShareMode, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes) throw() override { DXTRACE_FMT_APIFS("DxcArgsFileSystem::CreateFileW %S\n", lpFileName); DWORD findError; { @@ -488,15 +483,16 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { return INVALID_HANDLE_VALUE; } - BOOL SetFileTime(_In_ HANDLE hFile, - _In_opt_ const FILETIME *lpCreationTime, - _In_opt_ const FILETIME *lpLastAccessTime, - _In_opt_ const FILETIME *lpLastWriteTime) throw() override { + BOOL SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override { + BOOL GetFileInformationByHandle( + HANDLE hFile, + LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override { DxcArgsHandle argsHandle(hFile); ZeroMemory(lpFileInformation, sizeof(*lpFileInformation)); lpFileInformation->nFileIndexLow = (DWORD)(uintptr_t)hFile; @@ -526,7 +522,7 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { return FALSE; } - DWORD GetFileType(_In_ HANDLE hFile) throw() override { + DWORD GetFileType(HANDLE hFile) throw() override { DxcArgsHandle argsHandle(hFile); if (argsHandle.IsStdHandle()) { return FILE_TYPE_CHAR; @@ -540,15 +536,17 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { return FILE_TYPE_UNKNOWN; } - BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() override { + BOOL CreateHardLinkW(LPCWSTR lpFileName, + LPCWSTR lpExistingFileName) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() override { + BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, + DWORD dwFlags) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() override { + DWORD GetFileAttributesW(LPCWSTR lpFileName) throw() override { DXTRACE_FMT_APIFS("DxcArgsFileSystem::GetFileAttributesW %S\n", lpFileName); DWORD findError; { @@ -585,7 +583,7 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { return INVALID_FILE_ATTRIBUTES; } - BOOL CloseHandle(_In_ HANDLE hObject) throw() override { + BOOL CloseHandle(HANDLE hObject) throw() override { // Not actually closing handle. Would allow improper usage, but simplifies // query/open/usage patterns. if (IsKnownHandle(hObject)) { @@ -595,61 +593,59 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() override { + BOOL DeleteFileW(LPCWSTR lpFileName) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - BOOL RemoveDirectoryW(_In_ LPCWSTR lpFileName) throw() override { + BOOL RemoveDirectoryW(LPCWSTR lpFileName) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() override { + BOOL CreateDirectoryW(LPCWSTR lpPathName) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - _Success_(return != 0 && return < nBufferLength) - DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return +1) LPWSTR lpBuffer) throw() override { + DWORD GetCurrentDirectoryW(DWORD nBufferLength, + LPWSTR lpBuffer) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - _Success_(return != 0 && return < nSize) - DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return +1) LPWSTR lpFilename, DWORD nSize) throw() override { + DWORD GetMainModuleFileNameW(LPWSTR lpFilename, + DWORD nSize) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return +1) LPWSTR lpBuffer) throw() override { + DWORD GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() override { + BOOLEAN CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, + LPCWSTR lpTargetFileName, + DWORD dwFlags) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } bool SupportsCreateSymbolicLink() throw() override { return false; } - BOOL ReadFile(_In_ HANDLE hFile, _Out_bytecap_(nNumberOfBytesToRead) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() override { + BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } - HANDLE CreateFileMappingW( - _In_ HANDLE hFile, - _In_ DWORD flProtect, - _In_ DWORD dwMaximumSizeHigh, - _In_ DWORD dwMaximumSizeLow) throw() override { + HANDLE CreateFileMappingW(HANDLE hFile, DWORD flProtect, + DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow) throw() override { SetLastError(ERROR_NOT_CAPABLE); return INVALID_HANDLE_VALUE; } - LPVOID MapViewOfFile( - _In_ HANDLE hFileMappingObject, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwFileOffsetHigh, - _In_ DWORD dwFileOffsetLow, - _In_ SIZE_T dwNumberOfBytesToMap) throw() override { + LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap) throw() override { SetLastError(ERROR_NOT_CAPABLE); return nullptr; } - BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() override { + BOOL UnmapViewOfFile(LPCVOID lpBaseAddress) throw() override { SetLastError(ERROR_NOT_CAPABLE); return FALSE; } @@ -712,10 +708,10 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { int setmode(int fd, int mode) throw() override { return 0; } - errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() override { + errno_t resize_file(LPCWSTR path, uint64_t size) throw() override { return 0; } - int Read(int fd, _Out_bytecap_(count) void* buffer, unsigned int count) throw() override { + int Read(int fd, void *buffer, unsigned int count) throw() override { CComPtr stream; GetStreamForFD(fd, &stream); if (stream == nullptr) { @@ -732,7 +728,7 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { return (int)cbRead; } - int Write(int fd, _In_bytecount_(count) const void* buffer, unsigned int count) throw() override { + int Write(int fd, const void *buffer, unsigned int count) throw() override { CComPtr stream; GetStreamForFD(fd, &stream); if (stream == nullptr) { @@ -836,11 +832,10 @@ class DxcArgsFileSystemImpl : public DxcArgsFileSystem { namespace dxcutil { -DxcArgsFileSystem * -CreateDxcArgsFileSystem( - _In_ IDxcBlobUtf8 *pSource, _In_ LPCWSTR pSourceName, - _In_opt_ IDxcIncludeHandler *pIncludeHandler, - _In_opt_ UINT32 defaultCodePage) { +DxcArgsFileSystem *CreateDxcArgsFileSystem(IDxcBlobUtf8 *pSource, + LPCWSTR pSourceName, + IDxcIncludeHandler *pIncludeHandler, + UINT32 defaultCodePage) { return new DxcArgsFileSystemImpl(pSource, pSourceName, pIncludeHandler, defaultCodePage); } diff --git a/tools/clang/tools/dxcompiler/dxclibrary.cpp b/tools/clang/tools/dxcompiler/dxclibrary.cpp index 7e0b6f0879..391d29fd1c 100644 --- a/tools/clang/tools/dxcompiler/dxclibrary.cpp +++ b/tools/clang/tools/dxcompiler/dxclibrary.cpp @@ -46,9 +46,10 @@ class DxcIncludeHandlerForFS : public IDxcIncludeHandler { } HRESULT STDMETHODCALLTYPE LoadSource( - _In_ LPCWSTR pFilename, // Candidate filename. - _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource // Resultant source object for included file, nullptr if not found. - ) override { + LPCWSTR pFilename, // Candidate filename. + IDxcBlob **ppIncludeSource // Resultant source object for included file, + // nullptr if not found. + ) override { try { CComPtr pEncoding; HRESULT hr = ::hlsl::DxcCreateBlobFromFile(m_pMalloc, pFilename, nullptr, &pEncoding); @@ -92,9 +93,9 @@ class DxcCompilerArgs : public IDxcCompilerArgs { // Add additional arguments or defines here, if desired. HRESULT STDMETHODCALLTYPE AddArguments( - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments to add - _In_ UINT32 argCount // Number of arguments to add - ) override { + LPCWSTR *pArguments, // Array of pointers to arguments to add + UINT32 argCount // Number of arguments to add + ) override { DxcThreadMalloc TM(m_pMalloc); try { for (UINT32 i = 0; i < argCount; ++i) { @@ -105,9 +106,9 @@ class DxcCompilerArgs : public IDxcCompilerArgs { CATCH_CPP_RETURN_HRESULT(); } HRESULT STDMETHODCALLTYPE AddArgumentsUTF8( - _In_opt_count_(argCount)LPCSTR *pArguments, // Array of pointers to UTF-8 arguments to add - _In_ UINT32 argCount // Number of arguments to add - ) override { + LPCSTR *pArguments, // Array of pointers to UTF-8 arguments to add + UINT32 argCount // Number of arguments to add + ) override { DxcThreadMalloc TM(m_pMalloc); try { for (UINT32 i = 0; i < argCount; ++i) { @@ -118,9 +119,9 @@ class DxcCompilerArgs : public IDxcCompilerArgs { CATCH_CPP_RETURN_HRESULT(); } HRESULT STDMETHODCALLTYPE AddDefines( - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount // Number of defines - ) override { + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount // Number of defines + ) override { DxcThreadMalloc TM(m_pMalloc); try { for (UINT32 i = 0; i < defineCount; ++i) { @@ -150,8 +151,8 @@ class DxcCompilerArgs : public IDxcCompilerArgs { // arg list when already specified separatly. This would lead to duplicate or // even contradictory arguments in the arg list, visible in debug information. HRESULT AddArgumentsOptionallySkippingEntryAndTarget( - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments to add - _In_ UINT32 argCount, // Number of arguments to add + LPCWSTR *pArguments, // Array of pointers to arguments to add + UINT32 argCount, // Number of arguments to add bool skipEntry, bool skipTarget) { DxcThreadMalloc TM(m_pMalloc); bool skipNext = false; @@ -191,29 +192,30 @@ class DxcLibrary : public IDxcLibrary { ULONG STDMETHODCALLTYPE AddRef() override; ULONG STDMETHODCALLTYPE Release() override; HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override; - HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) override; - HRESULT STDMETHODCALLTYPE CreateBlobFromBlob( - _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) override; - HRESULT STDMETHODCALLTYPE CreateBlobFromFile( - LPCWSTR pFileName, _In_opt_ UINT32* pCodePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override; - HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override; - HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override; + HRESULT STDMETHODCALLTYPE SetMalloc(IMalloc *pMalloc) override; + HRESULT STDMETHODCALLTYPE CreateBlobFromBlob(IDxcBlob *pBlob, UINT32 offset, + UINT32 length, + IDxcBlob **ppResult) override; + HRESULT STDMETHODCALLTYPE + CreateBlobFromFile(LPCWSTR pFileName, UINT32 *pCodePage, + IDxcBlobEncoding **pBlobEncoding) override; + HRESULT STDMETHODCALLTYPE + CreateBlobWithEncodingFromPinned(LPCVOID pText, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) override; + HRESULT STDMETHODCALLTYPE + CreateBlobWithEncodingOnHeapCopy(LPCVOID pText, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) override; HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc( - _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override; - HRESULT STDMETHODCALLTYPE CreateIncludeHandler( - _COM_Outptr_ IDxcIncludeHandler **ppResult) override; - HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) override; - HRESULT STDMETHODCALLTYPE GetBlobAsUtf8( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override; - HRESULT STDMETHODCALLTYPE GetBlobAsWide( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override; + LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) override; + HRESULT STDMETHODCALLTYPE + CreateIncludeHandler(IDxcIncludeHandler **ppResult) override; + HRESULT STDMETHODCALLTYPE + CreateStreamFromBlobReadOnly(IDxcBlob *pBlob, IStream **ppStream) override; + HRESULT STDMETHODCALLTYPE + GetBlobAsUtf8(IDxcBlob *pBlob, IDxcBlobEncoding **pBlobEncoding) override; + HRESULT STDMETHODCALLTYPE + GetBlobAsWide(IDxcBlob *pBlob, IDxcBlobEncoding **pBlobEncoding) override; }; class DxcUtils : public IDxcUtils { @@ -234,8 +236,9 @@ class DxcUtils : public IDxcUtils { return hr; } - HRESULT STDMETHODCALLTYPE CreateBlobFromBlob( - _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) override { + HRESULT STDMETHODCALLTYPE CreateBlobFromBlob(IDxcBlob *pBlob, UINT32 offset, + UINT32 length, + IDxcBlob **ppResult) override { DxcThreadMalloc TM(m_pMalloc); try { return ::hlsl::DxcCreateBlobFromBlob(pBlob, offset, length, ppResult); @@ -243,9 +246,9 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - HRESULT STDMETHODCALLTYPE CreateBlobFromPinned( - _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override { + HRESULT STDMETHODCALLTYPE + CreateBlobFromPinned(LPCVOID pData, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) override { DxcThreadMalloc TM(m_pMalloc); try { return ::hlsl::DxcCreateBlobWithEncodingFromPinned(pData, size, codePage, pBlobEncoding); @@ -253,9 +256,9 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - virtual HRESULT STDMETHODCALLTYPE MoveToBlob( - _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override { + virtual HRESULT STDMETHODCALLTYPE + MoveToBlob(LPCVOID pData, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) override { DxcThreadMalloc TM(m_pMalloc); try { return ::hlsl::DxcCreateBlobWithEncodingOnMalloc(pData, pIMalloc, size, codePage, pBlobEncoding); @@ -263,9 +266,9 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - virtual HRESULT STDMETHODCALLTYPE CreateBlob( - _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override { + virtual HRESULT STDMETHODCALLTYPE + CreateBlob(LPCVOID pData, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) override { DxcThreadMalloc TM(m_pMalloc); try { return ::hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pData, size, codePage, pBlobEncoding); @@ -273,15 +276,15 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - virtual HRESULT STDMETHODCALLTYPE LoadFile( - _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* pCodePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) override { + virtual HRESULT STDMETHODCALLTYPE + LoadFile(LPCWSTR pFileName, UINT32 *pCodePage, + IDxcBlobEncoding **pBlobEncoding) override { DxcThreadMalloc TM(m_pMalloc); return ::hlsl::DxcCreateBlobFromFile(pFileName, pCodePage, pBlobEncoding); } - HRESULT STDMETHODCALLTYPE CreateReadOnlyStreamFromBlob( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) override { + HRESULT STDMETHODCALLTYPE + CreateReadOnlyStreamFromBlob(IDxcBlob *pBlob, IStream **ppStream) override { DxcThreadMalloc TM(m_pMalloc); try { return ::hlsl::CreateReadOnlyBlobStream(pBlob, ppStream); @@ -289,8 +292,8 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - virtual HRESULT STDMETHODCALLTYPE CreateDefaultIncludeHandler( - _COM_Outptr_ IDxcIncludeHandler **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + CreateDefaultIncludeHandler(IDxcIncludeHandler **ppResult) override { DxcThreadMalloc TM(m_pMalloc); CComPtr result; result = DxcIncludeHandlerForFS::Alloc(m_pMalloc); @@ -301,14 +304,14 @@ class DxcUtils : public IDxcUtils { return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **pBlobEncoding) override { + virtual HRESULT STDMETHODCALLTYPE + GetBlobAsUtf8(IDxcBlob *pBlob, IDxcBlobUtf8 **pBlobEncoding) override { DxcThreadMalloc TM(m_pMalloc); return ::hlsl::DxcGetBlobAsUtf8(pBlob, m_pMalloc, pBlobEncoding); } - virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **pBlobEncoding) override { + virtual HRESULT STDMETHODCALLTYPE + GetBlobAsWide(IDxcBlob *pBlob, IDxcBlobWide **pBlobEncoding) override { DxcThreadMalloc TM(m_pMalloc); try { return ::hlsl::DxcGetBlobAsWide(pBlob, m_pMalloc, pBlobEncoding); @@ -316,11 +319,9 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - - virtual HRESULT STDMETHODCALLTYPE GetDxilContainerPart( _In_ const DxcBuffer *pShader, - _In_ UINT32 DxcPart, - _Outptr_result_nullonfailure_ void **ppPartData, - _Out_ UINT32 *pPartSizeInBytes) override { + virtual HRESULT STDMETHODCALLTYPE + GetDxilContainerPart(const DxcBuffer *pShader, UINT32 DxcPart, + void **ppPartData, UINT32 *pPartSizeInBytes) override { if (!ppPartData || !pPartSizeInBytes) return E_INVALIDARG; @@ -339,7 +340,7 @@ class DxcUtils : public IDxcUtils { } virtual HRESULT STDMETHODCALLTYPE CreateReflection( - _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) override { + const DxcBuffer *pData, REFIID iid, void **ppvReflection) override { if (!pData || !pData->Ptr || pData->Size < 8 || pData->Encoding != DXC_CP_ACP || !ppvReflection) return E_INVALIDARG; @@ -429,16 +430,16 @@ class DxcUtils : public IDxcUtils { } virtual HRESULT STDMETHODCALLTYPE BuildArguments( - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name. (-E) - _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile. (-T) - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 NumArguments, // Number of arguments - _In_count_(NumDefines) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 NumDefines, // Number of defines - _COM_Outptr_ IDxcCompilerArgs **ppArgs // Arguments you can use with Compile() method - ) override { + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR pEntryPoint, // Entry point name. (-E) + LPCWSTR pTargetProfile, // Shader profile to compile. (-T) + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 NumArguments, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 NumDefines, // Number of defines + IDxcCompilerArgs **ppArgs // Arguments you can use with Compile() method + ) override { DxcThreadMalloc TM(m_pMalloc); try { @@ -479,10 +480,8 @@ class DxcUtils : public IDxcUtils { CATCH_CPP_RETURN_HRESULT(); } - virtual HRESULT STDMETHODCALLTYPE - GetPDBContents(_In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash, - _COM_Outptr_ IDxcBlob **ppContainer) override - { + virtual HRESULT STDMETHODCALLTYPE GetPDBContents( + IDxcBlob *pPDBBlob, IDxcBlob **ppHash, IDxcBlob **ppContainer) override { DxcThreadMalloc TM(m_pMalloc); try { @@ -493,7 +492,6 @@ class DxcUtils : public IDxcUtils { } CATCH_CPP_RETURN_HRESULT(); } - }; ////////////////////////////////////////////////////////////// @@ -508,66 +506,67 @@ HRESULT STDMETHODCALLTYPE DxcLibrary::QueryInterface(REFIID iid, void **ppvObjec return self.QueryInterface(iid, ppvObject); } -HRESULT STDMETHODCALLTYPE DxcLibrary::SetMalloc(_In_opt_ IMalloc *pMalloc) { +HRESULT STDMETHODCALLTYPE DxcLibrary::SetMalloc(IMalloc *pMalloc) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE DxcLibrary::CreateBlobFromBlob( - _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) { +HRESULT STDMETHODCALLTYPE DxcLibrary::CreateBlobFromBlob(IDxcBlob *pBlob, + UINT32 offset, + UINT32 length, + IDxcBlob **ppResult) { return self.CreateBlobFromBlob(pBlob, offset, length, ppResult); } HRESULT STDMETHODCALLTYPE DxcLibrary::CreateBlobFromFile( - LPCWSTR pFileName, _In_opt_ UINT32* pCodePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { + LPCWSTR pFileName, UINT32 *pCodePage, IDxcBlobEncoding **pBlobEncoding) { return self.LoadFile(pFileName, pCodePage, pBlobEncoding); } HRESULT STDMETHODCALLTYPE DxcLibrary::CreateBlobWithEncodingFromPinned( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { + LPCVOID pText, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) { return self.CreateBlobFromPinned(pText, size, codePage, pBlobEncoding); } HRESULT STDMETHODCALLTYPE DxcLibrary::CreateBlobWithEncodingOnHeapCopy( - _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { + LPCVOID pText, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) { return self.CreateBlob(pText, size, codePage, pBlobEncoding); } HRESULT STDMETHODCALLTYPE DxcLibrary::CreateBlobWithEncodingOnMalloc( - _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, - _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { + LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, + IDxcBlobEncoding **pBlobEncoding) { return self.MoveToBlob(pText, pIMalloc, size, codePage, pBlobEncoding); } -HRESULT STDMETHODCALLTYPE DxcLibrary::CreateIncludeHandler( - _COM_Outptr_ IDxcIncludeHandler **ppResult) { +HRESULT STDMETHODCALLTYPE +DxcLibrary::CreateIncludeHandler(IDxcIncludeHandler **ppResult) { return self.CreateDefaultIncludeHandler(ppResult); } -HRESULT STDMETHODCALLTYPE DxcLibrary::CreateStreamFromBlobReadOnly( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) { +HRESULT STDMETHODCALLTYPE +DxcLibrary::CreateStreamFromBlobReadOnly(IDxcBlob *pBlob, IStream **ppStream) { return self.CreateReadOnlyStreamFromBlob(pBlob, ppStream); } -HRESULT STDMETHODCALLTYPE DxcLibrary::GetBlobAsUtf8( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { +HRESULT STDMETHODCALLTYPE +DxcLibrary::GetBlobAsUtf8(IDxcBlob *pBlob, IDxcBlobEncoding **pBlobEncoding) { CComPtr pBlobUtf8; IFR(self.GetBlobAsUtf8(pBlob, &pBlobUtf8)); IFR(pBlobUtf8->QueryInterface(pBlobEncoding)); return S_OK; } -HRESULT STDMETHODCALLTYPE DxcLibrary::GetBlobAsWide( - _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { +HRESULT STDMETHODCALLTYPE +DxcLibrary::GetBlobAsWide(IDxcBlob *pBlob, IDxcBlobEncoding **pBlobEncoding) { CComPtr pBlobUtf16; IFR(self.GetBlobAsWide(pBlob, &pBlobUtf16)); IFR(pBlobUtf16->QueryInterface(pBlobEncoding)); return S_OK; } -HRESULT CreateDxcCompilerArgs(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcCompilerArgs(REFIID riid, LPVOID *ppv) { CComPtr result = DxcCompilerArgs::Alloc(DxcGetThreadMallocNoRef()); if (result == nullptr) { *ppv = nullptr; @@ -577,7 +576,7 @@ HRESULT CreateDxcCompilerArgs(_In_ REFIID riid, _Out_ LPVOID* ppv) { return result.p->QueryInterface(riid, ppv); } -HRESULT CreateDxcUtils(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcUtils(REFIID riid, LPVOID *ppv) { CComPtr result = DxcUtils::Alloc(DxcGetThreadMallocNoRef()); if (result == nullptr) { *ppv = nullptr; diff --git a/tools/clang/tools/dxcompiler/dxclinker.cpp b/tools/clang/tools/dxcompiler/dxclinker.cpp index da0a3b743b..5b0f445aa4 100644 --- a/tools/clang/tools/dxcompiler/dxclinker.cpp +++ b/tools/clang/tools/dxcompiler/dxclinker.cpp @@ -42,7 +42,7 @@ using namespace hlsl; using namespace llvm; // This declaration is used for the locally-linked validator. -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv); struct DeserializedDxilCompilerVersion { const hlsl::DxilCompilerVersion DCV; @@ -92,25 +92,21 @@ class DxcLinker : public IDxcLinker, public IDxcContainerEvent { DXC_MICROCOM_TM_CTOR(DxcLinker) // Register a library with name to ref it later. - HRESULT RegisterLibrary( - _In_opt_ LPCWSTR pLibName, // Name of the library. - _In_ IDxcBlob *pLib // Library to add. - ) override; + HRESULT RegisterLibrary(LPCWSTR pLibName, // Name of the library. + IDxcBlob *pLib // Library to add. + ) override; // Links the shader and produces a shader blob that the Direct3D runtime can // use. HRESULT STDMETHODCALLTYPE Link( - _In_opt_ LPCWSTR pEntryName, // Entry point name - _In_ LPCWSTR pTargetProfile, // shader profile to link - _In_count_(libCount) - const LPCWSTR *pLibNames, // Array of library names to link - UINT32 libCount, // Number of libraries to link - _In_count_(argCount) - const LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _COM_Outptr_ IDxcOperationResult * - *ppResult // Linker output status, buffer, and errors - ) override; + LPCWSTR pEntryName, // Entry point name + LPCWSTR pTargetProfile, // shader profile to link + const LPCWSTR *pLibNames, // Array of library names to link + UINT32 libCount, // Number of libraries to link + const LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + IDxcOperationResult **ppResult // Linker output status, buffer, and errors + ) override; HRESULT STDMETHODCALLTYPE RegisterDxilContainerEventHandler( IDxcContainerEventsHandler *pHandler, UINT64 *pCookie) override { @@ -180,8 +176,8 @@ class DxcLinker : public IDxcLinker, public IDxcContainerEvent { }; HRESULT -DxcLinker::RegisterLibrary(_In_opt_ LPCWSTR pLibName, // Name of the library. - _In_ IDxcBlob *pBlob // Library to add. +DxcLinker::RegisterLibrary(LPCWSTR pLibName, // Name of the library. + IDxcBlob *pBlob // Library to add. ) { if (!pLibName || !pBlob) return E_INVALIDARG; @@ -236,16 +232,13 @@ DxcLinker::RegisterLibrary(_In_opt_ LPCWSTR pLibName, // Name of the library. // Links the shader and produces a shader blob that the Direct3D runtime can // use. HRESULT STDMETHODCALLTYPE DxcLinker::Link( - _In_opt_ LPCWSTR pEntryName, // Entry point name - _In_ LPCWSTR pTargetProfile, // shader profile to link - _In_count_(libCount) - const LPCWSTR *pLibNames, // Array of library names to link - UINT32 libCount, // Number of libraries to link - _In_count_(argCount) - const LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _COM_Outptr_ IDxcOperationResult * - *ppResult // Linker output status, buffer, and errors + LPCWSTR pEntryName, // Entry point name + LPCWSTR pTargetProfile, // shader profile to link + const LPCWSTR *pLibNames, // Array of library names to link + UINT32 libCount, // Number of libraries to link + const LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + IDxcOperationResult **ppResult // Linker output status, buffer, and errors ) { if (!pTargetProfile || !pLibNames || libCount == 0 || !ppResult) return E_INVALIDARG; @@ -487,7 +480,7 @@ HRESULT STDMETHODCALLTYPE DxcLinker::Link( return hr; } -HRESULT CreateDxcLinker(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxcLinker(REFIID riid, LPVOID *ppv) { *ppv = nullptr; try { CComPtr result(DxcLinker::Alloc(DxcGetThreadMallocNoRef())); diff --git a/tools/clang/tools/dxcompiler/dxcompileradapter.h b/tools/clang/tools/dxcompiler/dxcompileradapter.h index 55b2dff888..3b5e6fbc37 100644 --- a/tools/clang/tools/dxcompiler/dxcompileradapter.h +++ b/tools/clang/tools/dxcompiler/dxcompileradapter.h @@ -30,19 +30,22 @@ class DxcCompilerAdapter: public IDxcCompiler2 // Internal wrapper for compile HRESULT WrapCompile( - _In_ BOOL bPreprocess, // Preprocess mode - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_ LPCWSTR pEntryPoint, // Entry point name - _In_ LPCWSTR pTargetProfile, // Shader profile to compile - _In_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult, // Compiler output status, buffer, and errors - _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. - _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob + BOOL bPreprocess, // Preprocess mode + IDxcBlob *pSource, // Source text to compile + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR pEntryPoint, // Entry point name + LPCWSTR pTargetProfile, // Shader profile to compile + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult, // Compiler output status, buffer, and errors + LPWSTR *ppDebugBlobName, // Suggested file name for debug blob. + IDxcBlob **ppDebugBlob // Debug blob ); public: @@ -55,17 +58,20 @@ class DxcCompilerAdapter: public IDxcCompiler2 // Compile a single entry point to the target shader model HRESULT STDMETHODCALLTYPE Compile( - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_ LPCWSTR pEntryPoint, // entry point name - _In_ LPCWSTR pTargetProfile, // shader profile to compile - _In_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors - ) override { + IDxcBlob *pSource, // Source text to compile + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR pEntryPoint, // entry point name + LPCWSTR pTargetProfile, // shader profile to compile + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult // Compiler output status, buffer, and errors + ) override { return CompileWithDebug(pSource, pSourceName, pEntryPoint, pTargetProfile, pArguments, argCount, pDefines, defineCount, pIncludeHandler, ppResult, nullptr, nullptr); @@ -73,40 +79,46 @@ class DxcCompilerAdapter: public IDxcCompiler2 // Preprocess source text HRESULT STDMETHODCALLTYPE Preprocess( - _In_ IDxcBlob *pSource, // Source text to preprocess - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult // Preprocessor output status, buffer, and errors - ) override; + IDxcBlob *pSource, // Source text to preprocess + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult // Preprocessor output status, buffer, and errors + ) override; // Disassemble a program. HRESULT STDMETHODCALLTYPE Disassemble( - _In_ IDxcBlob *pSource, // Program to disassemble. - _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text. - ) override; + IDxcBlob *pSource, // Program to disassemble. + IDxcBlobEncoding **ppDisassembly // Disassembly text. + ) override; // ================ IDxcCompiler2 ================ - // Compile a single entry point to the target shader model with debug information. + // Compile a single entry point to the target shader model with debug + // information. HRESULT STDMETHODCALLTYPE CompileWithDebug( - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_ LPCWSTR pEntryPoint, // Entry point name - _In_ LPCWSTR pTargetProfile, // Shader profile to compile - _In_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult, // Compiler output status, buffer, and errors - _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. - _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob - ) override; + IDxcBlob *pSource, // Source text to compile + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR pEntryPoint, // Entry point name + LPCWSTR pTargetProfile, // Shader profile to compile + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult, // Compiler output status, buffer, and errors + LPWSTR *ppDebugBlobName, // Suggested file name for debug blob. + IDxcBlob **ppDebugBlob // Debug blob + ) override; }; } diff --git a/tools/clang/tools/dxcompiler/dxcompilerobj.cpp b/tools/clang/tools/dxcompiler/dxcompilerobj.cpp index 1384060f74..b1342ee379 100644 --- a/tools/clang/tools/dxcompiler/dxcompilerobj.cpp +++ b/tools/clang/tools/dxcompiler/dxcompilerobj.cpp @@ -77,17 +77,15 @@ using namespace hlsl; using std::string; // This declaration is used for the locally-linked validator. -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv); // This internal call allows the validator to avoid having to re-deserialize // the module. It trusts that the caller didn't make any changes and is // kept internal because the layout of the module class may change based // on changes across modules, or picking a different compiler version or CRT. -HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, - _In_ llvm::Module *pModule, - _In_ llvm::Module *pDebugModule, - _In_ IDxcBlob *pShader, UINT32 Flags, - _In_ IDxcOperationResult **ppResult); +HRESULT RunInternalValidator(IDxcValidator *pValidator, llvm::Module *pModule, + llvm::Module *pDebugModule, IDxcBlob *pShader, + UINT32 Flags, IDxcOperationResult **ppResult); static bool ShouldBeCopiedIntoPDB(UINT32 FourCC) { switch (FourCC) { @@ -413,10 +411,8 @@ class HLSLExtensionsCodegenHelperImpl : public HLSLExtensionsCodegenHelper { } }; -static void CreateDefineStrings( - _In_count_(defineCount) const DxcDefine *pDefines, - UINT defineCount, - std::vector &defines) { +static void CreateDefineStrings(const DxcDefine *pDefines, UINT defineCount, + std::vector &defines) { // Not very efficient but also not very important. for (UINT32 i = 0; i < defineCount; i++) { CW2A utf8Name(pDefines[i].Name, CP_UTF8); @@ -492,12 +488,13 @@ class DxcCompiler : public IDxcCompiler3, // Compile a single entry point to the target shader model with debug information. HRESULT STDMETHODCALLTYPE Compile( - _In_ const DxcBuffer *pSource, // Source text to compile - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _In_ REFIID riid, _Out_ LPVOID *ppResult // IDxcResult: status, buffer, and errors - ) override { + const DxcBuffer *pSource, // Source text to compile + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + REFIID riid, LPVOID *ppResult // IDxcResult: status, buffer, and errors + ) override { llvm::TimeTraceScope TimeScope("Compile", StringRef("")); if (pSource == nullptr || ppResult == nullptr || (argCount > 0 && pArguments == nullptr)) @@ -1148,7 +1145,7 @@ class DxcCompiler : public IDxcCompiler3, } catch (std::bad_alloc &) { hr = E_OUTOFMEMORY; } catch (hlsl::Exception &e) { - _Analysis_assume_(DXC_FAILED(e.hr)); + assert(DXC_FAILED(e.hr)); CComPtr pResult; hr = e.hr; std::string msg("Internal Compiler error: "); @@ -1175,9 +1172,11 @@ class DxcCompiler : public IDxcCompiler3, // Disassemble a program. virtual HRESULT STDMETHODCALLTYPE Disassemble( - _In_ const DxcBuffer *pObject, // Program to disassemble: dxil container or bitcode. - _In_ REFIID riid, _Out_ LPVOID *ppResult // IDxcResult: status, disassembly text, and errors - ) override { + const DxcBuffer + *pObject, // Program to disassemble: dxil container or bitcode. + REFIID riid, + LPVOID *ppResult // IDxcResult: status, disassembly text, and errors + ) override { if (pObject == nullptr || ppResult == nullptr) return E_INVALIDARG; if (!(IsEqualIID(riid, __uuidof(IDxcResult)) || @@ -1217,7 +1216,7 @@ class DxcCompiler : public IDxcCompiler3, } catch (std::bad_alloc &) { hr = E_OUTOFMEMORY; } catch (hlsl::Exception &e) { - _Analysis_assume_(DXC_FAILED(e.hr)); + assert(DXC_FAILED(e.hr)); hr = e.hr; if (SUCCEEDED(DxcResult::Create(e.hr, DXC_OUT_NONE, { DxcOutputObject::ErrorOutput(CP_UTF8, @@ -1235,12 +1234,12 @@ class DxcCompiler : public IDxcCompiler3, } void SetupCompilerForCompile(CompilerInstance &compiler, - _In_ DxcLangExtensionsHelper *helper, - _In_ LPCSTR pMainFile, _In_ TextDiagnosticPrinter *diagPrinter, - _In_ std::vector& defines, - _In_ hlsl::options::DxcOpts &Opts, - _In_count_(argCount) LPCWSTR *pArguments, - _In_ UINT32 argCount) { + DxcLangExtensionsHelper *helper, + LPCSTR pMainFile, + TextDiagnosticPrinter *diagPrinter, + std::vector &defines, + hlsl::options::DxcOpts &Opts, + LPCWSTR *pArguments, UINT32 argCount) { // Setup a compiler instance. std::shared_ptr targetOptions(new TargetOptions); targetOptions->Triple = "dxil-ms-dx"; @@ -1466,7 +1465,8 @@ class DxcCompiler : public IDxcCompiler3, } // IDxcVersionInfo - HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) override { + HRESULT STDMETHODCALLTYPE GetVersion(UINT32 *pMajor, + UINT32 *pMinor) override { if (pMajor == nullptr || pMinor == nullptr) return E_INVALIDARG; *pMajor = DXIL::kDxilMajor; @@ -1474,9 +1474,9 @@ class DxcCompiler : public IDxcCompiler3, return S_OK; } HRESULT STDMETHODCALLTYPE GetCustomVersionString( - _Outptr_result_z_ char **pVersionString // Custom version string for compiler. (Must be CoTaskMemFree()'d!) - ) override - { + char **pVersionString // Custom version string for compiler. (Must be + // CoTaskMemFree()'d!) + ) override { size_t size = strlen(RC_FILE_VERSION); char *const result = (char *)CoTaskMemAlloc(size + 1); if (result == nullptr) @@ -1487,8 +1487,8 @@ class DxcCompiler : public IDxcCompiler3, } #ifdef SUPPORT_QUERY_GIT_COMMIT_INFO - HRESULT STDMETHODCALLTYPE GetCommitInfo(_Out_ UINT32 *pCommitCount, - _Out_ char **pCommitHash) override { + HRESULT STDMETHODCALLTYPE GetCommitInfo(UINT32 *pCommitCount, + char **pCommitHash) override { if (pCommitCount == nullptr || pCommitHash == nullptr) return E_INVALIDARG; @@ -1504,7 +1504,7 @@ class DxcCompiler : public IDxcCompiler3, } #endif // SUPPORT_QUERY_GIT_COMMIT_INFO - HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) override { + HRESULT STDMETHODCALLTYPE GetFlags(UINT32 *pFlags) override { if (pFlags == nullptr) return E_INVALIDARG; *pFlags = DxcVersionInfoFlags_None; @@ -1529,15 +1529,17 @@ HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::QueryInterface(REFIID iid, void ** // Preprocess source text HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::Preprocess( - _In_ IDxcBlob *pSource, // Source text to preprocess - _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) - const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult // Preprocessor output status, buffer, and errors + IDxcBlob *pSource, // Source text to preprocess + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult // Preprocessor output status, buffer, and errors ) { if (pSource == nullptr || ppResult == nullptr || (defineCount > 0 && pDefines == nullptr) || @@ -1557,8 +1559,8 @@ HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::Preprocess( // Disassemble a program. HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::Disassemble( - _In_ IDxcBlob *pProgram, // Program to disassemble. - _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text. + IDxcBlob *pProgram, // Program to disassemble. + IDxcBlobEncoding **ppDisassembly // Disassembly text. ) { if (pProgram == nullptr || ppDisassembly == nullptr) return E_INVALIDARG; @@ -1581,21 +1583,24 @@ HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::Disassemble( return hr; } -HRESULT CreateDxcUtils(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcUtils(REFIID riid, LPVOID *ppv); HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::CompileWithDebug( - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_ LPCWSTR pEntryPoint, // Entry point name - _In_ LPCWSTR pTargetProfile, // Shader profile to compile - _In_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult, // Compiler output status, buffer, and errors - _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. - _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob + IDxcBlob *pSource, // Source text to compile + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR pEntryPoint, // Entry point name + LPCWSTR pTargetProfile, // Shader profile to compile + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult, // Compiler output status, buffer, and errors + LPWSTR *ppDebugBlobName, // Suggested file name for debug blob. + IDxcBlob **ppDebugBlob // Debug blob ) { if (pSource == nullptr || ppResult == nullptr || (defineCount > 0 && pDefines == nullptr) || @@ -1618,19 +1623,22 @@ HRESULT STDMETHODCALLTYPE DxcCompilerAdapter::CompileWithDebug( } HRESULT DxcCompilerAdapter::WrapCompile( - _In_ BOOL bPreprocess, // Preprocess mode - _In_ IDxcBlob *pSource, // Source text to compile - _In_opt_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. - _In_ LPCWSTR pEntryPoint, // Entry point name - _In_ LPCWSTR pTargetProfile, // Shader profile to compile - _In_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments - _In_ UINT32 argCount, // Number of arguments - _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines - _In_ UINT32 defineCount, // Number of defines - _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) - _COM_Outptr_ IDxcOperationResult **ppResult, // Compiler output status, buffer, and errors - _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. - _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob + BOOL bPreprocess, // Preprocess mode + IDxcBlob *pSource, // Source text to compile + LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and + // include handlers. + LPCWSTR pEntryPoint, // Entry point name + LPCWSTR pTargetProfile, // Shader profile to compile + LPCWSTR *pArguments, // Array of pointers to arguments + UINT32 argCount, // Number of arguments + const DxcDefine *pDefines, // Array of defines + UINT32 defineCount, // Number of defines + IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle + // #include directives (optional) + IDxcOperationResult * + *ppResult, // Compiler output status, buffer, and errors + LPWSTR *ppDebugBlobName, // Suggested file name for debug blob. + IDxcBlob **ppDebugBlob // Debug blob ) { HRESULT hr = S_OK; DxcThreadMalloc TM(m_pMalloc); @@ -1773,7 +1781,7 @@ HRESULT DxcCompilerAdapter::WrapCompile( } catch (std::bad_alloc &) { hr = E_OUTOFMEMORY; } catch (hlsl::Exception &e) { - _Analysis_assume_(DXC_FAILED(e.hr)); + assert(DXC_FAILED(e.hr)); hr = DxcResult::Create(e.hr, DXC_OUT_NONE, { DxcOutputObject::ErrorOutput(CP_UTF8, e.msg.c_str(), e.msg.size()) }, ppResult); @@ -1784,8 +1792,7 @@ HRESULT DxcCompilerAdapter::WrapCompile( } ////////////////////////////////////////////////////////////// - -HRESULT CreateDxcCompiler(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcCompiler(REFIID riid, LPVOID *ppv) { *ppv = nullptr; try { CComPtr result(DxcCompiler::Alloc(DxcGetThreadMallocNoRef())); diff --git a/tools/clang/tools/dxcompiler/dxcpdbutils.cpp b/tools/clang/tools/dxcompiler/dxcpdbutils.cpp index 5d8dc1ea24..cfce3b5884 100644 --- a/tools/clang/tools/dxcompiler/dxcpdbutils.cpp +++ b/tools/clang/tools/dxcompiler/dxcpdbutils.cpp @@ -71,7 +71,8 @@ struct DxcPdbVersionInfo : std::string m_VersionCommitSha = {}; std::string m_VersionString = {}; - static HRESULT CopyStringToOutStringPtr(const std::string &Str, _Out_ char **ppOutString) { + static HRESULT CopyStringToOutStringPtr(const std::string &Str, + char **ppOutString) { *ppOutString = nullptr; char *const pString = (char *)CoTaskMemAlloc(Str.size() + 1); if (pString == nullptr) @@ -87,7 +88,8 @@ struct DxcPdbVersionInfo : return DoBasicQueryInterface(this, iid, ppvObject); } - virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) override { + virtual HRESULT STDMETHODCALLTYPE GetVersion(UINT32 *pMajor, + UINT32 *pMinor) override { if (!pMajor || !pMinor) return E_POINTER; *pMajor = m_Version.Major; @@ -95,13 +97,14 @@ struct DxcPdbVersionInfo : return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) override { + virtual HRESULT STDMETHODCALLTYPE GetFlags(UINT32 *pFlags) override { if (!pFlags) return E_POINTER; *pFlags = m_Version.VersionFlags; return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetCommitInfo(_Out_ UINT32 *pCommitCount, _Outptr_result_z_ char **pCommitHash) override { + virtual HRESULT STDMETHODCALLTYPE GetCommitInfo(UINT32 *pCommitCount, + char **pCommitHash) override { if (!pCommitHash) return E_POINTER; @@ -111,7 +114,8 @@ struct DxcPdbVersionInfo : return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetCustomVersionString(_Outptr_result_z_ char **pVersionString) override { + virtual HRESULT STDMETHODCALLTYPE + GetCustomVersionString(char **pVersionString) override { if (!pVersionString) return E_POINTER; IFR(CopyStringToOutStringPtr(m_VersionString, pVersionString)); @@ -126,7 +130,7 @@ struct DxcPdbUtilsAdapter : public IDxcPdbUtils private: IDxcPdbUtils2 *m_pImpl; - HRESULT CopyBlobWideToBSTR(IDxcBlobWide *pBlob, _Outptr_result_z_ BSTR *pResult) { + HRESULT CopyBlobWideToBSTR(IDxcBlobWide *pBlob, BSTR *pResult) { if (!pResult) return E_POINTER; *pResult = nullptr; if (pBlob) { @@ -148,48 +152,60 @@ struct DxcPdbUtilsAdapter : public IDxcPdbUtils return m_pImpl->QueryInterface(iid, ppvObject); } - HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) override { + HRESULT STDMETHODCALLTYPE Load(IDxcBlob *pPdbOrDxil) override { return m_pImpl->Load(pPdbOrDxil); } - virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) override { + virtual HRESULT STDMETHODCALLTYPE GetSourceCount(UINT32 *pCount) override { return m_pImpl->GetSourceCount(pCount); } - virtual HRESULT STDMETHODCALLTYPE GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetSource(UINT32 uIndex, IDxcBlobEncoding **ppResult) override { return m_pImpl->GetSource(uIndex, ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetSourceName(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetSourceName(UINT32 uIndex, + BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetSourceName(uIndex, &pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) override { return m_pImpl->GetFlagCount(pCount); } - virtual HRESULT STDMETHODCALLTYPE GetFlag(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetFlagCount(UINT32 *pCount) override { + return m_pImpl->GetFlagCount(pCount); + } + virtual HRESULT STDMETHODCALLTYPE GetFlag(UINT32 uIndex, + BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetFlag(uIndex, &pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) override { return m_pImpl->GetArgCount(pCount); } - virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetArgCount(UINT32 *pCount) override { + return m_pImpl->GetArgCount(pCount); + } + virtual HRESULT STDMETHODCALLTYPE GetArg(UINT32 uIndex, + BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetArg(uIndex, &pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) override { return m_pImpl->GetDefineCount(pCount); } - virtual HRESULT STDMETHODCALLTYPE GetDefine(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetDefineCount(UINT32 *pCount) override { + return m_pImpl->GetDefineCount(pCount); + } + virtual HRESULT STDMETHODCALLTYPE GetDefine(UINT32 uIndex, + BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetDefine(uIndex, &pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) override { + virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(UINT32 *pCount) override { return m_pImpl->GetArgPairCount(pCount); } - virtual HRESULT STDMETHODCALLTYPE GetArgPair(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pName, _Outptr_result_z_ BSTR *pValue) override { + virtual HRESULT STDMETHODCALLTYPE GetArgPair(UINT32 uIndex, BSTR *pName, + BSTR *pValue) override { CComPtr pNameBlob; CComPtr pValueBlob; IFR(m_pImpl->GetArgPair(uIndex, &pNameBlob, &pValueBlob)); @@ -198,17 +214,17 @@ struct DxcPdbUtilsAdapter : public IDxcPdbUtils return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(_Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetTargetProfile(&pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(_Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetEntryPoint(&pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetMainFileName(_Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetMainFileName(BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetMainFileName(&pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); @@ -218,37 +234,42 @@ struct DxcPdbUtilsAdapter : public IDxcPdbUtils return m_pImpl->IsFullPDB(); } - virtual HRESULT STDMETHODCALLTYPE OverrideArgs(_In_ DxcArgPair *pArgPairs, UINT32 uNumArgPairs) override { + virtual HRESULT STDMETHODCALLTYPE OverrideArgs(DxcArgPair *pArgPairs, + UINT32 uNumArgPairs) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE OverrideRootSignature(_In_ const WCHAR *pRootSignature) override { + virtual HRESULT STDMETHODCALLTYPE + OverrideRootSignature(const WCHAR *pRootSignature) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE CompileForFullPDB(_COM_Outptr_ IDxcResult **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + CompileForFullPDB(IDxcResult **ppResult) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) override { + virtual HRESULT STDMETHODCALLTYPE GetFullPDB(IDxcBlob **ppFullPDB) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetHash(_COM_Outptr_ IDxcBlob **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE GetHash(IDxcBlob **ppResult) override { return m_pImpl->GetHash(ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetName(_Outptr_result_z_ BSTR *pResult) override { + virtual HRESULT STDMETHODCALLTYPE GetName(BSTR *pResult) override { CComPtr pBlob; IFR(m_pImpl->GetName(&pBlob)); return CopyBlobWideToBSTR(pBlob, pResult); } - virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(_COM_Outptr_ IDxcVersionInfo **ppVersionInfo) override { + virtual HRESULT STDMETHODCALLTYPE + GetVersionInfo(IDxcVersionInfo **ppVersionInfo) override { return m_pImpl->GetVersionInfo(ppVersionInfo); } - virtual HRESULT STDMETHODCALLTYPE SetCompiler(_In_ IDxcCompiler3 *pCompiler) override { + virtual HRESULT STDMETHODCALLTYPE + SetCompiler(IDxcCompiler3 *pCompiler) override { return E_NOTIMPL; } }; @@ -819,7 +840,7 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return hr; } - HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) override { + HRESULT STDMETHODCALLTYPE Load(IDxcBlob *pPdbOrDxil) override { if (!pPdbOrDxil) return E_POINTER; @@ -881,49 +902,71 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) override { + virtual HRESULT STDMETHODCALLTYPE GetSourceCount(UINT32 *pCount) override { if (!pCount) return E_POINTER; *pCount = (UINT32)m_SourceFiles.size(); return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetSource(UINT32 uIndex, IDxcBlobEncoding **ppResult) override { if (uIndex >= m_SourceFiles.size()) return E_INVALIDARG; if (!ppResult) return E_POINTER; *ppResult = nullptr; return m_SourceFiles[uIndex].Content.QueryInterface(ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetSourceName(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetSourceName(UINT32 uIndex, IDxcBlobWide **ppResult) override { if (uIndex >= m_SourceFiles.size()) return E_INVALIDARG; return m_SourceFiles[uIndex].Name.QueryInterface(ppResult); } - static inline HRESULT GetStringCount(const std::vector > &list, _Out_ UINT32 *pCount) { + static inline HRESULT + GetStringCount(const std::vector> &list, + UINT32 *pCount) { if (!pCount) return E_POINTER; *pCount = (UINT32)list.size(); return S_OK; } - static inline HRESULT GetStringOption(const std::vector > &list, _In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) { + static inline HRESULT + GetStringOption(const std::vector> &list, UINT32 uIndex, + IDxcBlobWide **ppResult) { if (uIndex >= list.size()) return E_INVALIDARG; return list[uIndex].QueryInterface(ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) override { return GetStringCount(m_Flags, pCount); } - virtual HRESULT STDMETHODCALLTYPE GetFlag(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) override { return GetStringOption(m_Flags, uIndex, ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) override { return GetStringCount(m_Args, pCount); } - virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) override { return GetStringOption(m_Args, uIndex, ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) override { return GetStringCount(m_Defines, pCount); } - virtual HRESULT STDMETHODCALLTYPE GetDefine(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) override { return GetStringOption(m_Defines, uIndex, ppResult); } + virtual HRESULT STDMETHODCALLTYPE GetFlagCount(UINT32 *pCount) override { + return GetStringCount(m_Flags, pCount); + } + virtual HRESULT STDMETHODCALLTYPE GetFlag(UINT32 uIndex, + IDxcBlobWide **ppResult) override { + return GetStringOption(m_Flags, uIndex, ppResult); + } + virtual HRESULT STDMETHODCALLTYPE GetArgCount(UINT32 *pCount) override { + return GetStringCount(m_Args, pCount); + } + virtual HRESULT STDMETHODCALLTYPE GetArg(UINT32 uIndex, + IDxcBlobWide **ppResult) override { + return GetStringOption(m_Args, uIndex, ppResult); + } + virtual HRESULT STDMETHODCALLTYPE GetDefineCount(UINT32 *pCount) override { + return GetStringCount(m_Defines, pCount); + } + virtual HRESULT STDMETHODCALLTYPE + GetDefine(UINT32 uIndex, IDxcBlobWide **ppResult) override { + return GetStringOption(m_Defines, uIndex, ppResult); + } - virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) override { + virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(UINT32 *pCount) override { if (!pCount) return E_POINTER; *pCount = (UINT32)m_ArgPairs.size(); return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetArgPair(_In_ UINT32 uIndex, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppName, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppValue) override { + virtual HRESULT STDMETHODCALLTYPE GetArgPair( + UINT32 uIndex, IDxcBlobWide **ppName, IDxcBlobWide **ppValue) override { if (!ppName || !ppValue) return E_POINTER; if (uIndex >= m_ArgPairs.size()) return E_INVALIDARG; const ArgPair &pair = m_ArgPairs[uIndex]; @@ -942,13 +985,16 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(_COM_Outptr_ IDxcBlobWide **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetTargetProfile(IDxcBlobWide **ppResult) override { return CopyBlobWide(m_TargetProfile, ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(_COM_Outptr_ IDxcBlobWide **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetEntryPoint(IDxcBlobWide **ppResult) override { return CopyBlobWide(m_EntryPoint, ppResult); } - virtual HRESULT STDMETHODCALLTYPE GetMainFileName(_COM_Outptr_ IDxcBlobWide **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetMainFileName(IDxcBlobWide **ppResult) override { return CopyBlobWide(m_MainFileName, ppResult); } @@ -974,7 +1020,7 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetHash(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE GetHash(IDxcBlob **ppResult) override { if (!ppResult) return E_POINTER; *ppResult = nullptr; if (m_HashBlob) @@ -982,7 +1028,7 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return E_FAIL; } - virtual HRESULT STDMETHODCALLTYPE GetWholeDxil(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE GetWholeDxil(IDxcBlob **ppResult) override { if (!ppResult) return E_POINTER; *ppResult = nullptr; if (m_WholeDxil) @@ -990,14 +1036,13 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) override { + virtual HRESULT STDMETHODCALLTYPE GetName(IDxcBlobWide **ppResult) override { return CopyBlobWide(m_Name, ppResult); } #ifdef _WIN32 - virtual STDMETHODIMP NewDxcPixDxilDebugInfo( - _COM_Outptr_ IDxcPixDxilDebugInfo **ppDxilDebugInfo) override - { + virtual STDMETHODIMP + NewDxcPixDxilDebugInfo(IDxcPixDxilDebugInfo **ppDxilDebugInfo) override { if (!m_pDebugProgramBlob) return E_FAIL; @@ -1021,14 +1066,14 @@ struct DxcPdbUtils : public IDxcPdbUtils2 } virtual STDMETHODIMP NewDxcPixCompilationInfo( - _COM_Outptr_ IDxcPixCompilationInfo **ppCompilationInfo) override - { + IDxcPixCompilationInfo **ppCompilationInfo) override { return E_NOTIMPL; } #endif - virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(_COM_Outptr_result_maybenull_ IDxcVersionInfo **ppVersionInfo) override { + virtual HRESULT STDMETHODCALLTYPE + GetVersionInfo(IDxcVersionInfo **ppVersionInfo) override { if (!ppVersionInfo) return E_POINTER; @@ -1049,12 +1094,15 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetLibraryPDBCount(_Out_ UINT32 *pCount) override { + virtual HRESULT STDMETHODCALLTYPE + GetLibraryPDBCount(UINT32 *pCount) override { if (!pCount) return E_POINTER; *pCount = (UINT32)m_LibraryPdbs.size(); return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetLibraryPDB(_In_ UINT32 uIndex, _COM_Outptr_ IDxcPdbUtils2 **ppOutPdbUtils, _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppLibraryName) override { + virtual HRESULT STDMETHODCALLTYPE + GetLibraryPDB(UINT32 uIndex, IDxcPdbUtils2 **ppOutPdbUtils, + IDxcBlobWide **ppLibraryName) override { if (!ppOutPdbUtils) return E_POINTER; if (uIndex >= m_LibraryPdbs.size()) return E_INVALIDARG; @@ -1080,13 +1128,14 @@ struct DxcPdbUtils : public IDxcPdbUtils2 return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainID(_Out_ UINT32 *pID) override { + virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainID(UINT32 *pID) override { if (!pID) return E_POINTER; *pID = m_uCustomToolchainID; return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainData(_COM_Outptr_opt_result_maybenull_ IDxcBlob **ppBlob) override { + virtual HRESULT STDMETHODCALLTYPE + GetCustomToolchainData(IDxcBlob **ppBlob) override { if (!ppBlob) return E_POINTER; *ppBlob = nullptr; if (m_customToolchainData) @@ -1095,7 +1144,7 @@ struct DxcPdbUtils : public IDxcPdbUtils2 } }; -HRESULT CreateDxcPdbUtils(_In_ REFIID riid, _Out_ LPVOID *ppv) { +HRESULT CreateDxcPdbUtils(REFIID riid, LPVOID *ppv) { if (!ppv) return E_POINTER; *ppv = nullptr; if (riid == __uuidof(IDxcPdbUtils)) { diff --git a/tools/clang/tools/dxcompiler/dxcutil.cpp b/tools/clang/tools/dxcompiler/dxcutil.cpp index aef4d01c0b..61637189ce 100644 --- a/tools/clang/tools/dxcompiler/dxcutil.cpp +++ b/tools/clang/tools/dxcompiler/dxcutil.cpp @@ -37,16 +37,14 @@ using namespace llvm; using namespace hlsl; // This declaration is used for the locally-linked validator. -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv); // This internal call allows the validator to avoid having to re-deserialize // the module. It trusts that the caller didn't make any changes and is // kept internal because the layout of the module class may change based // on changes across modules, or picking a different compiler version or CRT. -HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, - _In_ llvm::Module *pModule, - _In_ llvm::Module *pDebugModule, - _In_ IDxcBlob *pShader, UINT32 Flags, - _In_ IDxcOperationResult **ppResult); +HRESULT RunInternalValidator(IDxcValidator *pValidator, llvm::Module *pModule, + llvm::Module *pDebugModule, IDxcBlob *pShader, + UINT32 Flags, IDxcOperationResult **ppResult); namespace { // AssembleToContainer helper functions. @@ -137,8 +135,7 @@ void AssembleToContainer(AssembleInputs &inputs) { void ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, hlsl::options::DxcOpts &opts, AbstractMemoryStream *pOutputStream, - _COM_Outptr_ IDxcOperationResult **ppResult, - bool &finished) { + IDxcOperationResult **ppResult, bool &finished) { const llvm::opt::OptTable *table = ::options::getHlslOptTable(); raw_stream_ostream outStream(pOutputStream); if (0 != hlsl::options::ReadDxcOpts(table, hlsl::options::CompilerFlags, @@ -339,10 +336,9 @@ HRESULT SetRootSignature(hlsl::DxilModule *pModule, CComPtr pSource) { } void CreateOperationResultFromOutputs( - DXC_OUT_KIND resultKind, UINT32 textEncoding, - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult) { + DXC_OUT_KIND resultKind, UINT32 textEncoding, IDxcBlob *pResultBlob, + CComPtr &pErrorStream, const std::string &warnings, + bool hasErrorOccurred, IDxcOperationResult **ppResult) { CComPtr pResult = DxcResult::Alloc(DxcGetThreadMallocNoRef()); IFT(pResult->SetEncoding(textEncoding)); IFT(pResult->SetStatusAndPrimaryResult(hasErrorOccurred ? E_FAIL : S_OK, resultKind)); @@ -357,10 +353,11 @@ void CreateOperationResultFromOutputs( IFT(pResult.QueryInterface(ppResult)); } -void CreateOperationResultFromOutputs( - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult) { +void CreateOperationResultFromOutputs(IDxcBlob *pResultBlob, + CComPtr &pErrorStream, + const std::string &warnings, + bool hasErrorOccurred, + IDxcOperationResult **ppResult) { CreateOperationResultFromOutputs(DXC_OUT_OBJECT, DXC_CP_UTF8, pResultBlob, pErrorStream, warnings, hasErrorOccurred, ppResult); } diff --git a/tools/clang/tools/dxcompiler/dxcutil.h b/tools/clang/tools/dxcompiler/dxcutil.h index 9e926f6aaf..c256c78272 100644 --- a/tools/clang/tools/dxcompiler/dxcutil.h +++ b/tools/clang/tools/dxcompiler/dxcutil.h @@ -76,17 +76,16 @@ HRESULT Disassemble(IDxcBlob *pProgram, llvm::raw_string_ostream &Stream); void ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, hlsl::options::DxcOpts &opts, hlsl::AbstractMemoryStream *pOutputStream, - _COM_Outptr_ IDxcOperationResult **ppResult, - bool &finished); + IDxcOperationResult **ppResult, bool &finished); void CreateOperationResultFromOutputs( - DXC_OUT_KIND resultKind, UINT32 textEncoding, - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult); -void CreateOperationResultFromOutputs( - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult); + DXC_OUT_KIND resultKind, UINT32 textEncoding, IDxcBlob *pResultBlob, + CComPtr &pErrorStream, const std::string &warnings, + bool hasErrorOccurred, IDxcOperationResult **ppResult); +void CreateOperationResultFromOutputs(IDxcBlob *pResultBlob, + CComPtr &pErrorStream, + const std::string &warnings, + bool hasErrorOccurred, + IDxcOperationResult **ppResult); bool IsAbsoluteOrCurDirRelative(const llvm::Twine &T); diff --git a/tools/clang/tools/dxcompiler/dxcvalidator.cpp b/tools/clang/tools/dxcompiler/dxcvalidator.cpp index 63499c4128..117bc0c2e2 100644 --- a/tools/clang/tools/dxcompiler/dxcvalidator.cpp +++ b/tools/clang/tools/dxcompiler/dxcvalidator.cpp @@ -65,15 +65,14 @@ class DxcValidator : public IDxcValidator2, DXC_MICROCOM_TM_REF_FIELDS() HRESULT RunValidation( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_opt_ llvm::Module *pModule, // Module to validate, if available. - _In_opt_ llvm::Module *pDebugModule, // Debug module to validate, if available - _In_ AbstractMemoryStream *pDiagStream); + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + AbstractMemoryStream *pDiagStream); - HRESULT RunRootSignatureValidation( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ AbstractMemoryStream *pDiagStream); + HRESULT RunRootSignatureValidation(IDxcBlob *pShader, // Shader to validate. + AbstractMemoryStream *pDiagStream); public: DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL() @@ -85,43 +84,49 @@ class DxcValidator : public IDxcValidator2, // For internal use only. HRESULT ValidateWithOptModules( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_opt_ llvm::Module *pModule, // Module to validate, if available. - _In_opt_ llvm::Module *pDebugModule, // Debug module to validate, if available - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors ); // IDxcValidator HRESULT STDMETHODCALLTYPE Validate( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors - ) override; + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors + ) override; // IDxcValidator2 HRESULT STDMETHODCALLTYPE ValidateWithDebug( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_opt_ DxcBuffer *pOptDebugBitcode, // Optional debug module bitcode to provide line numbers - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors - ) override; + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + DxcBuffer *pOptDebugBitcode, // Optional debug module bitcode to provide + // line numbers + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors + ) override; // IDxcVersionInfo - HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) override; - HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) override; + HRESULT STDMETHODCALLTYPE GetVersion(UINT32 *pMajor, UINT32 *pMinor) override; + HRESULT STDMETHODCALLTYPE GetFlags(UINT32 *pFlags) override; #ifdef SUPPORT_QUERY_GIT_COMMIT_INFO // IDxcVersionInfo2 - HRESULT STDMETHODCALLTYPE GetCommitInfo(_Out_ UINT32 *pCommitCount, _Out_ char **pCommitHash) override; + HRESULT STDMETHODCALLTYPE GetCommitInfo(UINT32 *pCommitCount, + char **pCommitHash) override; #endif }; // Compile a single entry point to the target shader model HRESULT STDMETHODCALLTYPE DxcValidator::Validate( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors ) { DxcThreadMalloc TM(m_pMalloc); if (ppResult == nullptr) @@ -135,12 +140,13 @@ HRESULT STDMETHODCALLTYPE DxcValidator::Validate( } HRESULT STDMETHODCALLTYPE DxcValidator::ValidateWithDebug( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_opt_ DxcBuffer *pOptDebugBitcode, // Optional debug module bitcode to provide line numbers - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors -) -{ + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + DxcBuffer *pOptDebugBitcode, // Optional debug module bitcode to provide + // line numbers + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors +) { if (ppResult == nullptr) return E_INVALIDARG; *ppResult = nullptr; @@ -176,11 +182,12 @@ HRESULT STDMETHODCALLTYPE DxcValidator::ValidateWithDebug( } HRESULT DxcValidator::ValidateWithOptModules( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_opt_ llvm::Module *pModule, // Module to validate, if available. - _In_opt_ llvm::Module *pDebugModule, // Debug module to validate, if available - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors ) { *ppResult = nullptr; HRESULT hr = S_OK; @@ -218,7 +225,8 @@ HRESULT DxcValidator::ValidateWithOptModules( return hr; } -HRESULT STDMETHODCALLTYPE DxcValidator::GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) { +HRESULT STDMETHODCALLTYPE DxcValidator::GetVersion(UINT32 *pMajor, + UINT32 *pMinor) { if (pMajor == nullptr || pMinor == nullptr) return E_INVALIDARG; GetValidationVersion(pMajor, pMinor); @@ -226,8 +234,8 @@ HRESULT STDMETHODCALLTYPE DxcValidator::GetVersion(_Out_ UINT32 *pMajor, _Out_ U } #ifdef SUPPORT_QUERY_GIT_COMMIT_INFO -HRESULT STDMETHODCALLTYPE DxcValidator::GetCommitInfo( - _Out_ UINT32 *pCommitCount, _Out_ char **pCommitHash) { +HRESULT STDMETHODCALLTYPE DxcValidator::GetCommitInfo(UINT32 *pCommitCount, + char **pCommitHash) { if (pCommitCount == nullptr || pCommitHash == nullptr) return E_INVALIDARG; @@ -243,7 +251,7 @@ HRESULT STDMETHODCALLTYPE DxcValidator::GetCommitInfo( } #endif // SUPPORT_QUERY_GIT_COMMIT_INFO -HRESULT STDMETHODCALLTYPE DxcValidator::GetFlags(_Out_ UINT32 *pFlags) { +HRESULT STDMETHODCALLTYPE DxcValidator::GetFlags(UINT32 *pFlags) { if (pFlags == nullptr) return E_INVALIDARG; *pFlags = DxcVersionInfoFlags_None; @@ -255,11 +263,11 @@ HRESULT STDMETHODCALLTYPE DxcValidator::GetFlags(_Out_ UINT32 *pFlags) { } HRESULT DxcValidator::RunValidation( - _In_ IDxcBlob *pShader, - _In_ UINT32 Flags, // Validation flags. - _In_opt_ llvm::Module *pModule, // Module to validate, if available. - _In_opt_ llvm::Module *pDebugModule, // Debug module to validate, if available - _In_ AbstractMemoryStream *pDiagStream) { + IDxcBlob *pShader, + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + AbstractMemoryStream *pDiagStream) { // Run validation may throw, but that indicates an inability to validate, // not that the validation failed (eg out of memory). That is indicated @@ -300,9 +308,9 @@ HRESULT DxcValidator::RunValidation( return S_OK; } -HRESULT DxcValidator::RunRootSignatureValidation( - _In_ IDxcBlob *pShader, - _In_ AbstractMemoryStream *pDiagStream) { +HRESULT +DxcValidator::RunRootSignatureValidation(IDxcBlob *pShader, + AbstractMemoryStream *pDiagStream) { const DxilContainerHeader *pDxilContainer = IsDxilContainerLike( pShader->GetBufferPointer(), pShader->GetBufferSize()); @@ -343,11 +351,9 @@ HRESULT DxcValidator::RunRootSignatureValidation( /////////////////////////////////////////////////////////////////////////////// -HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, - _In_ llvm::Module *pModule, - _In_ llvm::Module *pDebugModule, - _In_ IDxcBlob *pShader, UINT32 Flags, - _COM_Outptr_ IDxcOperationResult **ppResult) { +HRESULT RunInternalValidator(IDxcValidator *pValidator, llvm::Module *pModule, + llvm::Module *pDebugModule, IDxcBlob *pShader, + UINT32 Flags, IDxcOperationResult **ppResult) { DXASSERT_NOMSG(pValidator != nullptr); DXASSERT_NOMSG(pModule != nullptr); DXASSERT_NOMSG(pShader != nullptr); @@ -358,7 +364,7 @@ HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, pDebugModule, ppResult); } -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv) { try { CComPtr result(DxcValidator::Alloc(DxcGetThreadMallocNoRef())); IFROOM(result.p); diff --git a/tools/clang/tools/dxcompiler/dxillib.cpp b/tools/clang/tools/dxcompiler/dxillib.cpp index 30975c3288..8704088c48 100644 --- a/tools/clang/tools/dxcompiler/dxillib.cpp +++ b/tools/clang/tools/dxcompiler/dxillib.cpp @@ -61,8 +61,8 @@ bool DxilLibIsEnabled() { return SUCCEEDED(g_DllLibResult); } - -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid, _In_ IUnknown **ppInterface) { +HRESULT DxilLibCreateInstance(REFCLSID rclsid, REFIID riid, + IUnknown **ppInterface) { DXASSERT_NOMSG(ppInterface != nullptr); HRESULT hr = E_FAIL; if (DxilLibIsEnabled()) { diff --git a/tools/clang/tools/dxcompiler/dxillib.h b/tools/clang/tools/dxcompiler/dxillib.h index 39e0bbe8e3..bb4e2ee6f6 100644 --- a/tools/clang/tools/dxcompiler/dxillib.h +++ b/tools/clang/tools/dxcompiler/dxillib.h @@ -32,11 +32,12 @@ HRESULT DxilLibCleanup(DxilLibCleanUpType type); // Check if can access dxil.dll bool DxilLibIsEnabled(); -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid, _In_ IUnknown **ppInterface); +HRESULT DxilLibCreateInstance(REFCLSID rclsid, REFIID riid, + IUnknown **ppInterface); template -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ TInterface **ppInterface) { +HRESULT DxilLibCreateInstance(REFCLSID rclsid, TInterface **ppInterface) { return DxilLibCreateInstance(rclsid, __uuidof(TInterface), (IUnknown**) ppInterface); } -#endif // __DXC_DXILLIB__ \ No newline at end of file +#endif // __DXC_DXILLIB__ diff --git a/tools/clang/tools/dxlib-sample/lib_share_compile.cpp b/tools/clang/tools/dxlib-sample/lib_share_compile.cpp index 37cd5025aa..0d812163bf 100644 --- a/tools/clang/tools/dxlib-sample/lib_share_compile.cpp +++ b/tools/clang/tools/dxlib-sample/lib_share_compile.cpp @@ -78,7 +78,7 @@ HRESULT CompileToLib(IDxcBlob *pSource, std::vector &defines, static void ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, hlsl::options::DxcOpts &opts, AbstractMemoryStream *pOutputStream, - _COM_Outptr_ IDxcOperationResult **ppResult, + IDxcOperationResult **ppResult, bool &finished) { const llvm::opt::OptTable *table = ::options::getHlslOptTable(); raw_stream_ostream outStream(pOutputStream); diff --git a/tools/clang/tools/dxlib-sample/lib_share_preprocessor.cpp b/tools/clang/tools/dxlib-sample/lib_share_preprocessor.cpp index 67c3bb746a..6208a2e34a 100644 --- a/tools/clang/tools/dxlib-sample/lib_share_preprocessor.cpp +++ b/tools/clang/tools/dxlib-sample/lib_share_preprocessor.cpp @@ -58,13 +58,13 @@ class IncPathIncludeHandler : public IDxcIncludeHandler { IncPathIncludeHandler(IDxcIncludeHandler *handler, std::vector &includePathList) : m_dwRef(0), m_pIncludeHandler(handler), m_includePathList(includePathList) {} HRESULT STDMETHODCALLTYPE LoadSource( - _In_ LPCWSTR pFilename, // Candidate filename. - _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource // Resultant - // source object - // for included - // file, nullptr - // if not found. - ) override { + LPCWSTR pFilename, // Candidate filename. + IDxcBlob **ppIncludeSource // Resultant + // source object + // for included + // file, nullptr + // if not found. + ) override { CW2A pUtf8Filename(pFilename); if (m_loadedFileNames.find(pUtf8Filename.m_psz) != m_loadedFileNames.end()) { diff --git a/tools/clang/tools/dxrfallbackcompiler/dxcapi.cpp b/tools/clang/tools/dxrfallbackcompiler/dxcapi.cpp index fe28df849c..30096cc17a 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxcapi.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxcapi.cpp @@ -19,12 +19,10 @@ #include "dxc/dxcdxrfallbackcompiler.h" #include -HRESULT CreateDxcDxrFallbackCompiler(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcDxrFallbackCompiler(REFIID riid, LPVOID *ppv); -static HRESULT ThreadMallocDxcCreateInstance( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { +static HRESULT ThreadMallocDxcCreateInstance(REFCLSID rclsid, REFIID riid, + LPVOID *ppv) { HRESULT hr = S_OK; *ppv = nullptr; @@ -37,11 +35,9 @@ static HRESULT ThreadMallocDxcCreateInstance( return hr; } -DXC_API_IMPORT HRESULT __stdcall -DxcCreateDxrFallbackCompiler( - _In_ REFCLSID rclsid, - _In_ REFIID riid, - _Out_ LPVOID *ppv) { +DXC_API_IMPORT HRESULT __stdcall DxcCreateDxrFallbackCompiler(REFCLSID rclsid, + REFIID riid, + LPVOID *ppv) { if (ppv == nullptr) { return E_POINTER; } diff --git a/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp b/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp index 476448a4a3..7f237e2f81 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp @@ -51,10 +51,8 @@ static std::string ws2s(const std::wstring& wide) return std::string(wide.begin(), wide.end()); } -static HRESULT FindDxilProgram(IDxcBlob* pBlob, - _In_ DxilFourCC FourCC, - _In_ const DxilProgramHeader **ppProgram) -{ +static HRESULT FindDxilProgram(IDxcBlob *pBlob, DxilFourCC FourCC, + const DxilProgramHeader **ppProgram) { void* pContainerBytes = pBlob->GetBufferPointer(); SIZE_T ContainerSize = pBlob->GetBufferSize(); @@ -89,7 +87,6 @@ static HRESULT FindDxilProgram(IDxcBlob* pBlob, return S_OK; } - static DxilModule* ExtractDxil(LLVMContext& context, IDxcBlob* pContainer) { const DxilProgramHeader *pProgram = nullptr; @@ -160,41 +157,23 @@ class DxcDxrFallbackCompiler : public IDxcDxrFallbackCompiler } __override HRESULT STDMETHODCALLTYPE PatchShaderBindingTables( - _In_ const LPCWSTR pEntryName, - _In_ DxcShaderBytecode *pShaderBytecode, - void *pShaderInfo, - _COM_Outptr_ IDxcOperationResult **ppResult - ); + const LPCWSTR pEntryName, DxcShaderBytecode *pShaderBytecode, + void *pShaderInfo, IDxcOperationResult **ppResult); __override HRESULT STDMETHODCALLTYPE RenameAndLink( - _In_count_(libCount) DxcShaderBytecode *pLibs, - UINT32 libCount, - _In_count_(ExportCount) DxcExportDesc *pExports, - UINT32 ExportCount, - _COM_Outptr_ IDxcOperationResult **ppResult - ); + DxcShaderBytecode *pLibs, UINT32 libCount, DxcExportDesc *pExports, + UINT32 ExportCount, IDxcOperationResult **ppResult); __override HRESULT STDMETHODCALLTYPE Compile( - _In_count_(libCount) DxcShaderBytecode *pLibs, - UINT32 libCount, - _In_count_(shaderCount) const LPCWSTR *pShaderNames, - _Out_writes_(shaderCount) DxcShaderInfo *pShaderInfo, - UINT32 shaderCount, - UINT32 maxAttributeSize, - _COM_Outptr_ IDxcOperationResult **ppResult - ); - - __override HRESULT STDMETHODCALLTYPE Link( - _In_ const LPCWSTR pEntryName, - _In_count_(libCount) IDxcBlob **pLibs, - UINT32 libCount, - _In_count_(shaderCount) const LPCWSTR *pShaderNames, - _In_count_(shaderCount) DxcShaderInfo *pShaderInfo, - UINT32 shaderCount, - UINT32 maxAttributeSize, - UINT32 stackSizeInBytes, - _COM_Outptr_ IDxcOperationResult **ppResult - ); + DxcShaderBytecode *pLibs, UINT32 libCount, const LPCWSTR *pShaderNames, + DxcShaderInfo *pShaderInfo, UINT32 shaderCount, UINT32 maxAttributeSize, + IDxcOperationResult **ppResult); + + __override HRESULT STDMETHODCALLTYPE + Link(const LPCWSTR pEntryName, IDxcBlob **pLibs, UINT32 libCount, + const LPCWSTR *pShaderNames, DxcShaderInfo *pShaderInfo, + UINT32 shaderCount, UINT32 maxAttributeSize, UINT32 stackSizeInBytes, + IDxcOperationResult **ppResult); }; // TODO: Stolen from Brandon's code, merge @@ -226,376 +205,342 @@ Function *CloneFunction(Function *Orig, llvm::Module *llvmModule); HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::RenameAndLink( - _In_count_(libCount) DxcShaderBytecode *pLibs, - UINT32 libCount, - _In_count_(ExportCount) DxcExportDesc *pExports, - UINT32 ExportCount, - _COM_Outptr_ IDxcOperationResult **ppResult -) -{ - if (pLibs == nullptr || pExports == nullptr) - return E_POINTER; + DxcShaderBytecode *pLibs, UINT32 libCount, DxcExportDesc *pExports, + UINT32 ExportCount, IDxcOperationResult **ppResult) { + if (pLibs == nullptr || pExports == nullptr) + return E_POINTER; - if (libCount == 0 || ExportCount == 0) - return E_INVALIDARG; + if (libCount == 0 || ExportCount == 0) + return E_INVALIDARG; - *ppResult = nullptr; - HRESULT hr = S_OK; - DxcThreadMalloc TM(m_pMalloc); - LLVMContext context; - try - { - // Init file system because we are currently loading the runtime from disk - ::llvm::sys::fs::MSFileSystem *msfPtr; - IFT(CreateMSFileSystemForDisk(&msfPtr)); - std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr); - ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get()); - IFTLLVM(pts.error_code()); - - // Create a diagnostic printer - CComPtr pDiagStream; - IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pDiagStream)); - raw_stream_ostream DiagStream(pDiagStream); - DiagnosticPrinterRawOStream DiagPrinter(DiagStream); - PrintDiagnosticContext DiagContext(DiagPrinter); - context.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler, - &DiagContext, true); - - std::vector> pShaderLibs(libCount); - for (UINT i = 0; i < libCount; i++) - { - hlsl::DxcCreateBlobWithEncodingFromPinned(pLibs[i].pData, pLibs[i].Size, CP_ACP, &pShaderLibs[i]); - } + *ppResult = nullptr; + HRESULT hr = S_OK; + DxcThreadMalloc TM(m_pMalloc); + LLVMContext context; + try { + // Init file system because we are currently loading the runtime from disk + ::llvm::sys::fs::MSFileSystem *msfPtr; + IFT(CreateMSFileSystemForDisk(&msfPtr)); + std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr); + ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get()); + IFTLLVM(pts.error_code()); - // Link all the modules together into a single into library - unsigned int valMajor = 0, valMinor = 0; - dxcutil::GetValidatorVersion(&valMajor, &valMinor); + // Create a diagnostic printer + CComPtr pDiagStream; + IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pDiagStream)); + raw_stream_ostream DiagStream(pDiagStream); + DiagnosticPrinterRawOStream DiagPrinter(DiagStream); + PrintDiagnosticContext DiagContext(DiagPrinter); + context.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler, + &DiagContext, true); - std::unique_ptr M; - { - DxilLinker* pLinker = DxilLinker::CreateLinker(context, valMajor, valMinor); - for (UINT32 i = 0; i < libCount; ++i) - { - DxilModule* dxil = ExtractDxil(context, pShaderLibs[i]); - if (dxil == nullptr) - { - return DXC_E_CONTAINER_MISSING_DXIL; - } - pLinker->RegisterLib(std::to_string(i), std::unique_ptr(dxil->GetModule()), nullptr); - pLinker->AttachLib(std::to_string(i)); - } - - dxilutil::ExportMap exportMap; - M = pLinker->Link("", "lib_6_3", exportMap); - if (m_debugOutput) - { - saveModuleToAsmFile(M.get(), "combined.ll"); - } - } + std::vector> pShaderLibs(libCount); + for (UINT i = 0; i < libCount; i++) { + hlsl::DxcCreateBlobWithEncodingFromPinned(pLibs[i].pData, pLibs[i].Size, + CP_ACP, &pShaderLibs[i]); + } - dxilutil::ExportMap exportMap; - for (UINT i = 0; i < ExportCount; i++) - { - auto &exportDesc = pExports[i]; - auto exportName = ws2s(exportDesc.ExportName); - if (exportDesc.ExportToRename) - { - auto exportToRename = ws2s(exportDesc.ExportToRename); - CloneFunction( - M->getFunction(exportToRename), - exportName, - M.get()); - } - exportMap.Add(GetUnmangledName(exportName)); + // Link all the modules together into a single into library + unsigned int valMajor = 0, valMinor = 0; + dxcutil::GetValidatorVersion(&valMajor, &valMinor); + + std::unique_ptr M; + { + DxilLinker *pLinker = + DxilLinker::CreateLinker(context, valMajor, valMinor); + for (UINT32 i = 0; i < libCount; ++i) { + DxilModule *dxil = ExtractDxil(context, pShaderLibs[i]); + if (dxil == nullptr) { + return DXC_E_CONTAINER_MISSING_DXIL; } + pLinker->RegisterLib(std::to_string(i), + std::unique_ptr(dxil->GetModule()), + nullptr); + pLinker->AttachLib(std::to_string(i)); + } - // Create the compute shader - DxilLinker* pLinker = DxilLinker::CreateLinker(context, valMajor, valMinor); - pLinker->RegisterLib("M", std::move(M), nullptr); - pLinker->AttachLib("M"); - auto profile = "lib_6_3"; - M = pLinker->Link(StringRef(), profile, exportMap); - bool hasErrors = DiagContext.HasErrors(); + dxilutil::ExportMap exportMap; + M = pLinker->Link("", "lib_6_3", exportMap); + if (m_debugOutput) { + saveModuleToAsmFile(M.get(), "combined.ll"); + } + } - CComPtr pResultBlob; - if (M) - { - CComPtr pOutputStream; - IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pOutputStream)); - raw_stream_ostream outStream(pOutputStream.p); - WriteBitcodeToFile(M.get(), outStream); - outStream.flush(); - - // Validation. - dxcutil::AssembleInputs inputs( - std::move(M), pResultBlob, TM.GetInstalledAllocator(), SerializeDxilFlags::None, - pOutputStream); - dxcutil::AssembleToContainer(inputs); - } + dxilutil::ExportMap exportMap; + for (UINT i = 0; i < ExportCount; i++) { + auto &exportDesc = pExports[i]; + auto exportName = ws2s(exportDesc.ExportName); + if (exportDesc.ExportToRename) { + auto exportToRename = ws2s(exportDesc.ExportToRename); + CloneFunction(M->getFunction(exportToRename), exportName, M.get()); + } + exportMap.Add(GetUnmangledName(exportName)); + } - DiagStream.flush(); - CComPtr pStream = static_cast>(pDiagStream); - std::string warnings; - dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, hasErrors, ppResult); + // Create the compute shader + DxilLinker *pLinker = DxilLinker::CreateLinker(context, valMajor, valMinor); + pLinker->RegisterLib("M", std::move(M), nullptr); + pLinker->AttachLib("M"); + auto profile = "lib_6_3"; + M = pLinker->Link(StringRef(), profile, exportMap); + bool hasErrors = DiagContext.HasErrors(); + + CComPtr pResultBlob; + if (M) { + CComPtr pOutputStream; + IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pOutputStream)); + raw_stream_ostream outStream(pOutputStream.p); + WriteBitcodeToFile(M.get(), outStream); + outStream.flush(); + + // Validation. + dxcutil::AssembleInputs inputs(std::move(M), pResultBlob, + TM.GetInstalledAllocator(), + SerializeDxilFlags::None, pOutputStream); + dxcutil::AssembleToContainer(inputs); } - CATCH_CPP_ASSIGN_HRESULT(); - return hr; + DiagStream.flush(); + CComPtr pStream = static_cast>(pDiagStream); + std::string warnings; + dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, + hasErrors, ppResult); + } + CATCH_CPP_ASSIGN_HRESULT(); + + return hr; } HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::PatchShaderBindingTables( - _In_ const LPCWSTR pEntryName, - _In_ DxcShaderBytecode *pShaderBytecode, - void *pShaderInfo, - _COM_Outptr_ IDxcOperationResult **ppResult -) -{ - if (pShaderBytecode == nullptr || pShaderInfo == nullptr) - return E_POINTER; - - *ppResult = nullptr; - HRESULT hr = S_OK; - DxcThreadMalloc TM(m_pMalloc); - LLVMContext context; - try - { - CComPtr pShaderBlob; - hlsl::DxcCreateBlobWithEncodingFromPinned(pShaderBytecode->pData, pShaderBytecode->Size, CP_ACP, &pShaderBlob); - - // Init file system because we are currently loading the runtime from disk - ::llvm::sys::fs::MSFileSystem *msfPtr; - IFT(CreateMSFileSystemForDisk(&msfPtr)); - std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr); - ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get()); - IFTLLVM(pts.error_code()); - - // Create a diagnostic printer - CComPtr pDiagStream; - IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pDiagStream)); - raw_stream_ostream DiagStream(pDiagStream); - DiagnosticPrinterRawOStream DiagPrinter(DiagStream); - PrintDiagnosticContext DiagContext(DiagPrinter); - context.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler, - &DiagContext, true); - - DxilModule* dxil = ExtractDxil(context, pShaderBlob); - - // TODO: Lifetime managment? - std::unique_ptr M(dxil->GetModule()); - if (dxil == nullptr) - { - return DXC_E_CONTAINER_MISSING_DXIL; - } + const LPCWSTR pEntryName, DxcShaderBytecode *pShaderBytecode, + void *pShaderInfo, IDxcOperationResult **ppResult) { + if (pShaderBytecode == nullptr || pShaderInfo == nullptr) + return E_POINTER; - ModulePass *patchShaderRecordBindingsPass = createDxilPatchShaderRecordBindingsPass(); + *ppResult = nullptr; + HRESULT hr = S_OK; + DxcThreadMalloc TM(m_pMalloc); + LLVMContext context; + try { + CComPtr pShaderBlob; + hlsl::DxcCreateBlobWithEncodingFromPinned( + pShaderBytecode->pData, pShaderBytecode->Size, CP_ACP, &pShaderBlob); - char dxilPatchShaderRecordString[32]; - StringCchPrintf(dxilPatchShaderRecordString, _countof(dxilPatchShaderRecordString), - "%p", pShaderInfo); - auto passOption = PassOption("root-signature", dxilPatchShaderRecordString); - PassOptions options(passOption); - patchShaderRecordBindingsPass->applyOptions(options); + // Init file system because we are currently loading the runtime from disk + ::llvm::sys::fs::MSFileSystem *msfPtr; + IFT(CreateMSFileSystemForDisk(&msfPtr)); + std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr); + ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get()); + IFTLLVM(pts.error_code()); - legacy::PassManager FPM; - FPM.add(patchShaderRecordBindingsPass); - FPM.run(*M); + // Create a diagnostic printer + CComPtr pDiagStream; + IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pDiagStream)); + raw_stream_ostream DiagStream(pDiagStream); + DiagnosticPrinterRawOStream DiagPrinter(DiagStream); + PrintDiagnosticContext DiagContext(DiagPrinter); + context.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler, + &DiagContext, true); - CComPtr pResultBlob; - if (M) - { - CComPtr pOutputStream; - IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pOutputStream)); - raw_stream_ostream outStream(pOutputStream.p); - WriteBitcodeToFile(M.get(), outStream); - outStream.flush(); - dxcutil::AssembleInputs inputs( - std::move(M), - pResultBlob, - TM.GetInstalledAllocator(), - SerializeDxilFlags::None, - pOutputStream); - dxcutil::AssembleToContainer(inputs); - } + DxilModule *dxil = ExtractDxil(context, pShaderBlob); - DiagStream.flush(); - CComPtr pStream = static_cast>(pDiagStream); - std::string warnings; - dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, false, ppResult); + // TODO: Lifetime managment? + std::unique_ptr M(dxil->GetModule()); + if (dxil == nullptr) { + return DXC_E_CONTAINER_MISSING_DXIL; } - CATCH_CPP_ASSIGN_HRESULT(); - return hr; + ModulePass *patchShaderRecordBindingsPass = + createDxilPatchShaderRecordBindingsPass(); + + char dxilPatchShaderRecordString[32]; + StringCchPrintf(dxilPatchShaderRecordString, + _countof(dxilPatchShaderRecordString), "%p", pShaderInfo); + auto passOption = PassOption("root-signature", dxilPatchShaderRecordString); + PassOptions options(passOption); + patchShaderRecordBindingsPass->applyOptions(options); + + legacy::PassManager FPM; + FPM.add(patchShaderRecordBindingsPass); + FPM.run(*M); + + CComPtr pResultBlob; + if (M) { + CComPtr pOutputStream; + IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pOutputStream)); + raw_stream_ostream outStream(pOutputStream.p); + WriteBitcodeToFile(M.get(), outStream); + outStream.flush(); + dxcutil::AssembleInputs inputs(std::move(M), pResultBlob, + TM.GetInstalledAllocator(), + SerializeDxilFlags::None, pOutputStream); + dxcutil::AssembleToContainer(inputs); + } + + DiagStream.flush(); + CComPtr pStream = static_cast>(pDiagStream); + std::string warnings; + dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, + false, ppResult); + } + CATCH_CPP_ASSIGN_HRESULT(); + + return hr; } HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::Link( - _In_ const LPCWSTR pEntryName, - _In_count_(libCount) IDxcBlob **pLibs, - UINT32 libCount, - _In_count_(shaderCount) const LPCWSTR *pShaderNames, - _In_count_(shaderCount) DxcShaderInfo *pShaderInfo, - UINT32 shaderCount, - UINT32 maxAttributeSize, - UINT32 stackSizeInBytes, - _COM_Outptr_ IDxcOperationResult **ppResult -) -{ - if (pLibs == nullptr || pShaderNames == nullptr || ppResult == nullptr) - return E_POINTER; + const LPCWSTR pEntryName, IDxcBlob **pLibs, UINT32 libCount, + const LPCWSTR *pShaderNames, DxcShaderInfo *pShaderInfo, UINT32 shaderCount, + UINT32 maxAttributeSize, UINT32 stackSizeInBytes, + IDxcOperationResult **ppResult) { + if (pLibs == nullptr || pShaderNames == nullptr || ppResult == nullptr) + return E_POINTER; + + if (libCount == 0 || shaderCount == 0) + return E_INVALIDARG; + + *ppResult = nullptr; + HRESULT hr = S_OK; + DxcThreadMalloc TM(m_pMalloc); + LLVMContext context; + try { + // Init file system because we are currently loading the runtime from disk + ::llvm::sys::fs::MSFileSystem *msfPtr; + IFT(CreateMSFileSystemForDisk(&msfPtr)); + std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr); + ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get()); + IFTLLVM(pts.error_code()); - if (libCount == 0 || shaderCount == 0) - return E_INVALIDARG; + // Create a diagnostic printer + CComPtr pDiagStream; + IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pDiagStream)); + raw_stream_ostream DiagStream(pDiagStream); + DiagnosticPrinterRawOStream DiagPrinter(DiagStream); + PrintDiagnosticContext DiagContext(DiagPrinter); + context.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler, + &DiagContext, true); - *ppResult = nullptr; - HRESULT hr = S_OK; - DxcThreadMalloc TM(m_pMalloc); - LLVMContext context; - try + std::vector shaderNames(shaderCount); + for (UINT32 i = 0; i < shaderCount; ++i) + shaderNames[i] = ws2s(pShaderNames[i]); + + // Link all the modules together into a single into library + unsigned int valMajor = 0, valMinor = 0; + dxcutil::GetValidatorVersion(&valMajor, &valMinor); + std::unique_ptr M; { - // Init file system because we are currently loading the runtime from disk - ::llvm::sys::fs::MSFileSystem *msfPtr; - IFT(CreateMSFileSystemForDisk(&msfPtr)); - std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr); - ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get()); - IFTLLVM(pts.error_code()); - - // Create a diagnostic printer - CComPtr pDiagStream; - IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pDiagStream)); - raw_stream_ostream DiagStream(pDiagStream); - DiagnosticPrinterRawOStream DiagPrinter(DiagStream); - PrintDiagnosticContext DiagContext(DiagPrinter); - context.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler, - &DiagContext, true); - - - std::vector shaderNames(shaderCount); - for (UINT32 i = 0; i < shaderCount; ++i) - shaderNames[i] = ws2s(pShaderNames[i]); - - // Link all the modules together into a single into library - unsigned int valMajor = 0, valMinor = 0; - dxcutil::GetValidatorVersion(&valMajor, &valMinor); - std::unique_ptr M; - { - DxilLinker* pLinker = DxilLinker::CreateLinker(context, valMajor, valMinor); - for (UINT32 i = 0; i < libCount; ++i) - { - DxilModule* dxil = ExtractDxil(context, pLibs[i]); - if (dxil == nullptr) - { - return DXC_E_CONTAINER_MISSING_DXIL; - } - pLinker->RegisterLib(std::to_string(i), std::unique_ptr(dxil->GetModule()), nullptr); - pLinker->AttachLib(std::to_string(i)); - } - - dxilutil::ExportMap exportMap; - M = pLinker->Link("", "lib_6_3", exportMap); - if (m_debugOutput) - { - saveModuleToAsmFile(M.get(), "combined.ll"); - } + DxilLinker *pLinker = + DxilLinker::CreateLinker(context, valMajor, valMinor); + for (UINT32 i = 0; i < libCount; ++i) { + DxilModule *dxil = ExtractDxil(context, pLibs[i]); + if (dxil == nullptr) { + return DXC_E_CONTAINER_MISSING_DXIL; } + pLinker->RegisterLib(std::to_string(i), + std::unique_ptr(dxil->GetModule()), + nullptr); + pLinker->AttachLib(std::to_string(i)); + } - std::vector shaderEntryStateIds; - std::vector shaderStackSizes; + dxilutil::ExportMap exportMap; + M = pLinker->Link("", "lib_6_3", exportMap); + if (m_debugOutput) { + saveModuleToAsmFile(M.get(), "combined.ll"); + } + } - DxrFallbackCompiler compiler(M.get(), shaderNames, maxAttributeSize, stackSizeInBytes, m_findCalledShaders); - compiler.setDebugOutputLevel(m_debugOutput); - shaderEntryStateIds.resize(shaderCount); - shaderStackSizes.resize(shaderCount); - for (UINT i = 0; i < shaderCount; i++) - { - shaderEntryStateIds[i] = pShaderInfo[i].Identifier; - shaderStackSizes[i] = pShaderInfo[i].StackSize; - } - compiler.link(shaderEntryStateIds, shaderStackSizes, m_pCachedMap.get()); - if (m_debugOutput) - { - saveModuleToAsmFile(M.get(), "compiled.ll"); - } + std::vector shaderEntryStateIds; + std::vector shaderStackSizes; + DxrFallbackCompiler compiler(M.get(), shaderNames, maxAttributeSize, + stackSizeInBytes, m_findCalledShaders); + compiler.setDebugOutputLevel(m_debugOutput); + shaderEntryStateIds.resize(shaderCount); + shaderStackSizes.resize(shaderCount); + for (UINT i = 0; i < shaderCount; i++) { + shaderEntryStateIds[i] = pShaderInfo[i].Identifier; + shaderStackSizes[i] = pShaderInfo[i].StackSize; + } + compiler.link(shaderEntryStateIds, shaderStackSizes, m_pCachedMap.get()); + if (m_debugOutput) { + saveModuleToAsmFile(M.get(), "compiled.ll"); + } - // Create the compute shader - dxilutil::ExportMap exportMap; - DxilLinker* pLinker = DxilLinker::CreateLinker(context, valMajor, valMinor); - pLinker->RegisterLib("M", std::move(M), nullptr); - pLinker->AttachLib("M"); - auto profile = "cs_6_0"; - M = pLinker->Link(pEntryName ? ws2s(pEntryName).c_str() : StringRef(), profile, exportMap); - bool hasErrors = DiagContext.HasErrors(); + // Create the compute shader + dxilutil::ExportMap exportMap; + DxilLinker *pLinker = DxilLinker::CreateLinker(context, valMajor, valMinor); + pLinker->RegisterLib("M", std::move(M), nullptr); + pLinker->AttachLib("M"); + auto profile = "cs_6_0"; + M = pLinker->Link(pEntryName ? ws2s(pEntryName).c_str() : StringRef(), + profile, exportMap); + bool hasErrors = DiagContext.HasErrors(); - CComPtr pResultBlob; - if (M) - { - if (!hasErrors && stackSizeInBytes) - DxrFallbackCompiler::resizeStack(M->getFunction(ws2s(pEntryName).c_str()), stackSizeInBytes); - - llvm::NamedMDNode *IdentMetadata = M->getOrInsertNamedMetadata("llvm.ident"); - llvm::LLVMContext &Ctx = M->getContext(); - llvm::Metadata *IdentNode[] = { llvm::MDString::get(Ctx, "FallbackLayer") }; - IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode)); - - DxilModule& DM = M->GetDxilModule(); - DM.SetValidatorVersion(valMajor, valMinor); - DxilModule::ClearDxilMetadata(*M); - DM.EmitDxilMetadata(); - - if (m_debugOutput) - saveModuleToAsmFile(M.get(), "linked.ll"); - - #if !DISABLE_GET_CUSTOM_DIAG_ID - const IntrusiveRefCntPtr Diags( - new clang::DiagnosticIDs); - IntrusiveRefCntPtr DiagOpts = - new clang::DiagnosticOptions(); - // Construct our diagnostic client. - clang::TextDiagnosticPrinter *DiagClient = - new clang::TextDiagnosticPrinter(DiagStream, &*DiagOpts); - clang::DiagnosticsEngine Diag(Diags, &*DiagOpts, DiagClient); - #endif - } + CComPtr pResultBlob; + if (M) { + if (!hasErrors && stackSizeInBytes) + DxrFallbackCompiler::resizeStack( + M->getFunction(ws2s(pEntryName).c_str()), stackSizeInBytes); + + llvm::NamedMDNode *IdentMetadata = + M->getOrInsertNamedMetadata("llvm.ident"); + llvm::LLVMContext &Ctx = M->getContext(); + llvm::Metadata *IdentNode[] = {llvm::MDString::get(Ctx, "FallbackLayer")}; + IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode)); + + DxilModule &DM = M->GetDxilModule(); + DM.SetValidatorVersion(valMajor, valMinor); + DxilModule::ClearDxilMetadata(*M); + DM.EmitDxilMetadata(); + + if (m_debugOutput) + saveModuleToAsmFile(M.get(), "linked.ll"); + +#if !DISABLE_GET_CUSTOM_DIAG_ID + const IntrusiveRefCntPtr Diags( + new clang::DiagnosticIDs); + IntrusiveRefCntPtr DiagOpts = + new clang::DiagnosticOptions(); + // Construct our diagnostic client. + clang::TextDiagnosticPrinter *DiagClient = + new clang::TextDiagnosticPrinter(DiagStream, &*DiagOpts); + clang::DiagnosticsEngine Diag(Diags, &*DiagOpts, DiagClient); +#endif + } - if (M) - { - CComPtr pOutputStream; - IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pOutputStream)); - raw_stream_ostream outStream(pOutputStream.p); - WriteBitcodeToFile(M.get(), outStream); - outStream.flush(); - - // Validation. - dxcutil::AssembleInputs inputs( - std::move(M), pResultBlob, TM.GetInstalledAllocator(), SerializeDxilFlags::None, - pOutputStream, - /*bDebugInfo*/ false - ); - HRESULT valHR = dxcutil::ValidateAndAssembleToContainer(inputs); - - if (FAILED(valHR)) - hasErrors = true; - } + if (M) { + CComPtr pOutputStream; + IFT(CreateMemoryStream(TM.GetInstalledAllocator(), &pOutputStream)); + raw_stream_ostream outStream(pOutputStream.p); + WriteBitcodeToFile(M.get(), outStream); + outStream.flush(); + + // Validation. + dxcutil::AssembleInputs inputs(std::move(M), pResultBlob, + TM.GetInstalledAllocator(), + SerializeDxilFlags::None, pOutputStream, + /*bDebugInfo*/ false); + HRESULT valHR = dxcutil::ValidateAndAssembleToContainer(inputs); - DiagStream.flush(); - CComPtr pStream = static_cast>(pDiagStream); - std::string warnings; - dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, hasErrors, ppResult); + if (FAILED(valHR)) + hasErrors = true; } - CATCH_CPP_ASSIGN_HRESULT(); - return hr; + DiagStream.flush(); + CComPtr pStream = static_cast>(pDiagStream); + std::string warnings; + dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, + hasErrors, ppResult); + } + CATCH_CPP_ASSIGN_HRESULT(); + + return hr; } HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::Compile( - _In_count_(libCount) DxcShaderBytecode *pShaderLibs, - UINT32 libCount, - _In_count_(shaderCount) const LPCWSTR *pShaderNames, - _Out_writes_(shaderCount) DxcShaderInfo *pShaderInfo, - UINT32 shaderCount, - UINT32 maxAttributeSize, - _COM_Outptr_ IDxcOperationResult **ppResult -) -{ + DxcShaderBytecode *pShaderLibs, UINT32 libCount, + const LPCWSTR *pShaderNames, DxcShaderInfo *pShaderInfo, UINT32 shaderCount, + UINT32 maxAttributeSize, IDxcOperationResult **ppResult) { if (pShaderLibs == nullptr || pShaderNames == nullptr || ppResult == nullptr) return E_POINTER; @@ -750,9 +695,7 @@ HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::Compile( return hr; } - -HRESULT CreateDxcDxrFallbackCompiler(_In_ REFIID riid, _Out_ LPVOID *ppv) -{ +HRESULT CreateDxcDxrFallbackCompiler(REFIID riid, LPVOID *ppv) { CComPtr result = DxcDxrFallbackCompiler::Alloc(DxcGetThreadMallocNoRef()); if (result == nullptr) { @@ -762,21 +705,3 @@ HRESULT CreateDxcDxrFallbackCompiler(_In_ REFIID riid, _Out_ LPVOID *ppv) return result.p->QueryInterface(riid, ppv); } - - - - - - - - - - - - - - - - - - diff --git a/tools/clang/tools/dxrfallbackcompiler/dxcutil.cpp b/tools/clang/tools/dxrfallbackcompiler/dxcutil.cpp index 347ea19ed2..6c01bab0be 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxcutil.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxcutil.cpp @@ -35,16 +35,14 @@ using namespace llvm; using namespace hlsl; // This declaration is used for the locally-linked validator. -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID *ppv); +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv); // This internal call allows the validator to avoid having to re-deserialize // the module. It trusts that the caller didn't make any changes and is // kept internal because the layout of the module class may change based // on changes across modules, or picking a different compiler version or CRT. -HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, - _In_ llvm::Module *pModule, - _In_ llvm::Module *pDebugModule, - _In_ IDxcBlob *pShader, UINT32 Flags, - _In_ IDxcOperationResult **ppResult); +HRESULT RunInternalValidator(IDxcValidator *pValidator, llvm::Module *pModule, + llvm::Module *pDebugModule, IDxcBlob *pShader, + UINT32 Flags, IDxcOperationResult **ppResult); namespace { // AssembleToContainer helper functions. @@ -119,8 +117,7 @@ void AssembleToContainer(AssembleInputs &inputs) { void ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, hlsl::options::DxcOpts &opts, AbstractMemoryStream *pOutputStream, - _COM_Outptr_ IDxcOperationResult **ppResult, - bool &finished) { + IDxcOperationResult **ppResult, bool &finished) { const llvm::opt::OptTable *table = ::options::getHlslOptTable(); raw_stream_ostream outStream(pOutputStream); if (0 != hlsl::options::ReadDxcOpts(table, hlsl::options::CompilerFlags, @@ -262,10 +259,9 @@ HRESULT ValidateRootSignatureInContainer( } void CreateOperationResultFromOutputs( - DXC_OUT_KIND resultKind, UINT32 textEncoding, - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult) { + DXC_OUT_KIND resultKind, UINT32 textEncoding, IDxcBlob *pResultBlob, + CComPtr &pErrorStream, const std::string &warnings, + bool hasErrorOccurred, IDxcOperationResult **ppResult) { CComPtr pResult = DxcResult::Alloc(DxcGetThreadMallocNoRef()); IFT(pResult->SetEncoding(textEncoding)); IFT(pResult->SetStatusAndPrimaryResult(hasErrorOccurred ? E_FAIL : S_OK, resultKind)); @@ -280,10 +276,11 @@ void CreateOperationResultFromOutputs( IFT(pResult.QueryInterface(ppResult)); } -void CreateOperationResultFromOutputs( - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult) { +void CreateOperationResultFromOutputs(IDxcBlob *pResultBlob, + CComPtr &pErrorStream, + const std::string &warnings, + bool hasErrorOccurred, + IDxcOperationResult **ppResult) { CreateOperationResultFromOutputs(DXC_OUT_OBJECT, DXC_CP_UTF8, pResultBlob, pErrorStream, warnings, hasErrorOccurred, ppResult); } diff --git a/tools/clang/tools/dxrfallbackcompiler/dxcutil.h b/tools/clang/tools/dxrfallbackcompiler/dxcutil.h index e93525c318..9edfe04f16 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxcutil.h +++ b/tools/clang/tools/dxrfallbackcompiler/dxcutil.h @@ -74,18 +74,17 @@ HRESULT Disassemble(IDxcBlob *pProgram, llvm::raw_string_ostream &Stream); void ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, hlsl::options::DxcOpts &opts, hlsl::AbstractMemoryStream *pOutputStream, - _COM_Outptr_ IDxcOperationResult **ppResult, - bool &finished); + IDxcOperationResult **ppResult, bool &finished); void CreateOperationResultFromOutputs( - DXC_OUT_KIND resultKind, UINT32 textEncoding, - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult); -void CreateOperationResultFromOutputs( - IDxcBlob *pResultBlob, CComPtr &pErrorStream, - const std::string &warnings, bool hasErrorOccurred, - _COM_Outptr_ IDxcOperationResult **ppResult); + DXC_OUT_KIND resultKind, UINT32 textEncoding, IDxcBlob *pResultBlob, + CComPtr &pErrorStream, const std::string &warnings, + bool hasErrorOccurred, IDxcOperationResult **ppResult); +void CreateOperationResultFromOutputs(IDxcBlob *pResultBlob, + CComPtr &pErrorStream, + const std::string &warnings, + bool hasErrorOccurred, + IDxcOperationResult **ppResult); bool IsAbsoluteOrCurDirRelative(const llvm::Twine &T); -} // namespace dxcutil \ No newline at end of file +} // namespace dxcutil diff --git a/tools/clang/tools/dxrfallbackcompiler/dxcvalidator.cpp b/tools/clang/tools/dxrfallbackcompiler/dxcvalidator.cpp index 7691cb4b52..5855f2eb68 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxcvalidator.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxcvalidator.cpp @@ -51,15 +51,14 @@ class DxcValidator : public IDxcValidator, public IDxcVersionInfo { DXC_MICROCOM_TM_REF_FIELDS() HRESULT RunValidation( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_ llvm::Module *pModule, // Module to validate, if available. - _In_ llvm::Module *pDebugModule, // Debug module to validate, if available - _In_ AbstractMemoryStream *pDiagStream); + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + AbstractMemoryStream *pDiagStream); - HRESULT RunRootSignatureValidation( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ AbstractMemoryStream *pDiagStream); + HRESULT RunRootSignatureValidation(IDxcBlob *pShader, // Shader to validate. + AbstractMemoryStream *pDiagStream); public: DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL() @@ -71,30 +70,34 @@ class DxcValidator : public IDxcValidator, public IDxcVersionInfo { // For internal use only. HRESULT ValidateWithOptModules( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_ llvm::Module *pModule, // Module to validate, if available. - _In_ llvm::Module *pDebugModule, // Debug module to validate, if available - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors ); // IDxcValidator __override HRESULT STDMETHODCALLTYPE Validate( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors - ); + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors + ); // IDxcVersionInfo - __override HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor); - __override HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags); + __override HRESULT STDMETHODCALLTYPE GetVersion(UINT32 *pMajor, + UINT32 *pMinor); + __override HRESULT STDMETHODCALLTYPE GetFlags(UINT32 *pFlags); }; // Compile a single entry point to the target shader model HRESULT STDMETHODCALLTYPE DxcValidator::Validate( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors ) { DxcThreadMalloc TM(m_pMalloc); if (pShader == nullptr || ppResult == nullptr || Flags & ~DxcValidatorFlags_ValidMask) @@ -105,11 +108,12 @@ HRESULT STDMETHODCALLTYPE DxcValidator::Validate( } HRESULT DxcValidator::ValidateWithOptModules( - _In_ IDxcBlob *pShader, // Shader to validate. - _In_ UINT32 Flags, // Validation flags. - _In_ llvm::Module *pModule, // Module to validate, if available. - _In_ llvm::Module *pDebugModule, // Debug module to validate, if available - _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors + IDxcBlob *pShader, // Shader to validate. + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + IDxcOperationResult * + *ppResult // Validation output status, buffer, and errors ) { *ppResult = nullptr; HRESULT hr = S_OK; @@ -147,14 +151,15 @@ HRESULT DxcValidator::ValidateWithOptModules( return hr; } -HRESULT STDMETHODCALLTYPE DxcValidator::GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) { +HRESULT STDMETHODCALLTYPE DxcValidator::GetVersion(UINT32 *pMajor, + UINT32 *pMinor) { if (pMajor == nullptr || pMinor == nullptr) return E_INVALIDARG; GetValidationVersion(pMajor, pMinor); return S_OK; } -HRESULT STDMETHODCALLTYPE DxcValidator::GetFlags(_Out_ UINT32 *pFlags) { +HRESULT STDMETHODCALLTYPE DxcValidator::GetFlags(UINT32 *pFlags) { if (pFlags == nullptr) return E_INVALIDARG; *pFlags = DxcVersionInfoFlags_None; @@ -166,11 +171,11 @@ HRESULT STDMETHODCALLTYPE DxcValidator::GetFlags(_Out_ UINT32 *pFlags) { } HRESULT DxcValidator::RunValidation( - _In_ IDxcBlob *pShader, - _In_ UINT32 Flags, // Validation flags. - _In_ llvm::Module *pModule, // Module to validate, if available. - _In_ llvm::Module *pDebugModule, // Debug module to validate, if available - _In_ AbstractMemoryStream *pDiagStream) { + IDxcBlob *pShader, + UINT32 Flags, // Validation flags. + llvm::Module *pModule, // Module to validate, if available. + llvm::Module *pDebugModule, // Debug module to validate, if available + AbstractMemoryStream *pDiagStream) { // Run validation may throw, but that indicates an inability to validate, // not that the validation failed (eg out of memory). That is indicated @@ -211,9 +216,9 @@ HRESULT DxcValidator::RunValidation( return S_OK; } -HRESULT DxcValidator::RunRootSignatureValidation( - _In_ IDxcBlob *pShader, - _In_ AbstractMemoryStream *pDiagStream) { +HRESULT +DxcValidator::RunRootSignatureValidation(IDxcBlob *pShader, + AbstractMemoryStream *pDiagStream) { const DxilContainerHeader *pDxilContainer = IsDxilContainerLike( pShader->GetBufferPointer(), pShader->GetBufferSize()); @@ -245,11 +250,9 @@ HRESULT DxcValidator::RunRootSignatureValidation( /////////////////////////////////////////////////////////////////////////////// -HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, - _In_ llvm::Module *pModule, - _In_ llvm::Module *pDebugModule, - _In_ IDxcBlob *pShader, UINT32 Flags, - _COM_Outptr_ IDxcOperationResult **ppResult) { +HRESULT RunInternalValidator(IDxcValidator *pValidator, llvm::Module *pModule, + llvm::Module *pDebugModule, IDxcBlob *pShader, + UINT32 Flags, IDxcOperationResult **ppResult) { DXASSERT_NOMSG(pValidator != nullptr); DXASSERT_NOMSG(pModule != nullptr); DXASSERT_NOMSG(pShader != nullptr); @@ -260,7 +263,7 @@ HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator, pDebugModule, ppResult); } -HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcValidator(REFIID riid, LPVOID *ppv) { try { CComPtr result(DxcValidator::Alloc(DxcGetThreadMallocNoRef())); IFROOM(result.p); diff --git a/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp b/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp index cdfb08527f..f932ecfad8 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxillib.cpp @@ -55,8 +55,8 @@ bool DxilLibIsEnabled() { return SUCCEEDED(g_DllLibResult); } - -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid, _In_ IUnknown **ppInterface) { +HRESULT DxilLibCreateInstance(REFCLSID rclsid, REFIID riid, + IUnknown **ppInterface) { DXASSERT_NOMSG(ppInterface != nullptr); HRESULT hr = E_FAIL; if (DxilLibIsEnabled()) { diff --git a/tools/clang/tools/dxrfallbackcompiler/dxillib.h b/tools/clang/tools/dxrfallbackcompiler/dxillib.h index 746b2d0cab..805089c10f 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxillib.h +++ b/tools/clang/tools/dxrfallbackcompiler/dxillib.h @@ -32,11 +32,12 @@ HRESULT DxilLibCleanup(DxilLibCleanUpType type); // Check if can access dxil.dll bool DxilLibIsEnabled(); -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid, _In_ IUnknown **ppInterface); +HRESULT DxilLibCreateInstance(REFCLSID rclsid, REFIID riid, + IUnknown **ppInterface); template -HRESULT DxilLibCreateInstance(_In_ REFCLSID rclsid, _In_ TInterface **ppInterface) { +HRESULT DxilLibCreateInstance(REFCLSID rclsid, TInterface **ppInterface) { return DxilLibCreateInstance(rclsid, __uuidof(TInterface), (IUnknown**) ppInterface); } -#endif // __DXC_DXILLIB__ \ No newline at end of file +#endif // __DXC_DXILLIB__ diff --git a/tools/clang/tools/dxv/dxv.cpp b/tools/clang/tools/dxv/dxv.cpp index db8ee84ac5..619aab0c76 100644 --- a/tools/clang/tools/dxv/dxv.cpp +++ b/tools/clang/tools/dxv/dxv.cpp @@ -126,7 +126,7 @@ void DxvContext::Validate() { } #ifdef _WIN32 -int __cdecl main(int argc, _In_reads_z_(argc) const char **argv) { +int __cdecl main(int argc, const char **argv) { #else int main(int argc, const char **argv) { #endif diff --git a/tools/clang/tools/libclang/dxcisenseimpl.cpp b/tools/clang/tools/libclang/dxcisenseimpl.cpp index 1439705d17..727d9bf194 100644 --- a/tools/clang/tools/libclang/dxcisenseimpl.cpp +++ b/tools/clang/tools/libclang/dxcisenseimpl.cpp @@ -35,8 +35,7 @@ /////////////////////////////////////////////////////////////////////////////// -HRESULT CreateDxcIntelliSense(_In_ REFIID riid, _Out_ LPVOID* ppv) throw() -{ +HRESULT CreateDxcIntelliSense(REFIID riid, LPVOID *ppv) throw() { CComPtr isense = CreateOnMalloc(DxcGetThreadMallocNoRef()); if (isense == nullptr) { @@ -68,12 +67,13 @@ class DxcBasicUnsavedFile : public IDxcUnsavedFile DxcBasicUnsavedFile(IMalloc *pMalloc); ~DxcBasicUnsavedFile(); - HRESULT Initialize(_In_z_ LPCSTR fileName, _In_z_ LPCSTR contents, unsigned length); - static HRESULT Create(_In_z_ LPCSTR fileName, _In_z_ LPCSTR contents, unsigned length, _COM_Outptr_ IDxcUnsavedFile** pObject); + HRESULT Initialize(LPCSTR fileName, LPCSTR contents, unsigned length); + static HRESULT Create(LPCSTR fileName, LPCSTR contents, unsigned length, + IDxcUnsavedFile **pObject); - HRESULT STDMETHODCALLTYPE GetFileName(_Outptr_result_z_ LPSTR* pFileName) override; - HRESULT STDMETHODCALLTYPE GetContents(_Outptr_result_z_ LPSTR* pContents) override; - HRESULT STDMETHODCALLTYPE GetLength(_Out_ unsigned* pLength) override; + HRESULT STDMETHODCALLTYPE GetFileName(LPSTR *pFileName) override; + HRESULT STDMETHODCALLTYPE GetContents(LPSTR *pContents) override; + HRESULT STDMETHODCALLTYPE GetLength(unsigned *pLength) override; }; /////////////////////////////////////////////////////////////////////////////// @@ -82,9 +82,7 @@ static bool IsCursorKindQualifiedByParent(CXCursorKind kind) throw(); /////////////////////////////////////////////////////////////////////////////// -static -HRESULT AnsiToBSTR(_In_opt_z_ const char* text, _Outptr_result_maybenull_ BSTR* pValue) throw() -{ +static HRESULT AnsiToBSTR(const char *text, BSTR *pValue) throw() { if (pValue == nullptr) return E_POINTER; *pValue = nullptr; if (text == nullptr) @@ -115,7 +113,6 @@ HRESULT AnsiToBSTR(_In_opt_z_ const char* text, _Outptr_result_maybenull_ BSTR* } static -_Ret_opt_ _Post_readable_byte_size_(cb) __drv_allocatesMem(Mem) LPVOID CoTaskMemAllocZero(SIZE_T cb) throw() { LPVOID result = CoTaskMemAlloc(cb); @@ -132,15 +129,11 @@ LPVOID CoTaskMemAllocZero(SIZE_T cb) throw() /// error cases. /// template -static -void CoTaskMemAllocZeroElems(_In_ SIZE_T elementCount, _Outptr_result_buffer_maybenull_(elementCount) T**buf) throw() -{ +static void CoTaskMemAllocZeroElems(SIZE_T elementCount, T **buf) throw() { *buf = reinterpret_cast(CoTaskMemAllocZero(elementCount * sizeof(T))); } -static -HRESULT CXStringToAnsiAndDispose(CXString value, _Outptr_result_maybenull_ LPSTR* pValue) throw() -{ +static HRESULT CXStringToAnsiAndDispose(CXString value, LPSTR *pValue) throw() { if (pValue == nullptr) return E_POINTER; *pValue = nullptr; const char* text = clang_getCString(value); @@ -159,19 +152,14 @@ HRESULT CXStringToAnsiAndDispose(CXString value, _Outptr_result_maybenull_ LPSTR return S_OK; } -static -HRESULT CXStringToBSTRAndDispose(CXString value, _Outptr_result_maybenull_ BSTR* pValue) throw() -{ +static HRESULT CXStringToBSTRAndDispose(CXString value, BSTR *pValue) throw() { HRESULT hr = AnsiToBSTR(clang_getCString(value), pValue); clang_disposeString(value); return hr; } -static -void CleanupUnsavedFiles( - _In_count_(file_count) CXUnsavedFile * files, - unsigned file_count) throw() -{ +static void CleanupUnsavedFiles(CXUnsavedFile *files, + unsigned file_count) throw() { for (unsigned i = 0; i < file_count; ++i) { CoTaskMemFree((LPVOID)files[i].Filename); @@ -181,9 +169,7 @@ void CleanupUnsavedFiles( delete[] files; } -static -HRESULT CoTaskMemAllocString(_In_z_ const char* src, _Outptr_ LPSTR* pResult) throw() -{ +static HRESULT CoTaskMemAllocString(const char *src, LPSTR *pResult) throw() { assert(src != nullptr); if (pResult == nullptr) @@ -241,10 +227,8 @@ bool IsCursorKindQualifiedByParent(CXCursorKind kind) throw() kind == CXCursor_FunctionTemplate || kind == CXCursor_ClassTemplate || kind == CXCursor_ClassTemplatePartialSpecialization; } -template -static -void SafeReleaseIfaceArray(_Inout_count_(count) TIface** arr, unsigned count) throw() -{ +template +static void SafeReleaseIfaceArray(TIface **arr, unsigned count) throw() { if (arr != nullptr) { for (unsigned i = 0; i < count; i++) @@ -258,12 +242,9 @@ void SafeReleaseIfaceArray(_Inout_count_(count) TIface** arr, unsigned count) th } } -static -HRESULT SetupUnsavedFiles( - _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files, - unsigned num_unsaved_files, - _Outptr_result_buffer_maybenull_(num_unsaved_files) CXUnsavedFile** files) -{ +static HRESULT SetupUnsavedFiles(IDxcUnsavedFile **unsaved_files, + unsigned num_unsaved_files, + CXUnsavedFile **files) { *files = nullptr; if (num_unsaved_files == 0) { @@ -345,12 +326,9 @@ CXChildVisitResult LIBCLANG_CC PagedCursorTraverseVisit(CXCursor cursor, CXCurso return (pagedContext->top == 0) ? CXChildVisit_Break : CXChildVisit_Continue; } -static -HRESULT PagedCursorVisitorCopyResults( - _In_ PagedCursorVisitorContext* context, - _Out_ unsigned* pResultLength, - _Outptr_result_buffer_(*pResultLength) IDxcCursor*** pResult) -{ +static HRESULT PagedCursorVisitorCopyResults(PagedCursorVisitorContext *context, + unsigned *pResultLength, + IDxcCursor ***pResult) { *pResultLength = 0; *pResult = nullptr; @@ -462,7 +440,6 @@ DxcBasicUnsavedFile::~DxcBasicUnsavedFile() delete[] m_contents; } -_Use_decl_annotations_ HRESULT DxcBasicUnsavedFile::Initialize(LPCSTR fileName, LPCSTR contents, unsigned contentLength) { if (fileName == nullptr) return E_INVALIDARG; @@ -490,7 +467,6 @@ HRESULT DxcBasicUnsavedFile::Initialize(LPCSTR fileName, LPCSTR contents, unsign return S_OK; } -_Use_decl_annotations_ HRESULT DxcBasicUnsavedFile::Create( LPCSTR fileName, LPCSTR contents, unsigned contentLength, IDxcUnsavedFile** pObject) @@ -512,13 +488,11 @@ HRESULT DxcBasicUnsavedFile::Create( return S_OK; } -_Use_decl_annotations_ HRESULT DxcBasicUnsavedFile::GetFileName(LPSTR* pFileName) { return CoTaskMemAllocString(m_fileName, pFileName); } -_Use_decl_annotations_ HRESULT DxcBasicUnsavedFile::GetContents(LPSTR* pContents) { return CoTaskMemAllocString(m_contents, pContents); @@ -533,7 +507,6 @@ HRESULT DxcBasicUnsavedFile::GetLength(unsigned* pLength) /////////////////////////////////////////////////////////////////////////////// -_Use_decl_annotations_ HRESULT DxcCursor::Create(const CXCursor& cursor, IDxcCursor** pObject) { if (pObject == nullptr) return E_POINTER; @@ -551,7 +524,6 @@ void DxcCursor::Initialize(const CXCursor& cursor) m_cursor = cursor; } -_Use_decl_annotations_ HRESULT DxcCursor::GetExtent(IDxcSourceRange** pValue) { DxcThreadMalloc TM(m_pMalloc); @@ -559,14 +531,12 @@ HRESULT DxcCursor::GetExtent(IDxcSourceRange** pValue) return DxcSourceRange::Create(range, pValue); } -_Use_decl_annotations_ HRESULT DxcCursor::GetLocation(IDxcSourceLocation** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcSourceLocation::Create(clang_getCursorLocation(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetKind(DxcCursorKind* pResult) { if (pResult == nullptr) return E_POINTER; @@ -574,7 +544,6 @@ HRESULT DxcCursor::GetKind(DxcCursorKind* pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcCursor::GetKindFlags(DxcCursorKindFlags* pResult) { if (pResult == nullptr) return E_POINTER; @@ -593,28 +562,24 @@ HRESULT DxcCursor::GetKindFlags(DxcCursorKindFlags* pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcCursor::GetSemanticParent(IDxcCursor** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcCursor::Create(clang_getCursorSemanticParent(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetLexicalParent(IDxcCursor** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcCursor::Create(clang_getCursorLexicalParent(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetCursorType(IDxcType** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcType::Create(clang_getCursorType(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetNumArguments(int* pResult) { if (pResult == nullptr) return E_POINTER; @@ -622,28 +587,24 @@ HRESULT DxcCursor::GetNumArguments(int* pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcCursor::GetArgumentAt(int index, IDxcCursor** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcCursor::Create(clang_Cursor_getArgument(m_cursor, index), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetReferencedCursor(IDxcCursor** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcCursor::Create(clang_getCursorReferenced(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetDefinitionCursor(IDxcCursor** pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcCursor::Create(clang_getCursorDefinition(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::FindReferencesInFile( IDxcFile* file, unsigned skip, unsigned top, unsigned* pResultLength, IDxcCursor*** pResult) @@ -673,7 +634,6 @@ HRESULT DxcCursor::FindReferencesInFile( return PagedCursorVisitorCopyResults(&findReferencesInFileContext, pResultLength, pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetSpelling(LPSTR* pResult) { if (pResult == nullptr) return E_POINTER; @@ -681,8 +641,7 @@ HRESULT DxcCursor::GetSpelling(LPSTR* pResult) return CXStringToAnsiAndDispose(clang_getCursorSpelling(m_cursor), pResult); } -HRESULT DxcCursor::IsEqualTo(_In_ IDxcCursor* other, _Out_ BOOL* pResult) -{ +HRESULT DxcCursor::IsEqualTo(IDxcCursor *other, BOOL *pResult) { if (pResult == nullptr) return E_POINTER; if (other == nullptr) { @@ -696,21 +655,18 @@ HRESULT DxcCursor::IsEqualTo(_In_ IDxcCursor* other, _Out_ BOOL* pResult) return S_OK; } -HRESULT DxcCursor::IsNull(_Out_ BOOL* pResult) -{ +HRESULT DxcCursor::IsNull(BOOL *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = 0 != clang_Cursor_isNull(m_cursor); return S_OK; } -HRESULT DxcCursor::IsDefinition(_Out_ BOOL* pResult) -{ +HRESULT DxcCursor::IsDefinition(BOOL *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = 0 != clang_isCursorDefinition(m_cursor); return S_OK; } -_Use_decl_annotations_ HRESULT DxcCursor::GetDisplayName(BSTR* pResult) { if (pResult == nullptr) return E_POINTER; @@ -718,7 +674,6 @@ HRESULT DxcCursor::GetDisplayName(BSTR* pResult) return CXStringToBSTRAndDispose(clang_getCursorDisplayName(m_cursor), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetQualifiedName(BOOL includeTemplateArgs, BSTR* pResult) { if (pResult == nullptr) return E_POINTER; @@ -726,7 +681,6 @@ HRESULT DxcCursor::GetQualifiedName(BOOL includeTemplateArgs, BSTR* pResult) return GetCursorQualifiedName(m_cursor, includeTemplateArgs, pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetFormattedName(DxcCursorFormatting formatting, BSTR* pResult) { if (pResult == nullptr) return E_POINTER; @@ -734,7 +688,6 @@ HRESULT DxcCursor::GetFormattedName(DxcCursorFormatting formatting, BSTR* pResul return CXStringToBSTRAndDispose(clang_getCursorSpellingWithFormatting(m_cursor, formatting), pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetChildren( unsigned skip, unsigned top, unsigned* pResultLength, IDxcCursor*** pResult) @@ -757,7 +710,6 @@ HRESULT DxcCursor::GetChildren( return PagedCursorVisitorCopyResults(&visitorContext, pResultLength, pResult); } -_Use_decl_annotations_ HRESULT DxcCursor::GetSnappedChild(IDxcSourceLocation* location, IDxcCursor** pResult) { if (location == nullptr) return E_POINTER; @@ -799,7 +751,6 @@ void DxcDiagnostic::Initialize(const CXDiagnostic& diagnostic) m_diagnostic = diagnostic; } -_Use_decl_annotations_ HRESULT DxcDiagnostic::Create(const CXDiagnostic& diagnostic, IDxcDiagnostic** pObject) { if (pObject == nullptr) return E_POINTER; @@ -812,7 +763,6 @@ HRESULT DxcDiagnostic::Create(const CXDiagnostic& diagnostic, IDxcDiagnostic** p return S_OK; } -_Use_decl_annotations_ HRESULT DxcDiagnostic::FormatDiagnostic( DxcDiagnosticDisplayOptions options, LPSTR* pResult) @@ -822,52 +772,44 @@ HRESULT DxcDiagnostic::FormatDiagnostic( return CXStringToAnsiAndDispose(clang_formatDiagnostic(m_diagnostic, options), pResult); } -HRESULT DxcDiagnostic::GetSeverity(_Out_ DxcDiagnosticSeverity* pResult) -{ +HRESULT DxcDiagnostic::GetSeverity(DxcDiagnosticSeverity *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = (DxcDiagnosticSeverity)clang_getDiagnosticSeverity(m_diagnostic); return S_OK; } -_Use_decl_annotations_ HRESULT DxcDiagnostic::GetLocation(IDxcSourceLocation** pResult) { return DxcSourceLocation::Create(clang_getDiagnosticLocation(m_diagnostic), pResult); } -_Use_decl_annotations_ HRESULT DxcDiagnostic::GetSpelling(LPSTR* pResult) { return CXStringToAnsiAndDispose(clang_getDiagnosticSpelling(m_diagnostic), pResult); } -_Use_decl_annotations_ HRESULT DxcDiagnostic::GetCategoryText(LPSTR* pResult) { return CXStringToAnsiAndDispose(clang_getDiagnosticCategoryText(m_diagnostic), pResult); } -HRESULT DxcDiagnostic::GetNumRanges(_Out_ unsigned* pResult) -{ +HRESULT DxcDiagnostic::GetNumRanges(unsigned *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = clang_getDiagnosticNumRanges(m_diagnostic); return S_OK; } -_Use_decl_annotations_ HRESULT DxcDiagnostic::GetRangeAt(unsigned index, IDxcSourceRange** pResult) { return DxcSourceRange::Create(clang_getDiagnosticRange(m_diagnostic, index), pResult); } -HRESULT DxcDiagnostic::GetNumFixIts(_Out_ unsigned* pResult) -{ +HRESULT DxcDiagnostic::GetNumFixIts(unsigned *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = clang_getDiagnosticNumFixIts(m_diagnostic); return S_OK; } -_Use_decl_annotations_ HRESULT DxcDiagnostic::GetFixItAt(unsigned index, IDxcSourceRange** pReplacementRange, LPSTR* pText) { @@ -900,7 +842,6 @@ void DxcFile::Initialize(const CXFile& file) m_file = file; } -_Use_decl_annotations_ HRESULT DxcFile::Create(const CXFile& file, IDxcFile** pObject) { if (pObject == nullptr) return E_POINTER; @@ -913,14 +854,12 @@ HRESULT DxcFile::Create(const CXFile& file, IDxcFile** pObject) return S_OK; } -_Use_decl_annotations_ HRESULT DxcFile::GetName(LPSTR* pResult) { DxcThreadMalloc TM(m_pMalloc); return CXStringToAnsiAndDispose(clang_getFileName(m_file), pResult); } -_Use_decl_annotations_ HRESULT DxcFile::IsEqualTo(IDxcFile* other, BOOL* pResult) { if (!pResult) return E_POINTER; @@ -949,7 +888,6 @@ DxcInclusion::~DxcInclusion() { delete[] m_locations; } -_Use_decl_annotations_ HRESULT DxcInclusion::Initialize(CXFile file, unsigned locations, CXSourceLocation *pLocations) { if (locations) { m_locations = new (std::nothrow)CXSourceLocation[locations]; @@ -962,7 +900,6 @@ HRESULT DxcInclusion::Initialize(CXFile file, unsigned locations, CXSourceLocati return S_OK; } -_Use_decl_annotations_ HRESULT DxcInclusion::Create(CXFile file, unsigned locations, CXSourceLocation *pLocations, IDxcInclusion **pResult) { if (pResult == nullptr) return E_POINTER; *pResult = nullptr; @@ -976,21 +913,19 @@ HRESULT DxcInclusion::Create(CXFile file, unsigned locations, CXSourceLocation * return S_OK; } -_Use_decl_annotations_ -HRESULT DxcInclusion::GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile** pResult) { +HRESULT DxcInclusion::GetIncludedFile(IDxcFile **pResult) { DxcThreadMalloc TM(m_pMalloc); return DxcFile::Create(m_file, pResult); } -_Use_decl_annotations_ -HRESULT DxcInclusion::GetStackLength(_Out_ unsigned *pResult) { +HRESULT DxcInclusion::GetStackLength(unsigned *pResult) { if (pResult == nullptr) return E_POINTER; *pResult = m_locationLength; return S_OK; } -_Use_decl_annotations_ -HRESULT DxcInclusion::GetStackItem(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) { +HRESULT DxcInclusion::GetStackItem(unsigned index, + IDxcSourceLocation **pResult) { if (pResult == nullptr) return E_POINTER; if (index >= m_locationLength) return E_INVALIDARG; DxcThreadMalloc TM(m_pMalloc); @@ -1029,7 +964,6 @@ HRESULT DxcIndex::Initialize(hlsl::DxcLangExtensionsHelper &langHelper) { return S_OK; } -_Use_decl_annotations_ HRESULT DxcIndex::Create(hlsl::DxcLangExtensionsHelper &langHelper, DxcIndex** index) { if (index == nullptr) return E_POINTER; @@ -1050,8 +984,7 @@ HRESULT DxcIndex::SetGlobalOptions(DxcGlobalOptions options) return S_OK; } -HRESULT DxcIndex::GetGlobalOptions(_Out_ DxcGlobalOptions* options) -{ +HRESULT DxcIndex::GetGlobalOptions(DxcGlobalOptions *options) { if (options == nullptr) return E_POINTER; *options = m_options; return S_OK; @@ -1059,7 +992,6 @@ HRESULT DxcIndex::GetGlobalOptions(_Out_ DxcGlobalOptions* options) /////////////////////////////////////////////////////////////////////////////// -_Use_decl_annotations_ HRESULT DxcIndex::ParseTranslationUnit( const char *source_filename, const char * const *command_line_args, @@ -1114,7 +1046,6 @@ HRESULT DxcIndex::ParseTranslationUnit( /////////////////////////////////////////////////////////////////////////////// -_Use_decl_annotations_ HRESULT DxcIntelliSense::CreateIndex(IDxcIndex** index) { DxcThreadMalloc TM(m_pMalloc); @@ -1124,21 +1055,18 @@ HRESULT DxcIntelliSense::CreateIndex(IDxcIndex** index) return hr; } -_Use_decl_annotations_ HRESULT DxcIntelliSense::GetNullLocation(IDxcSourceLocation** location) { DxcThreadMalloc TM(m_pMalloc); return DxcSourceLocation::Create(clang_getNullLocation(), location); } -_Use_decl_annotations_ HRESULT DxcIntelliSense::GetNullRange(IDxcSourceRange** location) { DxcThreadMalloc TM(m_pMalloc); return DxcSourceRange::Create(clang_getNullRange(), location); } -_Use_decl_annotations_ HRESULT DxcIntelliSense::GetRange( IDxcSourceLocation* start, IDxcSourceLocation* end, @@ -1155,22 +1083,20 @@ HRESULT DxcIntelliSense::GetRange( } HRESULT DxcIntelliSense::GetDefaultDiagnosticDisplayOptions( - _Out_ DxcDiagnosticDisplayOptions* pValue) -{ + DxcDiagnosticDisplayOptions *pValue) { if (pValue == nullptr) return E_POINTER; *pValue = (DxcDiagnosticDisplayOptions)clang_defaultDiagnosticDisplayOptions(); return S_OK; } -HRESULT DxcIntelliSense::GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags* pValue) -{ +HRESULT +DxcIntelliSense::GetDefaultEditingTUOptions(DxcTranslationUnitFlags *pValue) { if (pValue == nullptr) return E_POINTER; *pValue = (DxcTranslationUnitFlags) (clang_defaultEditingTranslationUnitOptions() | (unsigned)DxcTranslationUnitFlags_UseCallerThread); return S_OK; } -_Use_decl_annotations_ HRESULT DxcIntelliSense::CreateUnsavedFile(LPCSTR fileName, LPCSTR contents, unsigned contentLength, IDxcUnsavedFile** pResult) { DxcThreadMalloc TM(m_pMalloc); @@ -1184,7 +1110,6 @@ void DxcSourceLocation::Initialize(const CXSourceLocation& location) m_location = location; } -_Use_decl_annotations_ HRESULT DxcSourceLocation::Create( const CXSourceLocation& location, IDxcSourceLocation** pObject) @@ -1199,8 +1124,7 @@ HRESULT DxcSourceLocation::Create( return S_OK; } -HRESULT DxcSourceLocation::IsEqualTo(_In_ IDxcSourceLocation* other, _Out_ BOOL* pResult) -{ +HRESULT DxcSourceLocation::IsEqualTo(IDxcSourceLocation *other, BOOL *pResult) { if (pResult == nullptr) return E_POINTER; if (other == nullptr) { @@ -1215,12 +1139,9 @@ HRESULT DxcSourceLocation::IsEqualTo(_In_ IDxcSourceLocation* other, _Out_ BOOL* return S_OK; } -HRESULT DxcSourceLocation::GetSpellingLocation( - _Outptr_opt_ IDxcFile** pFile, - _Out_opt_ unsigned* pLine, - _Out_opt_ unsigned* pCol, - _Out_opt_ unsigned* pOffset) -{ +HRESULT DxcSourceLocation::GetSpellingLocation(IDxcFile **pFile, + unsigned *pLine, unsigned *pCol, + unsigned *pOffset) { CXFile file; unsigned line, col, offset; DxcThreadMalloc TM(m_pMalloc); @@ -1236,19 +1157,16 @@ HRESULT DxcSourceLocation::GetSpellingLocation( return S_OK; } -HRESULT DxcSourceLocation::IsNull(_Out_ BOOL* pResult) -{ +HRESULT DxcSourceLocation::IsNull(BOOL *pResult) { if (pResult == nullptr) return E_POINTER; CXSourceLocation nullLocation = clang_getNullLocation(); *pResult = 0 !=clang_equalLocations(nullLocation, m_location); return S_OK; } -HRESULT DxcSourceLocation::GetPresumedLocation( - _Outptr_opt_ LPSTR* pFilename, - _Out_opt_ unsigned* pLine, - _Out_opt_ unsigned* pCol) -{ +HRESULT DxcSourceLocation::GetPresumedLocation(LPSTR *pFilename, + unsigned *pLine, + unsigned *pCol) { DxcThreadMalloc TM(m_pMalloc); CXString filename; @@ -1271,7 +1189,6 @@ void DxcSourceRange::Initialize(const CXSourceRange& range) m_range = range; } -_Use_decl_annotations_ HRESULT DxcSourceRange::Create(const CXSourceRange& range, IDxcSourceRange** pObject) { if (pObject == nullptr) return E_POINTER; @@ -1284,7 +1201,6 @@ HRESULT DxcSourceRange::Create(const CXSourceRange& range, IDxcSourceRange** pOb return S_OK; } -_Use_decl_annotations_ HRESULT DxcSourceRange::IsNull(BOOL* pValue) { if (pValue == nullptr) return E_POINTER; @@ -1292,7 +1208,6 @@ HRESULT DxcSourceRange::IsNull(BOOL* pValue) return S_OK; } -_Use_decl_annotations_ HRESULT DxcSourceRange::GetStart(IDxcSourceLocation** pValue) { CXSourceLocation location = clang_getRangeStart(m_range); @@ -1300,7 +1215,6 @@ HRESULT DxcSourceRange::GetStart(IDxcSourceLocation** pValue) return DxcSourceLocation::Create(location, pValue); } -_Use_decl_annotations_ HRESULT DxcSourceRange::GetEnd(IDxcSourceLocation** pValue) { CXSourceLocation location = clang_getRangeEnd(m_range); @@ -1308,8 +1222,7 @@ HRESULT DxcSourceRange::GetEnd(IDxcSourceLocation** pValue) return DxcSourceLocation::Create(location, pValue); } -HRESULT DxcSourceRange::GetOffsets(_Out_ unsigned* startOffset, _Out_ unsigned* endOffset) -{ +HRESULT DxcSourceRange::GetOffsets(unsigned *startOffset, unsigned *endOffset) { if (startOffset == nullptr) return E_POINTER; if (endOffset == nullptr) return E_POINTER; CXSourceLocation startLocation = clang_getRangeStart(m_range); @@ -1331,7 +1244,6 @@ void DxcToken::Initialize(const CXTranslationUnit& tu, const CXToken& token) m_token = token; } -_Use_decl_annotations_ HRESULT DxcToken::Create( const CXTranslationUnit& tu, const CXToken& token, @@ -1347,8 +1259,7 @@ HRESULT DxcToken::Create( return S_OK; } -HRESULT DxcToken::GetKind(_Out_ DxcTokenKind* pValue) -{ +HRESULT DxcToken::GetKind(DxcTokenKind *pValue) { if (pValue == nullptr) return E_POINTER; switch (clang_getTokenKind(m_token)) { @@ -1363,7 +1274,6 @@ HRESULT DxcToken::GetKind(_Out_ DxcTokenKind* pValue) return S_OK; } -_Use_decl_annotations_ HRESULT DxcToken::GetLocation(IDxcSourceLocation** pValue) { if (pValue == nullptr) return E_POINTER; @@ -1371,7 +1281,6 @@ HRESULT DxcToken::GetLocation(IDxcSourceLocation** pValue) return DxcSourceLocation::Create(clang_getTokenLocation(m_tu, m_token), pValue); } -_Use_decl_annotations_ HRESULT DxcToken::GetExtent(IDxcSourceRange** pValue) { if (pValue == nullptr) return E_POINTER; @@ -1379,7 +1288,6 @@ HRESULT DxcToken::GetExtent(IDxcSourceRange** pValue) return DxcSourceRange::Create(clang_getTokenExtent(m_tu, m_token), pValue); } -_Use_decl_annotations_ HRESULT DxcToken::GetSpelling(LPSTR* pValue) { if (pValue == nullptr) return E_POINTER; @@ -1417,7 +1325,6 @@ void DxcTranslationUnit::Initialize(CXTranslationUnit tu) m_tu = tu; } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetCursor(IDxcCursor** pCursor) { DxcThreadMalloc TM(m_pMalloc); @@ -1425,7 +1332,6 @@ HRESULT DxcTranslationUnit::GetCursor(IDxcCursor** pCursor) return DxcCursor::Create(clang_getTranslationUnitCursor(m_tu), pCursor); } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::Tokenize( IDxcSourceRange* range, IDxcToken*** pTokens, @@ -1480,12 +1386,9 @@ HRESULT DxcTranslationUnit::Tokenize( return hr; } -_Use_decl_annotations_ -HRESULT DxcTranslationUnit::GetLocation( - _In_ IDxcFile* file, - unsigned line, unsigned column, - IDxcSourceLocation** pResult) -{ +HRESULT DxcTranslationUnit::GetLocation(IDxcFile *file, unsigned line, + unsigned column, + IDxcSourceLocation **pResult) { if (pResult == nullptr) return E_POINTER; *pResult = nullptr; @@ -1495,15 +1398,13 @@ HRESULT DxcTranslationUnit::GetLocation( return DxcSourceLocation::Create(clang_getLocation(m_tu, fileImpl->GetFile(), line, column), pResult); } -HRESULT DxcTranslationUnit::GetNumDiagnostics(_Out_ unsigned* pValue) -{ +HRESULT DxcTranslationUnit::GetNumDiagnostics(unsigned *pValue) { if (pValue == nullptr) return E_POINTER; DxcThreadMalloc TM(m_pMalloc); *pValue = clang_getNumDiagnostics(m_tu); return S_OK; } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetDiagnostic(unsigned index, IDxcDiagnostic** pValue) { if (pValue == nullptr) return E_POINTER; @@ -1511,7 +1412,6 @@ HRESULT DxcTranslationUnit::GetDiagnostic(unsigned index, IDxcDiagnostic** pValu return DxcDiagnostic::Create(clang_getDiagnostic(m_tu, index), pValue); } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetFile(LPCSTR name, IDxcFile** pResult) { if (name == nullptr) return E_INVALIDARG; @@ -1529,14 +1429,12 @@ HRESULT DxcTranslationUnit::GetFile(LPCSTR name, IDxcFile** pResult) return localFile == nullptr ? DISP_E_BADINDEX : DxcFile::Create(localFile, pResult); } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetFileName(LPSTR* pResult) { DxcThreadMalloc TM(m_pMalloc); return CXStringToAnsiAndDispose(clang_getTranslationUnitSpelling(m_tu), pResult); } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::Reparse( IDxcUnsavedFile** unsaved_files, unsigned num_unsaved_files) @@ -1552,7 +1450,6 @@ HRESULT DxcTranslationUnit::Reparse( return reparseResult == 0 ? S_OK : E_FAIL; } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetCursorForLocation(IDxcSourceLocation* location, IDxcCursor** pResult) { if (location == nullptr) return E_INVALIDARG; @@ -1562,7 +1459,6 @@ HRESULT DxcTranslationUnit::GetCursorForLocation(IDxcSourceLocation* location, I return DxcCursor::Create(clang_getCursor(m_tu, locationImpl->GetLocation()), pResult); } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetLocationForOffset(IDxcFile* file, unsigned offset, IDxcSourceLocation** pResult) { if (file == nullptr) return E_INVALIDARG; @@ -1572,7 +1468,6 @@ HRESULT DxcTranslationUnit::GetLocationForOffset(IDxcFile* file, unsigned offset return DxcSourceLocation::Create(clang_getLocationForOffset(m_tu, fileImpl->GetFile(), offset), pResult); } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetSkippedRanges(IDxcFile* file, unsigned* pResultCount, IDxcSourceRange*** pResult) { if (file == nullptr) return E_INVALIDARG; @@ -1624,16 +1519,9 @@ HRESULT DxcTranslationUnit::GetSkippedRanges(IDxcFile* file, unsigned* pResultCo } HRESULT DxcTranslationUnit::GetDiagnosticDetails( - unsigned index, - DxcDiagnosticDisplayOptions options, - _Out_ unsigned* errorCode, - _Out_ unsigned* errorLine, - _Out_ unsigned* errorColumn, - _Out_ BSTR* errorFile, - _Out_ unsigned* errorOffset, - _Out_ unsigned* errorLength, - _Out_ BSTR* errorMessage) -{ + unsigned index, DxcDiagnosticDisplayOptions options, unsigned *errorCode, + unsigned *errorLine, unsigned *errorColumn, BSTR *errorFile, + unsigned *errorOffset, unsigned *errorLength, BSTR *errorMessage) { if (errorCode == nullptr || errorLine == nullptr || errorColumn == nullptr || errorFile == nullptr || errorOffset == nullptr || errorLength == nullptr || @@ -1691,7 +1579,6 @@ void VisitInclusion(CXFile included_file, } } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::GetInclusionList(unsigned *pResultCount, IDxcInclusion ***pResult) { if (pResultCount == nullptr || pResult == nullptr) { @@ -1721,7 +1608,6 @@ HRESULT DxcTranslationUnit::GetInclusionList(unsigned *pResultCount, return S_OK; } -_Use_decl_annotations_ HRESULT DxcTranslationUnit::CodeCompleteAt( const char *fileName, unsigned line, unsigned column, IDxcUnsavedFile **pUnsavedFiles, unsigned numUnsavedFiles, @@ -1758,7 +1644,6 @@ HRESULT DxcTranslationUnit::CodeCompleteAt( /////////////////////////////////////////////////////////////////////////////// -_Use_decl_annotations_ HRESULT DxcType::Create(const CXType& type, IDxcType** pObject) { if (pObject == nullptr) return E_POINTER; @@ -1776,14 +1661,12 @@ void DxcType::Initialize(const CXType& type) m_type = type; } -_Use_decl_annotations_ HRESULT DxcType::GetSpelling(LPSTR* pResult) { DxcThreadMalloc TM(m_pMalloc); return CXStringToAnsiAndDispose(clang_getTypeSpelling(m_type), pResult); } -_Use_decl_annotations_ HRESULT DxcType::IsEqualTo(IDxcType* other, BOOL* pResult) { if (pResult == nullptr) return E_POINTER; @@ -1797,7 +1680,6 @@ HRESULT DxcType::IsEqualTo(IDxcType* other, BOOL* pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcType::GetKind(DxcTypeKind* pResult) { if (pResult == nullptr) return E_POINTER; @@ -1817,7 +1699,6 @@ void DxcCodeCompleteResults::Initialize(CXCodeCompleteResults* ccr) m_ccr = ccr; } -_Use_decl_annotations_ HRESULT DxcCodeCompleteResults::GetNumResults(unsigned *pResult) { if (pResult == nullptr) @@ -1829,7 +1710,6 @@ HRESULT DxcCodeCompleteResults::GetNumResults(unsigned *pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcCodeCompleteResults::GetResultAt( unsigned index, IDxcCompletionResult **pResult) @@ -1859,7 +1739,6 @@ void DxcCompletionResult::Initialize(const CXCompletionResult &cr) m_cr = cr; } -_Use_decl_annotations_ HRESULT DxcCompletionResult::GetCursorKind(DxcCursorKind *pResult) { if (pResult == nullptr) return E_POINTER; @@ -1867,7 +1746,6 @@ HRESULT DxcCompletionResult::GetCursorKind(DxcCursorKind *pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcCompletionResult::GetCompletionString(IDxcCompletionString **pResult) { if (pResult == nullptr) return E_POINTER; @@ -1892,7 +1770,6 @@ void DxcCompletionString::Initialize(const CXCompletionString &cs) m_cs = cs; } -_Use_decl_annotations_ HRESULT DxcCompletionString::GetNumCompletionChunks(unsigned *pResult) { if (pResult == nullptr) return E_POINTER; @@ -1900,7 +1777,6 @@ HRESULT DxcCompletionString::GetNumCompletionChunks(unsigned *pResult) return S_OK; } -_Use_decl_annotations_ HRESULT DxcCompletionString::GetCompletionChunkKind(unsigned chunkNumber, DxcCompletionChunkKind *pResult) { if (pResult == nullptr) return E_POINTER; @@ -1908,7 +1784,6 @@ HRESULT DxcCompletionString::GetCompletionChunkKind(unsigned chunkNumber, DxcCom return S_OK; } -_Use_decl_annotations_ HRESULT DxcCompletionString::GetCompletionChunkText(unsigned chunkNumber, LPSTR* pResult) { if (pResult == nullptr) return E_POINTER; diff --git a/tools/clang/tools/libclang/dxcisenseimpl.h b/tools/clang/tools/libclang/dxcisenseimpl.h index 493ea30b91..a9d0406835 100644 --- a/tools/clang/tools/libclang/dxcisenseimpl.h +++ b/tools/clang/tools/libclang/dxcisenseimpl.h @@ -47,38 +47,43 @@ class DxcCursor : public IDxcCursor } void Initialize(const CXCursor& cursor); - static HRESULT Create(const CXCursor& cursor, _Outptr_result_nullonfailure_ IDxcCursor** pObject); - - HRESULT STDMETHODCALLTYPE GetExtent(_Outptr_result_nullonfailure_ IDxcSourceRange** pRange) override; - HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) override; - HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcCursorKind* pResult) override; - HRESULT STDMETHODCALLTYPE GetKindFlags(_Out_ DxcCursorKindFlags* pResult) override; - HRESULT STDMETHODCALLTYPE GetSemanticParent(_Outptr_result_nullonfailure_ IDxcCursor** pResult) override; - HRESULT STDMETHODCALLTYPE GetLexicalParent(_Outptr_result_nullonfailure_ IDxcCursor** pResult) override; - HRESULT STDMETHODCALLTYPE GetCursorType(_Outptr_result_nullonfailure_ IDxcType** pResult) override; - HRESULT STDMETHODCALLTYPE GetNumArguments(_Out_ int* pResult) override; - HRESULT STDMETHODCALLTYPE GetArgumentAt(int index, _Outptr_result_nullonfailure_ IDxcCursor** pResult) override; - HRESULT STDMETHODCALLTYPE GetReferencedCursor(_Outptr_result_nullonfailure_ IDxcCursor** pResult) override; - HRESULT STDMETHODCALLTYPE GetDefinitionCursor(_Outptr_result_nullonfailure_ IDxcCursor** pResult) override; - HRESULT STDMETHODCALLTYPE FindReferencesInFile( - _In_ IDxcFile* file, unsigned skip, unsigned top, - _Out_ unsigned* pResultLength, _Outptr_result_buffer_maybenull_(*pResultLength) IDxcCursor*** pResult) override; - HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcCursor* other, _Out_ BOOL* pResult) override; - HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pResult) override; - HRESULT STDMETHODCALLTYPE IsDefinition(_Out_ BOOL* pResult) override; + static HRESULT Create(const CXCursor &cursor, IDxcCursor **pObject); + + HRESULT STDMETHODCALLTYPE GetExtent(IDxcSourceRange **pRange) override; + HRESULT STDMETHODCALLTYPE GetLocation(IDxcSourceLocation **pResult) override; + HRESULT STDMETHODCALLTYPE GetKind(DxcCursorKind *pResult) override; + HRESULT STDMETHODCALLTYPE GetKindFlags(DxcCursorKindFlags *pResult) override; + HRESULT STDMETHODCALLTYPE GetSemanticParent(IDxcCursor **pResult) override; + HRESULT STDMETHODCALLTYPE GetLexicalParent(IDxcCursor **pResult) override; + HRESULT STDMETHODCALLTYPE GetCursorType(IDxcType **pResult) override; + HRESULT STDMETHODCALLTYPE GetNumArguments(int *pResult) override; + HRESULT STDMETHODCALLTYPE GetArgumentAt(int index, + IDxcCursor **pResult) override; + HRESULT STDMETHODCALLTYPE GetReferencedCursor(IDxcCursor **pResult) override; + HRESULT STDMETHODCALLTYPE GetDefinitionCursor(IDxcCursor **pResult) override; + HRESULT STDMETHODCALLTYPE + FindReferencesInFile(IDxcFile *file, unsigned skip, unsigned top, + unsigned *pResultLength, IDxcCursor ***pResult) override; + HRESULT STDMETHODCALLTYPE GetSpelling(LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE IsEqualTo(IDxcCursor *other, + BOOL *pResult) override; + HRESULT STDMETHODCALLTYPE IsNull(BOOL *pResult) override; + HRESULT STDMETHODCALLTYPE IsDefinition(BOOL *pResult) override; /// Gets the display name for the cursor, including e.g. parameter types for a function. - HRESULT STDMETHODCALLTYPE GetDisplayName(_Outptr_result_maybenull_ BSTR* pResult) override; + HRESULT STDMETHODCALLTYPE GetDisplayName(BSTR *pResult) override; /// Gets the qualified name for the symbol the cursor refers to. - HRESULT STDMETHODCALLTYPE GetQualifiedName(BOOL includeTemplateArgs, _Outptr_result_maybenull_ BSTR* pResult) override; + HRESULT STDMETHODCALLTYPE GetQualifiedName(BOOL includeTemplateArgs, + BSTR *pResult) override; /// Gets a name for the cursor, applying the specified formatting flags. - HRESULT STDMETHODCALLTYPE GetFormattedName(DxcCursorFormatting formatting, _Outptr_result_maybenull_ BSTR* pResult) override; + HRESULT STDMETHODCALLTYPE GetFormattedName(DxcCursorFormatting formatting, + BSTR *pResult) override; /// Gets children in pResult up to top elements. - HRESULT STDMETHODCALLTYPE GetChildren( - unsigned skip, unsigned top, - _Out_ unsigned* pResultLength, _Outptr_result_buffer_maybenull_(*pResultLength) IDxcCursor*** pResult) override; + HRESULT STDMETHODCALLTYPE GetChildren(unsigned skip, unsigned top, + unsigned *pResultLength, + IDxcCursor ***pResult) override; /// Gets the cursor following a location within a compound cursor. - HRESULT STDMETHODCALLTYPE GetSnappedChild(_In_ IDxcSourceLocation* location, _Outptr_result_maybenull_ IDxcCursor** pResult) override; + HRESULT STDMETHODCALLTYPE GetSnappedChild(IDxcSourceLocation *location, + IDxcCursor **pResult) override; }; class DxcDiagnostic : public IDxcDiagnostic @@ -97,20 +102,23 @@ class DxcDiagnostic : public IDxcDiagnostic DxcDiagnostic(IMalloc *pMalloc); ~DxcDiagnostic(); void Initialize(const CXDiagnostic& diagnostic); - static HRESULT Create(const CXDiagnostic& diagnostic, _Outptr_result_nullonfailure_ IDxcDiagnostic** pObject); + static HRESULT Create(const CXDiagnostic &diagnostic, + IDxcDiagnostic **pObject); HRESULT STDMETHODCALLTYPE FormatDiagnostic( - DxcDiagnosticDisplayOptions options, - _Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE GetSeverity(_Out_ DxcDiagnosticSeverity* pResult) override; - HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) override; - HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE GetCategoryText(_Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE GetNumRanges(_Out_ unsigned* pResult) override; - HRESULT STDMETHODCALLTYPE GetRangeAt(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceRange** pResult) override; - HRESULT STDMETHODCALLTYPE GetNumFixIts(_Out_ unsigned* pResult) override; + DxcDiagnosticDisplayOptions options, LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE + GetSeverity(DxcDiagnosticSeverity *pResult) override; + HRESULT STDMETHODCALLTYPE GetLocation(IDxcSourceLocation **pResult) override; + HRESULT STDMETHODCALLTYPE GetSpelling(LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE GetCategoryText(LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE GetNumRanges(unsigned *pResult) override; + HRESULT STDMETHODCALLTYPE GetRangeAt(unsigned index, + IDxcSourceRange **pResult) override; + HRESULT STDMETHODCALLTYPE GetNumFixIts(unsigned *pResult) override; HRESULT STDMETHODCALLTYPE GetFixItAt(unsigned index, - _Outptr_result_nullonfailure_ IDxcSourceRange** pReplacementRange, _Outptr_result_maybenull_ LPSTR* pText) override; + IDxcSourceRange **pReplacementRange, + LPSTR *pText) override; }; class DxcFile : public IDxcFile @@ -127,11 +135,11 @@ class DxcFile : public IDxcFile } void Initialize(const CXFile& file); - static HRESULT Create(const CXFile& file, _Outptr_result_nullonfailure_ IDxcFile** pObject); + static HRESULT Create(const CXFile &file, IDxcFile **pObject); const CXFile& GetFile() const { return m_file; } - HRESULT STDMETHODCALLTYPE GetName(_Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcFile* other, _Out_ BOOL* pResult) override; + HRESULT STDMETHODCALLTYPE GetName(LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE IsEqualTo(IDxcFile *other, BOOL *pResult) override; }; class DxcInclusion : public IDxcInclusion @@ -139,7 +147,6 @@ class DxcInclusion : public IDxcInclusion private: DXC_MICROCOM_TM_REF_FIELDS() CXFile m_file; - _Field_size_(m_locationLength) CXSourceLocation *m_locations; unsigned m_locationLength; public: @@ -152,12 +159,15 @@ class DxcInclusion : public IDxcInclusion DxcInclusion(IMalloc *pMalloc); ~DxcInclusion(); - HRESULT Initialize(CXFile file, unsigned locations, _In_count_(locations) CXSourceLocation *pLocation); - static HRESULT Create(CXFile file, unsigned locations, _In_count_(locations) CXSourceLocation *pLocation, _COM_Outptr_ IDxcInclusion **pResult); - - HRESULT STDMETHODCALLTYPE GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile** pResult) override; - HRESULT STDMETHODCALLTYPE GetStackLength(_Out_ unsigned *pResult) override; - HRESULT STDMETHODCALLTYPE GetStackItem(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) override; + HRESULT Initialize(CXFile file, unsigned locations, + CXSourceLocation *pLocation); + static HRESULT Create(CXFile file, unsigned locations, + CXSourceLocation *pLocation, IDxcInclusion **pResult); + + HRESULT STDMETHODCALLTYPE GetIncludedFile(IDxcFile **pResult) override; + HRESULT STDMETHODCALLTYPE GetStackLength(unsigned *pResult) override; + HRESULT STDMETHODCALLTYPE GetStackItem(unsigned index, + IDxcSourceLocation **pResult) override; }; class DxcIndex : public IDxcIndex @@ -178,18 +188,17 @@ class DxcIndex : public IDxcIndex DxcIndex(IMalloc *pMalloc); ~DxcIndex(); HRESULT Initialize(hlsl::DxcLangExtensionsHelper& langHelper); - static HRESULT Create(hlsl::DxcLangExtensionsHelper& langHelper, _Outptr_result_nullonfailure_ DxcIndex** index); + static HRESULT Create(hlsl::DxcLangExtensionsHelper &langHelper, + DxcIndex **index); HRESULT STDMETHODCALLTYPE SetGlobalOptions(DxcGlobalOptions options) override; - HRESULT STDMETHODCALLTYPE GetGlobalOptions(_Out_ DxcGlobalOptions* options) override; + HRESULT STDMETHODCALLTYPE + GetGlobalOptions(DxcGlobalOptions *options) override; HRESULT STDMETHODCALLTYPE ParseTranslationUnit( - _In_z_ const char *source_filename, - _In_count_(num_command_line_args) const char * const *command_line_args, - int num_command_line_args, - _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files, - unsigned num_unsaved_files, - DxcTranslationUnitFlags options, - _Outptr_result_nullonfailure_ IDxcTranslationUnit** pTranslationUnit) override; + const char *source_filename, const char *const *command_line_args, + int num_command_line_args, IDxcUnsavedFile **unsaved_files, + unsigned num_unsaved_files, DxcTranslationUnitFlags options, + IDxcTranslationUnit **pTranslationUnit) override; }; class DxcIntelliSense : public IDxcIntelliSense, public IDxcLangExtensions3 { @@ -208,19 +217,20 @@ class DxcIntelliSense : public IDxcIntelliSense, public IDxcLangExtensions3 { this, iid, ppvObject); } - HRESULT STDMETHODCALLTYPE CreateIndex(_Outptr_result_nullonfailure_ IDxcIndex** index) override; - HRESULT STDMETHODCALLTYPE GetNullLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** location) override; - HRESULT STDMETHODCALLTYPE GetNullRange(_Outptr_result_nullonfailure_ IDxcSourceRange** location) override; - HRESULT STDMETHODCALLTYPE GetRange( - _In_ IDxcSourceLocation* start, - _In_ IDxcSourceLocation* end, - _Outptr_result_nullonfailure_ IDxcSourceRange** location) override; + HRESULT STDMETHODCALLTYPE CreateIndex(IDxcIndex **index) override; + HRESULT STDMETHODCALLTYPE + GetNullLocation(IDxcSourceLocation **location) override; + HRESULT STDMETHODCALLTYPE GetNullRange(IDxcSourceRange **location) override; + HRESULT STDMETHODCALLTYPE GetRange(IDxcSourceLocation *start, + IDxcSourceLocation *end, + IDxcSourceRange **location) override; HRESULT STDMETHODCALLTYPE GetDefaultDiagnosticDisplayOptions( - _Out_ DxcDiagnosticDisplayOptions* pValue) override; - HRESULT STDMETHODCALLTYPE GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags* pValue) override; - HRESULT STDMETHODCALLTYPE CreateUnsavedFile( - _In_ LPCSTR fileName, _In_ LPCSTR contents, unsigned contentLength, - _Outptr_result_nullonfailure_ IDxcUnsavedFile** pResult) override; + DxcDiagnosticDisplayOptions *pValue) override; + HRESULT STDMETHODCALLTYPE + GetDefaultEditingTUOptions(DxcTranslationUnitFlags *pValue) override; + HRESULT STDMETHODCALLTYPE + CreateUnsavedFile(LPCSTR fileName, LPCSTR contents, unsigned contentLength, + IDxcUnsavedFile **pResult) override; }; class DxcSourceLocation : public IDxcSourceLocation @@ -237,20 +247,19 @@ class DxcSourceLocation : public IDxcSourceLocation } void Initialize(const CXSourceLocation& location); - static HRESULT Create(const CXSourceLocation& location, _Outptr_result_nullonfailure_ IDxcSourceLocation** pObject); + static HRESULT Create(const CXSourceLocation &location, + IDxcSourceLocation **pObject); const CXSourceLocation& GetLocation() const { return m_location; } - HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcSourceLocation* other, _Out_ BOOL* pValue) override; - HRESULT STDMETHODCALLTYPE GetSpellingLocation( - _Outptr_opt_ IDxcFile** pFile, - _Out_opt_ unsigned* pLine, - _Out_opt_ unsigned* pCol, - _Out_opt_ unsigned* pOffset) override; - HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pResult) override; - HRESULT STDMETHODCALLTYPE GetPresumedLocation( - _Outptr_opt_ LPSTR* pFilename, - _Out_opt_ unsigned* pLine, - _Out_opt_ unsigned* pCol) override; + HRESULT STDMETHODCALLTYPE IsEqualTo(IDxcSourceLocation *other, + BOOL *pValue) override; + HRESULT STDMETHODCALLTYPE GetSpellingLocation(IDxcFile **pFile, + unsigned *pLine, unsigned *pCol, + unsigned *pOffset) override; + HRESULT STDMETHODCALLTYPE IsNull(BOOL *pResult) override; + HRESULT STDMETHODCALLTYPE GetPresumedLocation(LPSTR *pFilename, + unsigned *pLine, + unsigned *pCol) override; }; class DxcSourceRange : public IDxcSourceRange @@ -267,13 +276,14 @@ class DxcSourceRange : public IDxcSourceRange } void Initialize(const CXSourceRange& range); - static HRESULT Create(const CXSourceRange& range, _Outptr_result_nullonfailure_ IDxcSourceRange** pObject); + static HRESULT Create(const CXSourceRange &range, IDxcSourceRange **pObject); const CXSourceRange& GetRange() const { return m_range; } - HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pValue) override; - HRESULT STDMETHODCALLTYPE GetStart(_Outptr_result_nullonfailure_ IDxcSourceLocation** pValue) override; - HRESULT STDMETHODCALLTYPE GetEnd(_Outptr_result_nullonfailure_ IDxcSourceLocation** pValue) override; - HRESULT STDMETHODCALLTYPE GetOffsets(_Out_ unsigned* startOffset, _Out_ unsigned* endOffset) override; + HRESULT STDMETHODCALLTYPE IsNull(BOOL *pValue) override; + HRESULT STDMETHODCALLTYPE GetStart(IDxcSourceLocation **pValue) override; + HRESULT STDMETHODCALLTYPE GetEnd(IDxcSourceLocation **pValue) override; + HRESULT STDMETHODCALLTYPE GetOffsets(unsigned *startOffset, + unsigned *endOffset) override; }; class DxcToken : public IDxcToken @@ -291,12 +301,13 @@ class DxcToken : public IDxcToken } void Initialize(const CXTranslationUnit& tu, const CXToken& token); - static HRESULT Create(const CXTranslationUnit& tu, const CXToken& token, _Outptr_result_nullonfailure_ IDxcToken** pObject); + static HRESULT Create(const CXTranslationUnit &tu, const CXToken &token, + IDxcToken **pObject); - HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTokenKind* pValue) override; - HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pValue) override; - HRESULT STDMETHODCALLTYPE GetExtent(_Outptr_result_nullonfailure_ IDxcSourceRange** pValue) override; - HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pValue) override; + HRESULT STDMETHODCALLTYPE GetKind(DxcTokenKind *pValue) override; + HRESULT STDMETHODCALLTYPE GetLocation(IDxcSourceLocation **pValue) override; + HRESULT STDMETHODCALLTYPE GetExtent(IDxcSourceRange **pValue) override; + HRESULT STDMETHODCALLTYPE GetSpelling(LPSTR *pValue) override; }; class DxcTranslationUnit : public IDxcTranslationUnit @@ -316,40 +327,40 @@ class DxcTranslationUnit : public IDxcTranslationUnit ~DxcTranslationUnit(); void Initialize(CXTranslationUnit tu); - HRESULT STDMETHODCALLTYPE GetCursor(_Outptr_ IDxcCursor** pCursor) override; - HRESULT STDMETHODCALLTYPE Tokenize( - _In_ IDxcSourceRange* range, - _Outptr_result_buffer_maybenull_(*pTokenCount) IDxcToken*** pTokens, - _Out_ unsigned* pTokenCount) override; - HRESULT STDMETHODCALLTYPE GetLocation( - _In_ IDxcFile* file, - unsigned line, unsigned column, - _Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) override; - HRESULT STDMETHODCALLTYPE GetNumDiagnostics(_Out_ unsigned* pValue) override; - HRESULT STDMETHODCALLTYPE GetDiagnostic(unsigned index, _Outptr_result_nullonfailure_ IDxcDiagnostic** pValue) override; - HRESULT STDMETHODCALLTYPE GetFile(_In_ const char* name, _Outptr_result_nullonfailure_ IDxcFile** pResult) override; - HRESULT STDMETHODCALLTYPE GetFileName(_Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE Reparse( - _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files, - unsigned num_unsaved_files) override; - HRESULT STDMETHODCALLTYPE GetCursorForLocation(_In_ IDxcSourceLocation* location, _Outptr_result_nullonfailure_ IDxcCursor** pResult) override; - HRESULT STDMETHODCALLTYPE GetLocationForOffset(_In_ IDxcFile* file, unsigned offset, _Outptr_ IDxcSourceLocation** pResult) override; - HRESULT STDMETHODCALLTYPE GetSkippedRanges(_In_ IDxcFile* file, _Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcSourceRange*** pResult) override; - HRESULT STDMETHODCALLTYPE GetDiagnosticDetails(unsigned index, DxcDiagnosticDisplayOptions options, - _Out_ unsigned* errorCode, - _Out_ unsigned* errorLine, - _Out_ unsigned* errorColumn, - _Out_ BSTR* errorFile, - _Out_ unsigned* errorOffset, - _Out_ unsigned* errorLength, - _Out_ BSTR* errorMessage) override; - HRESULT STDMETHODCALLTYPE GetInclusionList(_Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcInclusion*** pResult) override; - HRESULT STDMETHODCALLTYPE CodeCompleteAt( - _In_ const char *fileName, unsigned line, unsigned column, - _In_ IDxcUnsavedFile** pUnsavedFiles, unsigned numUnsavedFiles, - _In_ DxcCodeCompleteFlags options, - _Outptr_result_nullonfailure_ IDxcCodeCompleteResults **pResult) - override; + HRESULT STDMETHODCALLTYPE GetCursor(IDxcCursor **pCursor) override; + HRESULT STDMETHODCALLTYPE Tokenize(IDxcSourceRange *range, + IDxcToken ***pTokens, + unsigned *pTokenCount) override; + HRESULT STDMETHODCALLTYPE + GetLocation(IDxcFile *file, unsigned line, unsigned column, + IDxcSourceLocation **pResult) override; + HRESULT STDMETHODCALLTYPE GetNumDiagnostics(unsigned *pValue) override; + HRESULT STDMETHODCALLTYPE GetDiagnostic(unsigned index, + IDxcDiagnostic **pValue) override; + HRESULT STDMETHODCALLTYPE GetFile(const char *name, + IDxcFile **pResult) override; + HRESULT STDMETHODCALLTYPE GetFileName(LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE Reparse(IDxcUnsavedFile **unsaved_files, + unsigned num_unsaved_files) override; + HRESULT STDMETHODCALLTYPE GetCursorForLocation( + IDxcSourceLocation *location, IDxcCursor **pResult) override; + HRESULT STDMETHODCALLTYPE GetLocationForOffset( + IDxcFile *file, unsigned offset, IDxcSourceLocation **pResult) override; + HRESULT STDMETHODCALLTYPE + GetSkippedRanges(IDxcFile *file, unsigned *pResultCount, + IDxcSourceRange ***pResult) override; + HRESULT STDMETHODCALLTYPE GetDiagnosticDetails( + unsigned index, DxcDiagnosticDisplayOptions options, + unsigned *errorCode, unsigned *errorLine, unsigned *errorColumn, + BSTR *errorFile, unsigned *errorOffset, unsigned *errorLength, + BSTR *errorMessage) override; + HRESULT STDMETHODCALLTYPE + GetInclusionList(unsigned *pResultCount, IDxcInclusion ***pResult) override; + HRESULT STDMETHODCALLTYPE + CodeCompleteAt(const char *fileName, unsigned line, unsigned column, + IDxcUnsavedFile **pUnsavedFiles, unsigned numUnsavedFiles, + DxcCodeCompleteFlags options, + IDxcCodeCompleteResults **pResult) override; }; class DxcType : public IDxcType @@ -366,11 +377,11 @@ class DxcType : public IDxcType } void Initialize(const CXType& type); - static HRESULT Create(const CXType& type, _Outptr_result_nullonfailure_ IDxcType** pObject); + static HRESULT Create(const CXType &type, IDxcType **pObject); - HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) override; - HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcType* other, _Out_ BOOL* pResult) override; - HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTypeKind* pResult) override; + HRESULT STDMETHODCALLTYPE GetSpelling(LPSTR *pResult) override; + HRESULT STDMETHODCALLTYPE IsEqualTo(IDxcType *other, BOOL *pResult) override; + HRESULT STDMETHODCALLTYPE GetKind(DxcTypeKind *pResult) override; }; class DxcCodeCompleteResults : public IDxcCodeCompleteResults @@ -389,8 +400,9 @@ class DxcCodeCompleteResults : public IDxcCodeCompleteResults ~DxcCodeCompleteResults(); void Initialize(CXCodeCompleteResults* ccr); - HRESULT STDMETHODCALLTYPE GetNumResults(_Out_ unsigned *pResult) override; - HRESULT STDMETHODCALLTYPE GetResultAt(unsigned index, _Outptr_result_nullonfailure_ IDxcCompletionResult **pResult) override; + HRESULT STDMETHODCALLTYPE GetNumResults(unsigned *pResult) override; + HRESULT STDMETHODCALLTYPE + GetResultAt(unsigned index, IDxcCompletionResult **pResult) override; }; class DxcCompletionResult : public IDxcCompletionResult @@ -408,8 +420,9 @@ class DxcCompletionResult : public IDxcCompletionResult void Initialize(const CXCompletionResult& cr); - HRESULT STDMETHODCALLTYPE GetCursorKind(_Out_ DxcCursorKind *pResult) override; - HRESULT STDMETHODCALLTYPE GetCompletionString(_Outptr_result_nullonfailure_ IDxcCompletionString **pResult) override; + HRESULT STDMETHODCALLTYPE GetCursorKind(DxcCursorKind *pResult) override; + HRESULT STDMETHODCALLTYPE + GetCompletionString(IDxcCompletionString **pResult) override; }; class DxcCompletionString : public IDxcCompletionString @@ -427,11 +440,13 @@ class DxcCompletionString : public IDxcCompletionString void Initialize(const CXCompletionString& cs); - HRESULT STDMETHODCALLTYPE GetNumCompletionChunks(_Out_ unsigned *pResult) override; - HRESULT STDMETHODCALLTYPE GetCompletionChunkKind(unsigned chunkNumber, _Out_ DxcCompletionChunkKind *pResult) override; - HRESULT STDMETHODCALLTYPE GetCompletionChunkText(unsigned chunkNumber, _Out_ LPSTR* pResult) override; + HRESULT STDMETHODCALLTYPE GetNumCompletionChunks(unsigned *pResult) override; + HRESULT STDMETHODCALLTYPE GetCompletionChunkKind( + unsigned chunkNumber, DxcCompletionChunkKind *pResult) override; + HRESULT STDMETHODCALLTYPE GetCompletionChunkText(unsigned chunkNumber, + LPSTR *pResult) override; }; -HRESULT CreateDxcIntelliSense(_In_ REFIID riid, _Out_ LPVOID* ppv) throw(); +HRESULT CreateDxcIntelliSense(REFIID riid, LPVOID *ppv) throw(); #endif diff --git a/tools/clang/tools/libclang/dxcrewriteunused.cpp b/tools/clang/tools/libclang/dxcrewriteunused.cpp index 493929d414..902612fbb8 100644 --- a/tools/clang/tools/libclang/dxcrewriteunused.cpp +++ b/tools/clang/tools/libclang/dxcrewriteunused.cpp @@ -411,8 +411,9 @@ void WriteMacroDefines(ParsedSemanticDefineList ¯os, } // namespace -ParsedSemanticDefineList hlsl::CollectSemanticDefinesParsedByCompiler( - CompilerInstance &compiler, _In_ DxcLangExtensionsHelper *helper) { +ParsedSemanticDefineList +hlsl::CollectSemanticDefinesParsedByCompiler(CompilerInstance &compiler, + DxcLangExtensionsHelper *helper) { ParsedSemanticDefineList parsedDefines; const llvm::SmallVector &defines = helper->GetSemanticDefines(); @@ -516,15 +517,13 @@ ParsedSemanticDefineList hlsl::CollectSemanticDefinesParsedByCompiler( return parsedDefines; } - namespace { void SetupCompilerCommon(CompilerInstance &compiler, - _In_ DxcLangExtensionsHelper *helper, - _In_ LPCSTR pMainFile, - _In_ TextDiagnosticPrinter *diagPrinter, - _In_opt_ ASTUnit::RemappedFile *rewrite, - _In_ hlsl::options::DxcOpts &opts) { + DxcLangExtensionsHelper *helper, LPCSTR pMainFile, + TextDiagnosticPrinter *diagPrinter, + ASTUnit::RemappedFile *rewrite, + hlsl::options::DxcOpts &opts) { // Setup a compiler instance. std::shared_ptr targetOptions(new TargetOptions); targetOptions->Triple = llvm::sys::getDefaultTargetTriple(); @@ -576,14 +575,14 @@ void SetupCompilerCommon(CompilerInstance &compiler, HSOpts.AddPath(s, frontend::Angled, IsFrameworkFalse, IgnoreSysRoot); } } - } -void SetupCompilerForRewrite( - CompilerInstance &compiler, _In_ DxcLangExtensionsHelper *helper, - _In_ LPCSTR pMainFile, _In_ TextDiagnosticPrinter *diagPrinter, - _In_opt_ ASTUnit::RemappedFile *rewrite, _In_ hlsl::options::DxcOpts &opts, - _In_opt_ LPCSTR pDefines, _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr) { +void SetupCompilerForRewrite(CompilerInstance &compiler, + DxcLangExtensionsHelper *helper, LPCSTR pMainFile, + TextDiagnosticPrinter *diagPrinter, + ASTUnit::RemappedFile *rewrite, + hlsl::options::DxcOpts &opts, LPCSTR pDefines, + dxcutil::DxcArgsFileSystem *msfPtr) { SetupCompilerCommon(compiler, helper, pMainFile, diagPrinter, rewrite, opts); @@ -613,13 +612,14 @@ void SetupCompilerForRewrite( SrcMgr::C_User)); } - -void SetupCompilerForPreprocess( - CompilerInstance &compiler, _In_ DxcLangExtensionsHelper *helper, - _In_ LPCSTR pMainFile, _In_ TextDiagnosticPrinter *diagPrinter, - _In_opt_ ASTUnit::RemappedFile *rewrite, _In_ hlsl::options::DxcOpts &opts, - _In_ DxcDefine *pDefines, _In_ UINT32 defineCount, - _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr) { +void SetupCompilerForPreprocess(CompilerInstance &compiler, + DxcLangExtensionsHelper *helper, + LPCSTR pMainFile, + TextDiagnosticPrinter *diagPrinter, + ASTUnit::RemappedFile *rewrite, + hlsl::options::DxcOpts &opts, + DxcDefine *pDefines, UINT32 defineCount, + dxcutil::DxcArgsFileSystem *msfPtr) { SetupCompilerCommon(compiler, helper, pMainFile, diagPrinter, rewrite, opts); @@ -636,9 +636,7 @@ void SetupCompilerForPreprocess( } } - -std::string DefinesToString(_In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount) { +std::string DefinesToString(DxcDefine *pDefines, UINT32 defineCount) { std::string defineStr; for (UINT32 i = 0; i < defineCount; i++) { CW2A utf8Name(pDefines[i].Name, CP_UTF8); @@ -826,10 +824,9 @@ HRESULT CollectRewriteHelper(TranslationUnitDecl *tu, LPCSTR pEntryPoint, } // namespace -static -HRESULT ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, - hlsl::options::DxcOpts &opts, - _COM_Outptr_ IDxcOperationResult **ppResult) { +static HRESULT ReadOptsAndValidate(hlsl::options::MainArgs &mainArgs, + hlsl::options::DxcOpts &opts, + IDxcOperationResult **ppResult) { const llvm::opt::OptTable *table = ::options::getHlslOptTable(); CComPtr pOutputStream; @@ -964,13 +961,13 @@ static HRESULT DoRewriteUnused( TranslationUnitDecl *tu, return S_OK; } -static HRESULT -DoRewriteUnused(_In_ DxcLangExtensionsHelper *pHelper, _In_ LPCSTR pFileName, - _In_ ASTUnit::RemappedFile *pRemap, _In_ LPCSTR pEntryPoint, - _In_ DxcDefine *pDefines, _In_ UINT32 defineCount, - bool bRemoveGlobals, bool bRemoveFunctions, - std::string &warnings, std::string &result, - _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr) { +static HRESULT DoRewriteUnused(DxcLangExtensionsHelper *pHelper, + LPCSTR pFileName, ASTUnit::RemappedFile *pRemap, + LPCSTR pEntryPoint, DxcDefine *pDefines, + UINT32 defineCount, bool bRemoveGlobals, + bool bRemoveFunctions, std::string &warnings, + std::string &result, + dxcutil::DxcArgsFileSystem *msfPtr) { raw_string_ostream o(result); raw_string_ostream w(warnings); @@ -1050,16 +1047,12 @@ static void GlobalVariableAsExternByDefault(DeclContext &Ctx) { } } - -static -HRESULT DoSimpleReWrite(_In_ DxcLangExtensionsHelper *pHelper, - _In_ LPCSTR pFileName, - _In_ ASTUnit::RemappedFile *pRemap, - _In_ hlsl::options::DxcOpts &opts, _In_ DxcDefine *pDefines, - _In_ UINT32 defineCount, - std::string &warnings, - std::string &result, - _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr) { +static HRESULT DoSimpleReWrite(DxcLangExtensionsHelper *pHelper, + LPCSTR pFileName, ASTUnit::RemappedFile *pRemap, + hlsl::options::DxcOpts &opts, + DxcDefine *pDefines, UINT32 defineCount, + std::string &warnings, std::string &result, + dxcutil::DxcArgsFileSystem *msfPtr) { raw_string_ostream o(result); raw_string_ostream w(warnings); @@ -1228,12 +1221,14 @@ class RewriteVisitor : public RecursiveASTVisitor { }; // Preprocess rewritten files. -HRESULT preprocessRewrittenFiles( - _In_ DxcLangExtensionsHelper *pExtHelper, Rewriter &R, - _In_ LPCSTR pFileName, _In_ ASTUnit::RemappedFile *pRemap, - _In_ hlsl::options::DxcOpts &opts, _In_ DxcDefine *pDefines, - _In_ UINT32 defineCount, raw_string_ostream &w, raw_string_ostream &o, - _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr, IMalloc *pMalloc) { +HRESULT preprocessRewrittenFiles(DxcLangExtensionsHelper *pExtHelper, + Rewriter &R, LPCSTR pFileName, + ASTUnit::RemappedFile *pRemap, + hlsl::options::DxcOpts &opts, + DxcDefine *pDefines, UINT32 defineCount, + raw_string_ostream &w, raw_string_ostream &o, + dxcutil::DxcArgsFileSystem *msfPtr, + IMalloc *pMalloc) { CComPtr pOutputStream; IFT(CreateMemoryStream(pMalloc, &pOutputStream)); @@ -1294,11 +1289,10 @@ HRESULT preprocessRewrittenFiles( } HRESULT DoReWriteWithLineDirective( - _In_ DxcLangExtensionsHelper *pExtHelper, _In_ LPCSTR pFileName, - _In_ ASTUnit::RemappedFile *pRemap, _In_ hlsl::options::DxcOpts &opts, - _In_ DxcDefine *pDefines, _In_ UINT32 defineCount, std::string &warnings, - std::string &result, _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr, - IMalloc *pMalloc) { + DxcLangExtensionsHelper *pExtHelper, LPCSTR pFileName, + ASTUnit::RemappedFile *pRemap, hlsl::options::DxcOpts &opts, + DxcDefine *pDefines, UINT32 defineCount, std::string &warnings, + std::string &result, dxcutil::DxcArgsFileSystem *msfPtr, IMalloc *pMalloc) { raw_string_ostream o(result); raw_string_ostream w(warnings); @@ -1428,14 +1422,12 @@ class MethodsVisitor : public DeclVisitor { PrintingPolicy declP; }; - -HRESULT DoRewriteGlobalCB(_In_ DxcLangExtensionsHelper *pExtHelper, - _In_ LPCSTR pFileName, - _In_ ASTUnit::RemappedFile *pRemap, - _In_ hlsl::options::DxcOpts &opts, - _In_ DxcDefine *pDefines, _In_ UINT32 defineCount, - std::string &warnings, std::string &result, - _In_opt_ dxcutil::DxcArgsFileSystem *msfPtr, +HRESULT DoRewriteGlobalCB(DxcLangExtensionsHelper *pExtHelper, LPCSTR pFileName, + ASTUnit::RemappedFile *pRemap, + hlsl::options::DxcOpts &opts, DxcDefine *pDefines, + UINT32 defineCount, std::string &warnings, + std::string &result, + dxcutil::DxcArgsFileSystem *msfPtr, IMalloc *pMalloc) { raw_string_ostream o(result); raw_string_ostream w(warnings); @@ -1547,7 +1539,6 @@ HRESULT DoRewriteGlobalCB(_In_ DxcLangExtensionsHelper *pExtHelper, return S_OK; } - } // namespace class DxcRewriter : public IDxcRewriter2, public IDxcLangExtensions3 { @@ -1566,13 +1557,10 @@ class DxcRewriter : public IDxcRewriter2, public IDxcLangExtensions3 { this, iid, ppvObject); } - HRESULT STDMETHODCALLTYPE RemoveUnusedGlobals(_In_ IDxcBlobEncoding *pSource, - _In_z_ LPCWSTR pEntryPoint, - _In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount, - _COM_Outptr_ IDxcOperationResult **ppResult) override - { - + HRESULT STDMETHODCALLTYPE RemoveUnusedGlobals( + IDxcBlobEncoding *pSource, LPCWSTR pEntryPoint, DxcDefine *pDefines, + UINT32 defineCount, IDxcOperationResult **ppResult) override { + if (pSource == nullptr || ppResult == nullptr || (defineCount > 0 && pDefines == nullptr)) return E_INVALIDARG; @@ -1615,11 +1603,9 @@ class DxcRewriter : public IDxcRewriter2, public IDxcLangExtensions3 { CATCH_CPP_RETURN_HRESULT(); } - HRESULT STDMETHODCALLTYPE - RewriteUnchanged(_In_ IDxcBlobEncoding *pSource, - _In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount, - _COM_Outptr_ IDxcOperationResult **ppResult) override { + HRESULT STDMETHODCALLTYPE RewriteUnchanged( + IDxcBlobEncoding *pSource, DxcDefine *pDefines, UINT32 defineCount, + IDxcOperationResult **ppResult) override { if (pSource == nullptr || ppResult == nullptr || (defineCount > 0 && pDefines == nullptr)) return E_POINTER; @@ -1658,18 +1644,15 @@ class DxcRewriter : public IDxcRewriter2, public IDxcLangExtensions3 { }, ppResult); } CATCH_CPP_RETURN_HRESULT(); - } HRESULT STDMETHODCALLTYPE RewriteUnchangedWithInclude( - _In_ IDxcBlobEncoding *pSource, + IDxcBlobEncoding *pSource, // Optional file name for pSource. Used in errors and include handlers. - _In_opt_ LPCWSTR pSourceName, _In_count_(defineCount) DxcDefine *pDefines, - _In_ UINT32 defineCount, + LPCWSTR pSourceName, DxcDefine *pDefines, UINT32 defineCount, // user-provided interface to handle #include directives (optional) - _In_opt_ IDxcIncludeHandler *pIncludeHandler, - _In_ UINT32 rewriteOption, - _COM_Outptr_ IDxcOperationResult **ppResult) override { + IDxcIncludeHandler *pIncludeHandler, UINT32 rewriteOption, + IDxcOperationResult **ppResult) override { if (pSource == nullptr || ppResult == nullptr || (defineCount > 0 && pDefines == nullptr)) return E_POINTER; @@ -1716,20 +1699,19 @@ class DxcRewriter : public IDxcRewriter2, public IDxcLangExtensions3 { }, ppResult); } CATCH_CPP_RETURN_HRESULT(); - } - HRESULT STDMETHODCALLTYPE RewriteWithOptions( - _In_ IDxcBlobEncoding *pSource, - // Optional file name for pSource. Used in errors and include handlers. - _In_opt_ LPCWSTR pSourceName, - // Compiler arguments - _In_count_(argCount) LPCWSTR *pArguments, _In_ UINT32 argCount, - // Defines - _In_count_(defineCount) DxcDefine *pDefines, _In_ UINT32 defineCount, - // user-provided interface to handle #include directives (optional) - _In_opt_ IDxcIncludeHandler *pIncludeHandler, - _COM_Outptr_ IDxcOperationResult **ppResult) override { + HRESULT STDMETHODCALLTYPE RewriteWithOptions( + IDxcBlobEncoding *pSource, + // Optional file name for pSource. Used in errors and include handlers. + LPCWSTR pSourceName, + // Compiler arguments + LPCWSTR *pArguments, UINT32 argCount, + // Defines + DxcDefine *pDefines, UINT32 defineCount, + // user-provided interface to handle #include directives (optional) + IDxcIncludeHandler *pIncludeHandler, + IDxcOperationResult **ppResult) override { if (pSource == nullptr || ppResult == nullptr || (argCount > 0 && pArguments == nullptr) || @@ -1804,10 +1786,9 @@ class DxcRewriter : public IDxcRewriter2, public IDxcLangExtensions3 { } CATCH_CPP_RETURN_HRESULT(); } - }; -HRESULT CreateDxcRewriter(_In_ REFIID riid, _Out_ LPVOID* ppv) { +HRESULT CreateDxcRewriter(REFIID riid, LPVOID *ppv) { CComPtr isense = DxcRewriter::Alloc(DxcGetThreadMallocNoRef()); IFROOM(isense.p); return isense.p->QueryInterface(riid, ppv); diff --git a/tools/clang/unittests/DxrFallback/DXSampleHelper.h b/tools/clang/unittests/DxrFallback/DXSampleHelper.h index 218feac4a7..7dfcd8e1c4 100644 --- a/tools/clang/unittests/DxrFallback/DXSampleHelper.h +++ b/tools/clang/unittests/DxrFallback/DXSampleHelper.h @@ -19,25 +19,21 @@ inline void ThrowIfFailed(HRESULT hr) } } -inline void GetAssetsPath(_Out_writes_(pathSize) WCHAR* path, UINT pathSize) -{ - if (path == nullptr) - { - throw std::exception(); - } +inline void GetAssetsPath(WCHAR *path, UINT pathSize) { + if (path == nullptr) { + throw std::exception(); + } - DWORD size = GetModuleFileName(nullptr, path, pathSize); - if (size == 0 || size == pathSize) - { - // Method failed or path was truncated. - throw std::exception(); - } + DWORD size = GetModuleFileName(nullptr, path, pathSize); + if (size == 0 || size == pathSize) { + // Method failed or path was truncated. + throw std::exception(); + } - WCHAR* lastSlash = wcsrchr(path, L'\\'); - if (lastSlash) - { - *(lastSlash + 1) = L'\0'; - } + WCHAR *lastSlash = wcsrchr(path, L'\\'); + if (lastSlash) { + *(lastSlash + 1) = L'\0'; + } } inline HRESULT ReadDataFromFile(LPCWSTR filename, byte** data, UINT* size) diff --git a/tools/clang/unittests/HLSL/CompilerTest.cpp b/tools/clang/unittests/HLSL/CompilerTest.cpp index a6ff769033..c4b0baba1b 100644 --- a/tools/clang/unittests/HLSL/CompilerTest.cpp +++ b/tools/clang/unittests/HLSL/CompilerTest.cpp @@ -103,9 +103,9 @@ class TestIncludeHandler : public IDxcIncludeHandler { size_t callIndex; HRESULT STDMETHODCALLTYPE LoadSource( - _In_ LPCWSTR pFilename, // Filename as written in #include statement - _COM_Outptr_ IDxcBlob **ppIncludeSource // Resultant source object for included file - ) override { + LPCWSTR pFilename, // Filename as written in #include statement + IDxcBlob **ppIncludeSource // Resultant source object for included file + ) override { CallInfos.push_back(LoadSourceCallInfo(pFilename)); *ppIncludeSource = nullptr; @@ -276,23 +276,22 @@ class CompilerTest : public ::testing::Test { dxc::DxcDllSupport m_dllSupport; VersionSupportInfo m_ver; - void CreateBlobPinned(_In_bytecount_(size) LPCVOID data, SIZE_T size, - UINT32 codePage, _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobPinned(LPCVOID data, SIZE_T size, UINT32 codePage, + IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingFromPinned(data, size, codePage, ppBlob)); } - void CreateBlobFromFile(LPCWSTR name, _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobFromFile(LPCWSTR name, IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); const std::wstring path = hlsl_test::GetPathToHlslDataFile(name); IFT(library->CreateBlobFromFile(path.c_str(), nullptr, ppBlob)); } - void CreateBlobFromText(_In_z_ const char *pText, - _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobFromText(const char *pText, IDxcBlobEncoding **ppBlob) { CreateBlobPinned(pText, strlen(pText) + 1, CP_UTF8, ppBlob); } @@ -2138,9 +2137,9 @@ void CompilerTest::TestResourceBindingImpl( IncludeHandler() : m_dwRef(0) {} HRESULT STDMETHODCALLTYPE LoadSource( - _In_ LPCWSTR pFilename, // Filename as written in #include statement - _COM_Outptr_ IDxcBlob **ppIncludeSource // Resultant source object for included file - ) override { + LPCWSTR pFilename, // Filename as written in #include statement + IDxcBlob **ppIncludeSource // Resultant source object for included file + ) override { if (0 == wcscmp(pFilename, L"binding-file.txt")) { return pBindingFileBlob.QueryInterface(ppIncludeSource); @@ -3336,7 +3335,7 @@ struct InstrumentedHeapMalloc : public IMalloc { STDMETHODIMP QueryInterface(REFIID iid, void** ppvObject) override { return DoBasicQueryInterface(this, iid, ppvObject); } - virtual void *STDMETHODCALLTYPE Alloc(_In_ SIZE_T cb) override { + virtual void *STDMETHODCALLTYPE Alloc(SIZE_T cb) override { ++m_AllocCount; if (m_FailAlloc && m_AllocCount >= m_FailAlloc) { return nullptr; // breakpoint for i failure - m_FailAlloc == 1+VAL @@ -3360,7 +3359,7 @@ struct InstrumentedHeapMalloc : public IMalloc { return P + 1; } - virtual void *STDMETHODCALLTYPE Realloc(_In_opt_ void *pv, _In_ SIZE_T cb) override { + virtual void *STDMETHODCALLTYPE Realloc(void *pv, SIZE_T cb) override { SIZE_T priorSize = pv == nullptr ? (SIZE_T)0 : GetSize(pv); void *R = Alloc(cb); if (!R) @@ -3371,7 +3370,7 @@ struct InstrumentedHeapMalloc : public IMalloc { return R; } - virtual void STDMETHODCALLTYPE Free(_In_opt_ void *pv) override { + virtual void STDMETHODCALLTYPE Free(void *pv) override { if (!pv) return; PtrData *P = DataFromPtr(pv); @@ -3387,16 +3386,12 @@ struct InstrumentedHeapMalloc : public IMalloc { #endif // __ANDROID__ } - virtual SIZE_T STDMETHODCALLTYPE GetSize( - /* [annotation][in] */ - _In_opt_ _Post_writable_byte_size_(return) void *pv) override - { + virtual SIZE_T STDMETHODCALLTYPE GetSize(void *pv) override { if (pv == nullptr) return 0; return DataFromPtr(pv)->Size; } - virtual int STDMETHODCALLTYPE DidAlloc( - _In_opt_ void *pv) override { + virtual int STDMETHODCALLTYPE DidAlloc(void *pv) override { return -1; // don't know } diff --git a/tools/clang/unittests/HLSL/DXIsenseTest.cpp b/tools/clang/unittests/HLSL/DXIsenseTest.cpp index a53a0735d9..e9ba5289b1 100644 --- a/tools/clang/unittests/HLSL/DXIsenseTest.cpp +++ b/tools/clang/unittests/HLSL/DXIsenseTest.cpp @@ -49,9 +49,9 @@ class DXIntellisenseTest : public ::testing::Test { VERIFY_SUCCEEDED(TU->GetCursorForLocation(location, pResult)); } - void ExpectCursorAt(IDxcTranslationUnit* TU, unsigned line, unsigned col, - DxcCursorKind expectedKind, _COM_Outptr_opt_ IDxcCursor** pResult = nullptr) - { + void ExpectCursorAt(IDxcTranslationUnit *TU, unsigned line, unsigned col, + DxcCursorKind expectedKind, + IDxcCursor **pResult = nullptr) { CComPtr cursor; DxcCursorKind actualKind; GetCursorAt(TU, line, col, &cursor); diff --git a/tools/clang/unittests/HLSL/DxilContainerTest.cpp b/tools/clang/unittests/HLSL/DxilContainerTest.cpp index 6f66734585..27e7bce178 100644 --- a/tools/clang/unittests/HLSL/DxilContainerTest.cpp +++ b/tools/clang/unittests/HLSL/DxilContainerTest.cpp @@ -127,16 +127,15 @@ class DxilContainerTest : public ::testing::Test { dxc::DxcDllSupport m_dllSupport; VersionSupportInfo m_ver; - void CreateBlobPinned(_In_bytecount_(size) LPCVOID data, SIZE_T size, - UINT32 codePage, _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobPinned(LPCVOID data, SIZE_T size, UINT32 codePage, + IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingFromPinned(data, size, codePage, ppBlob)); } - void CreateBlobFromText(_In_z_ const char *pText, - _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobFromText(const char *pText, IDxcBlobEncoding **ppBlob) { CreateBlobPinned(pText, strlen(pText), CP_UTF8, ppBlob); } @@ -1941,7 +1940,7 @@ class HlslFileVariables { LPCWSTR GetMode() const { return m_Mode.c_str(); } LPCWSTR GetTarget() const { return m_Target.c_str(); } void Reset(); - HRESULT SetFromText(_In_count_(len) const char *pText, size_t len); + HRESULT SetFromText(const char *pText, size_t len); }; void HlslFileVariables::Reset() { @@ -1958,7 +1957,7 @@ static bool wcsneq(const wchar_t *pValue, const wchar_t *pCheck) { return 0 == wcsncmp(pValue, pCheck, wcslen(pCheck)); } -HRESULT HlslFileVariables::SetFromText(_In_count_(len) const char *pText, size_t len) { +HRESULT HlslFileVariables::SetFromText(const char *pText, size_t len) { // Look for the line of interest. const char *pEnd = pText + len; const char *pLineEnd = pText; diff --git a/tools/clang/unittests/HLSL/ExtensionTest.cpp b/tools/clang/unittests/HLSL/ExtensionTest.cpp index 2e66e49d6c..694edd5ae5 100644 --- a/tools/clang/unittests/HLSL/ExtensionTest.cpp +++ b/tools/clang/unittests/HLSL/ExtensionTest.cpp @@ -342,15 +342,15 @@ class TestIntrinsicTable : public IDxcIntrinsicTable { return DoBasicQueryInterface(this, iid, ppvObject); } - HRESULT STDMETHODCALLTYPE - GetTableName(_Outptr_ LPCSTR *pTableName) override { + HRESULT STDMETHODCALLTYPE GetTableName(LPCSTR *pTableName) override { *pTableName = "test"; return S_OK; } - HRESULT STDMETHODCALLTYPE LookupIntrinsic( - LPCWSTR typeName, LPCWSTR functionName, const HLSL_INTRINSIC **pIntrinsic, - _Inout_ UINT64 *pLookupCookie) override { + HRESULT STDMETHODCALLTYPE LookupIntrinsic(LPCWSTR typeName, + LPCWSTR functionName, + const HLSL_INTRINSIC **pIntrinsic, + UINT64 *pLookupCookie) override { if (typeName == nullptr) return E_FAIL; @@ -375,8 +375,8 @@ class TestIntrinsicTable : public IDxcIntrinsicTable { return result.intrinsic ? S_OK : E_FAIL; } - HRESULT STDMETHODCALLTYPE - GetLoweringStrategy(UINT opcode, _Outptr_ LPCSTR *pStrategy) override { + HRESULT STDMETHODCALLTYPE GetLoweringStrategy(UINT opcode, + LPCSTR *pStrategy) override { Intrinsic *intrinsic = FindByOpcode(opcode); if (!intrinsic) @@ -386,8 +386,8 @@ class TestIntrinsicTable : public IDxcIntrinsicTable { return S_OK; } - HRESULT STDMETHODCALLTYPE - GetIntrinsicName(UINT opcode, _Outptr_ LPCSTR *pName) override { + HRESULT STDMETHODCALLTYPE GetIntrinsicName(UINT opcode, + LPCSTR *pName) override { Intrinsic *intrinsic = FindByOpcode(opcode); if (!intrinsic) @@ -397,8 +397,8 @@ class TestIntrinsicTable : public IDxcIntrinsicTable { return S_OK; } - HRESULT STDMETHODCALLTYPE - GetDxilOpCode(UINT opcode, _Outptr_ UINT *pDxilOpcode) override { + HRESULT STDMETHODCALLTYPE GetDxilOpCode(UINT opcode, + UINT *pDxilOpcode) override { if (opcode == 13) { *pDxilOpcode = static_cast(hlsl::OP::OpCode::IsInf); return S_OK; diff --git a/tools/clang/unittests/HLSL/MSFileSysTest.cpp b/tools/clang/unittests/HLSL/MSFileSysTest.cpp index 84d161dc62..9f2cfa7216 100644 --- a/tools/clang/unittests/HLSL/MSFileSysTest.cpp +++ b/tools/clang/unittests/HLSL/MSFileSysTest.cpp @@ -89,8 +89,7 @@ class FixedEnumSTATSTG : public IEnumSTATSTG std::vector m_items; unsigned m_index; public: - FixedEnumSTATSTG(_In_count_(itemCount) const STATSTG* items, unsigned itemCount) - { + FixedEnumSTATSTG(const STATSTG *items, unsigned itemCount) { m_dwRef = 0; m_index = 0; m_items.reserve(itemCount); @@ -104,8 +103,8 @@ class FixedEnumSTATSTG : public IEnumSTATSTG { for (auto& item : m_items) CoTaskMemFree(item.pwcsName); } - virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, _Out_writes_to_(celt, *pceltFetched) STATSTG *rgelt, _Out_opt_ ULONG *pceltFetched) - { + virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, STATSTG *rgelt, + ULONG *pceltFetched) { if (celt != 1 || pceltFetched == nullptr) return E_NOTIMPL; if (m_index >= m_items.size()) { @@ -161,82 +160,93 @@ class MockDxcSystemAccess : public IDxcSystemAccess *pResult = resultEnum; return S_OK; } - virtual HRESULT STDMETHODCALLTYPE OpenStorage( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - IUnknown** pResult) override { + virtual HRESULT STDMETHODCALLTYPE OpenStorage(LPCWSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, + IUnknown **pResult) override { *pResult = SHCreateMemStream(nullptr, 0); return (*pResult == nullptr) ? E_OUTOFMEMORY : S_OK; } - virtual HRESULT STDMETHODCALLTYPE SetStorageTime(_In_ IUnknown* storage, - _In_opt_ const FILETIME *lpCreationTime, - _In_opt_ const FILETIME *lpLastAccessTime, - _In_opt_ const FILETIME *lpLastWriteTime) override { + virtual HRESULT STDMETHODCALLTYPE + SetStorageTime(IUnknown *storage, const FILETIME *lpCreationTime, + const FILETIME *lpLastAccessTime, + const FILETIME *lpLastWriteTime) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage(_In_ IUnknown* storage, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) override { + virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage( + IUnknown *storage, + LPBY_HANDLE_FILE_INFORMATION lpFileInformation) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetFileTypeForStorage(_In_ IUnknown* storage, _Out_ DWORD* fileType) override { + virtual HRESULT STDMETHODCALLTYPE + GetFileTypeForStorage(IUnknown *storage, DWORD *fileType) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) override { + virtual HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage( + LPCWSTR lpFileName, LPCWSTR lpExistingFileName) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE MoveStorage(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) override { + virtual HRESULT STDMETHODCALLTYPE MoveStorage(LPCWSTR lpExistingFileName, + LPCWSTR lpNewFileName, + DWORD dwFlags) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetFileAttributesForStorage(_In_ LPCWSTR lpFileName, _Out_ DWORD* pResult) override { + virtual HRESULT STDMETHODCALLTYPE + GetFileAttributesForStorage(LPCWSTR lpFileName, DWORD *pResult) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE DeleteStorage(_In_ LPCWSTR lpFileName) override { + virtual HRESULT STDMETHODCALLTYPE DeleteStorage(LPCWSTR lpFileName) override { return E_NOTIMPL; } virtual HRESULT STDMETHODCALLTYPE RemoveDirectoryStorage(LPCWSTR lpFileName) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE CreateDirectoryStorage(_In_ LPCWSTR lpPathName) override { + virtual HRESULT STDMETHODCALLTYPE + CreateDirectoryStorage(LPCWSTR lpPathName) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* len) override { + virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage( + DWORD nBufferLength, LPWSTR lpBuffer, DWORD *len) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* len) override { + virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW( + DWORD nBufferLength, LPWSTR lpBuffer, DWORD *len) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* len) override { + virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength, + LPWSTR lpBuffer, + DWORD *len) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE SupportsCreateSymbolicLink(_Out_ BOOL* pResult) override { + virtual HRESULT STDMETHODCALLTYPE + SupportsCreateSymbolicLink(BOOL *pResult) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) override { + virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage( + LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName, + DWORD dwFlags) override { return E_NOTIMPL; } virtual HRESULT STDMETHODCALLTYPE CreateStorageMapping( - _In_ IUnknown* hFile, - _In_ DWORD flProtect, - _In_ DWORD dwMaximumSizeHigh, - _In_ DWORD dwMaximumSizeLow, - _Outptr_ IUnknown** pResult) override { + IUnknown *hFile, DWORD flProtect, DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow, IUnknown **pResult) override { return E_NOTIMPL; } - virtual HRESULT MapViewOfFile( - _In_ IUnknown* hFileMappingObject, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwFileOffsetHigh, - _In_ DWORD dwFileOffsetLow, - _In_ SIZE_T dwNumberOfBytesToMap, - _Outptr_ ID3D10Blob** pResult) override { + virtual HRESULT MapViewOfFile(IUnknown *hFileMappingObject, + DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, + DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap, + ID3D10Blob **pResult) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE OpenStdStorage(int standardFD, _Outptr_ IUnknown** pResult) override { + virtual HRESULT STDMETHODCALLTYPE + OpenStdStorage(int standardFD, IUnknown **pResult) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetStreamDisplay(_COM_Outptr_result_maybenull_ ITextFont** textFont, _Out_ unsigned* columnCount) override { + virtual HRESULT STDMETHODCALLTYPE + GetStreamDisplay(ITextFont **textFont, unsigned *columnCount) override { return E_NOTIMPL; } }; diff --git a/tools/clang/unittests/HLSL/PixTest.cpp b/tools/clang/unittests/HLSL/PixTest.cpp index 83aecad735..8207658119 100644 --- a/tools/clang/unittests/HLSL/PixTest.cpp +++ b/tools/clang/unittests/HLSL/PixTest.cpp @@ -258,22 +258,21 @@ class PixTest { const wchar_t *expectedTypeName); void CreateBlobPinned(_In_bytecount_(size) LPCVOID data, SIZE_T size, - UINT32 codePage, _Outptr_ IDxcBlobEncoding **ppBlob) { + UINT32 codePage, IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingFromPinned(data, size, codePage, ppBlob)); } - void CreateBlobFromFile(LPCWSTR name, _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobFromFile(LPCWSTR name, IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); const std::wstring path = hlsl_test::GetPathToHlslDataFile(name); IFT(library->CreateBlobFromFile(path.c_str(), nullptr, ppBlob)); } - void CreateBlobFromText(_In_z_ const char *pText, - _Outptr_ IDxcBlobEncoding **ppBlob) { + void CreateBlobFromText(const char *pText, IDxcBlobEncoding **ppBlob) { CreateBlobPinned(pText, strlen(pText) + 1, CP_UTF8, ppBlob); } @@ -328,7 +327,7 @@ class PixTest { } } - std::wstring GetDebugInfoAsText(_In_ IDiaDataSource* pDataSource) { + std::wstring GetDebugInfoAsText(IDiaDataSource *pDataSource) { CComPtr pSession; CComPtr pTable; CComPtr pEnumTables; @@ -478,7 +477,7 @@ class PixTest { return o.str(); } - std::wstring GetDebugFileContent(_In_ IDiaDataSource *pDataSource) { + std::wstring GetDebugFileContent(IDiaDataSource *pDataSource) { CComPtr pSession; CComPtr pTable; @@ -1869,8 +1868,9 @@ TEST_F(PixTest, PixDebugCompileInfo) { static LPCWSTR defaultFilename = L"source.hlsl"; static void CompileAndLogErrors(dxc::DxcDllSupport &dllSupport, LPCSTR pText, - LPCWSTR pTargetProfile, std::vector &args, - _Outptr_ IDxcBlob **ppResult) { + LPCWSTR pTargetProfile, + std::vector &args, + IDxcBlob **ppResult) { CComPtr pCompiler; CComPtr pSource; CComPtr pResult; diff --git a/tools/clang/unittests/HLSL/RewriterTest.cpp b/tools/clang/unittests/HLSL/RewriterTest.cpp index 49ddb0a9eb..f64d0b865b 100644 --- a/tools/clang/unittests/HLSL/RewriterTest.cpp +++ b/tools/clang/unittests/HLSL/RewriterTest.cpp @@ -109,8 +109,8 @@ class RewriterTest { } }; - void CreateBlobPinned(_In_bytecount_(size) LPCVOID data, SIZE_T size, - UINT32 codePage, _In_ IDxcBlobEncoding **ppBlob) { + void CreateBlobPinned(LPCVOID data, SIZE_T size, UINT32 codePage, + IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingFromPinned(data, size, codePage, @@ -216,8 +216,8 @@ class RewriterTest { // to check for stable output. It has now been replaced by a new test that checks against a gold baseline. void RewriteCompareGold(LPCWSTR path, LPCWSTR goldPath, - _COM_Outptr_ IDxcOperationResult **ppResult, - _In_ IDxcRewriter *rewriter) { + IDxcOperationResult **ppResult, + IDxcRewriter *rewriter) { // Get the source text from a file FileWithBlob source(m_dllSupport, path); diff --git a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp index 1e2fd86001..99288cb82b 100644 --- a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp +++ b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp @@ -93,9 +93,8 @@ MIDL_INTERFACE("e9eb5314-33aa-42b2-a718-d77f58b1f1c7") ID3D12SDKConfiguration : public IUnknown { public: - virtual HRESULT STDMETHODCALLTYPE SetSDKVersion( - UINT SDKVersion, - _In_z_ LPCSTR SDKPath) = 0; + virtual HRESULT STDMETHODCALLTYPE SetSDKVersion(UINT SDKVersion, + LPCSTR SDKPath) = 0; }; #endif /* __ID3D12SDKConfiguration_INTERFACE_DEFINED__ */ @@ -252,11 +251,11 @@ enum D3D12_VIEW_INSTANCING_TIER typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS3 { - _Out_ BOOL CopyQueueTimestampQueriesSupported; - _Out_ BOOL CastingFullyTypedFormatSupported; - _Out_ DWORD WriteBufferImmediateSupportFlags; - _Out_ D3D12_VIEW_INSTANCING_TIER ViewInstancingTier; - _Out_ BOOL BarycentricsSupported; + BOOL CopyQueueTimestampQueriesSupported; + BOOL CastingFullyTypedFormatSupported; + DWORD WriteBufferImmediateSupportFlags; + D3D12_VIEW_INSTANCING_TIER ViewInstancingTier; + BOOL BarycentricsSupported; } D3D12_FEATURE_DATA_D3D12_OPTIONS3; #endif @@ -270,9 +269,9 @@ typedef enum D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS4 { - _Out_ BOOL ReservedBufferPlacementSupported; - _Out_ D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; - _Out_ BOOL Native16BitShaderOpsSupported; + BOOL ReservedBufferPlacementSupported; + 3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; + BOOL Native16BitShaderOpsSupported; } D3D12_FEATURE_DATA_D3D12_OPTIONS4; #endif @@ -520,7 +519,7 @@ class ExecutionTest { return true; } - std::wstring DxcBlobToWide(_In_ IDxcBlob *pBlob) { + std::wstring DxcBlobToWide(IDxcBlob *pBlob) { if (!pBlob) return std::wstring(); @@ -728,8 +727,9 @@ class ExecutionTest { VERIFY_SUCCEEDED(pDevice->CreateComputePipelineState(&computePsoDesc, IID_PPV_ARGS(ppComputeState))); } - bool CreateDevice(_COM_Outptr_ ID3D12Device **ppDevice, - D3D_SHADER_MODEL testModel = D3D_SHADER_MODEL_6_0, bool skipUnsupported = true) { + bool CreateDevice(ID3D12Device **ppDevice, + D3D_SHADER_MODEL testModel = D3D_SHADER_MODEL_6_0, + bool skipUnsupported = true) { if (testModel > HIGHEST_SHADER_MODEL) { UINT minor = (UINT)testModel & 0x0f; LogCommentFmt(L"Installed SDK does not support " @@ -789,7 +789,7 @@ class ExecutionTest { if (!UseDxbc()) { // Check for DXIL support. typedef struct D3D12_FEATURE_DATA_SHADER_MODEL { - _Inout_ D3D_SHADER_MODEL HighestShaderModel; + D3D_SHADER_MODEL HighestShaderModel; } D3D12_FEATURE_DATA_SHADER_MODEL; const UINT D3D12_FEATURE_SHADER_MODEL = 7; D3D12_FEATURE_DATA_SHADER_MODEL SMData; @@ -5289,7 +5289,7 @@ struct Half2 Half2& operator=(Half2&&) = default; constexpr Half2(uint16_t _x, uint16_t _y) : x(_x), y(_y) {} - explicit Half2(_In_reads_(2) const uint16_t *pArray) : x(pArray[0]), y(pArray[1]) {} + explicit Half2(const uint16_t *pArray) : x(pArray[0]), y(pArray[1]) {} }; struct SDot2AddHalfOp { diff --git a/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp b/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp index 105dce84be..c57927f00c 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp +++ b/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp @@ -63,7 +63,7 @@ void st::SetOutputFn(void *pCtx, OutputStringFn F) { g_OutputStrFn = F; } -static void ShaderOpLogFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) { +static void ShaderOpLogFmt(const wchar_t *fmt, ...) { va_list args; va_start(args, fmt); std::wstring buf(hlsl_test::vFormatToWString(fmt, args)); diff --git a/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp b/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp index 597cc94969..e23294bdb8 100644 --- a/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp +++ b/tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp @@ -225,7 +225,7 @@ void SplitPassList(LPWSTR pPassesBuffer, std::vector &passes) { } } -std::string BlobToUtf8(_In_ IDxcBlob *pBlob) { +std::string BlobToUtf8(IDxcBlob *pBlob) { if (!pBlob) return std::string(); CComPtr pBlobUtf8; @@ -265,7 +265,7 @@ std::string BlobToUtf8(_In_ IDxcBlob *pBlob) { } } -std::wstring BlobToWide(_In_ IDxcBlob *pBlob) { +std::wstring BlobToWide(IDxcBlob *pBlob) { if (!pBlob) return std::wstring(); CComPtr pBlobWide; @@ -301,38 +301,40 @@ std::wstring BlobToWide(_In_ IDxcBlob *pBlob) { } void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, - _Outptr_ IDxcBlobEncoding **ppBlob) { + IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingOnHeapCopy(pVal, strlen(pVal), CP_UTF8, ppBlob)); } -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, - UINT32 codePage, _Outptr_ IDxcBlobEncoding **ppBlob) { +void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, + const std::string &val, UINT32 codePage, + IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingOnHeapCopy(val.data(), val.size(), codePage, ppBlob)); } -void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, - UINT32 codePage, _Outptr_ IDxcBlob **ppBlob) { +void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport, + const std::string &val, UINT32 codePage, + IDxcBlob **ppBlob) { MultiByteStringToBlob(dllSupport, val, codePage, (IDxcBlobEncoding **)ppBlob); } void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, - _Outptr_ IDxcBlobEncoding **ppBlob) { + IDxcBlobEncoding **ppBlob) { MultiByteStringToBlob(dllSupport, val, CP_UTF8, ppBlob); } void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, - _Outptr_ IDxcBlob **ppBlob) { + IDxcBlob **ppBlob) { Utf8ToBlob(dllSupport, val, (IDxcBlobEncoding **)ppBlob); } void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, - _Outptr_ IDxcBlobEncoding **ppBlob) { + IDxcBlobEncoding **ppBlob) { CComPtr library; IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library)); IFT(library->CreateBlobWithEncodingOnHeapCopy( @@ -340,13 +342,13 @@ void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, } void WideToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, - _Outptr_ IDxcBlob **ppBlob) { + IDxcBlob **ppBlob) { WideToBlob(dllSupport, val, (IDxcBlobEncoding **)ppBlob); } void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, LPWSTR pTargetProfile, LPCWSTR pArgs, - _Outptr_ IDxcBlob **ppResult) { + IDxcBlob **ppResult) { std::vector argsW; std::vector args; if (pArgs) { @@ -361,7 +363,7 @@ void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText, LPWSTR pTargetProfile, std::vector &args, - _Outptr_ IDxcBlob **ppResult) { + IDxcBlob **ppResult) { CComPtr pCompiler; CComPtr pSource; CComPtr pResult; diff --git a/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp b/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp index b400015cad..86c9932779 100644 --- a/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp +++ b/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp @@ -231,8 +231,9 @@ class IncludeHandlerVFSOverlayForTest : public IDxcIncludeHandler { CComPtr pInnerIncludeHandler; HRESULT STDMETHODCALLTYPE LoadSource( - _In_ LPCWSTR pFilename, // Candidate filename. - _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource // Resultant source object for included file, nullptr if not found. + LPCWSTR pFilename, // Candidate filename. + IDxcBlob **ppIncludeSource // Resultant source object for included file, + // nullptr if not found. ) override { if (!ppIncludeSource) return E_INVALIDARG; diff --git a/tools/clang/unittests/dxc_batch/dxc_batch.cpp b/tools/clang/unittests/dxc_batch/dxc_batch.cpp index c00102d562..d3ce6a7a1b 100644 --- a/tools/clang/unittests/dxc_batch/dxc_batch.cpp +++ b/tools/clang/unittests/dxc_batch/dxc_batch.cpp @@ -171,7 +171,8 @@ static int Compile(llvm::StringRef command, DxcDllSupport &dxcSupport, return retVal; } -static void WriteBlobToFile(_In_opt_ IDxcBlob *pBlob, llvm::StringRef FName, UINT32 defaultTextCodePage) { +static void WriteBlobToFile(IDxcBlob *pBlob, llvm::StringRef FName, + UINT32 defaultTextCodePage) { ::dxc::WriteBlobToFile(pBlob, StringRefWide(FName), defaultTextCodePage); } @@ -537,8 +538,8 @@ class DxcIncludeHandlerForInjectedSources : public IDxcIncludeHandler { return DoBasicQueryInterface(this, iid, ppvObject); } - HRESULT insertIncludeFile(_In_ LPCWSTR pFilename, - _In_ IDxcBlobEncoding *pBlob, _In_ UINT32 dataLen) { + HRESULT insertIncludeFile(LPCWSTR pFilename, IDxcBlobEncoding *pBlob, + UINT32 dataLen) { try { includeFiles.try_emplace(std::wstring(pFilename), pBlob); } @@ -546,9 +547,8 @@ class DxcIncludeHandlerForInjectedSources : public IDxcIncludeHandler { return S_OK; } - HRESULT STDMETHODCALLTYPE - LoadSource(_In_ LPCWSTR pFilename, - _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource) override { + HRESULT STDMETHODCALLTYPE LoadSource(LPCWSTR pFilename, + IDxcBlob **ppIncludeSource) override { try { *ppIncludeSource = includeFiles.at(std::wstring(pFilename)); (*ppIncludeSource)->AddRef(); @@ -693,7 +693,7 @@ void DxcContext::Preprocess() { } } -static void WriteString(HANDLE hFile, _In_z_ LPCSTR value, LPCWSTR pFileName) { +static void WriteString(HANDLE hFile, LPCSTR value, LPCWSTR pFileName) { DWORD written; if (FALSE == WriteFile(hFile, value, strlen(value) * sizeof(value[0]), &written, nullptr)) diff --git a/tools/dxexp/dxexp.cpp b/tools/dxexp/dxexp.cpp index 6f7b79a015..4a226a5884 100644 --- a/tools/dxexp/dxexp.cpp +++ b/tools/dxexp/dxexp.cpp @@ -69,11 +69,11 @@ enum D3D12_VIEW_INSTANCING_TIER typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS3 { - _Out_ BOOL CopyQueueTimestampQueriesSupported; - _Out_ BOOL CastingFullyTypedFormatSupported; - _Out_ DWORD WriteBufferImmediateSupportFlags; - _Out_ D3D12_VIEW_INSTANCING_TIER ViewInstancingTier; - _Out_ BOOL BarycentricsSupported; + BOOL CopyQueueTimestampQueriesSupported; + BOOL CastingFullyTypedFormatSupported; + DWORD WriteBufferImmediateSupportFlags; + D3D12_VIEW_INSTANCING_TIER ViewInstancingTier; + BOOL BarycentricsSupported; } D3D12_FEATURE_DATA_D3D12_OPTIONS3; #endif @@ -91,9 +91,9 @@ typedef enum D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS4 { - _Out_ BOOL ReservedBufferPlacementSupported; - _Out_ D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; - _Out_ BOOL Native16BitShaderOpsSupported; + BOOL ReservedBufferPlacementSupported; + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; + BOOL Native16BitShaderOpsSupported; } D3D12_FEATURE_DATA_D3D12_OPTIONS4; #endif @@ -119,9 +119,9 @@ typedef enum D3D12_RAYTRACING_TIER typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS5 { - _Out_ BOOL SRVOnlyTiledResourceTier3; - _Out_ D3D12_RENDER_PASS_TIER RenderPassesTier; - _Out_ D3D12_RAYTRACING_TIER RaytracingTier; + BOOL SRVOnlyTiledResourceTier3; + D3D12_RENDER_PASS_TIER RenderPassesTier; + D3D12_RAYTRACING_TIER RaytracingTier; } D3D12_FEATURE_DATA_D3D12_OPTIONS5; #endif @@ -133,9 +133,9 @@ typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS5 #define D3D12_FEATURE_D3D12_OPTIONS14 ((D3D12_FEATURE)43) typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS14 { - _Out_ BOOL AdvancedTextureOpsSupported; - _Out_ BOOL WriteableMSAATexturesSupported; - _Out_ BOOL IndependentFrontAndBackStencilRefMaskSupported; + BOOL AdvancedTextureOpsSupported; + BOOL WriteableMSAATexturesSupported; + BOOL IndependentFrontAndBackStencilRefMaskSupported; } D3D12_FEATURE_DATA_D3D12_OPTIONS14; #endif diff --git a/utils/hct/hctgen.py b/utils/hct/hctgen.py index 6b84bb447a..338ed4cbac 100755 --- a/utils/hct/hctgen.py +++ b/utils/hct/hctgen.py @@ -163,7 +163,7 @@ def writeDxilValidation(args): ' unsigned op = I.getOpcode();', ])) out.write(get_instrs_pred("op", lambda i: not i.is_dxil_op and i.is_allowed, "llvm_id")) - out.write('}\n\nvoid GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor) {') + out.write('}\n\nvoid GetValidationVersion(unsigned *pMajor, unsigned *pMinor) {') out.write(get_validation_version()) out.write('}\n}\n') return 0