Selaa lähdekoodia

Code Cleanup for syncing with Windows (#651)

Young Kim 8 vuotta sitten
vanhempi
commit
028a08a6a9

+ 6 - 0
include/dxc/Support/FileIOHelper.h

@@ -11,6 +11,12 @@
 
 #pragma once
 
+#include "Global.h"
+
+#ifndef _ATL_DECLSPEC_ALLOCATOR
+#define _ATL_DECLSPEC_ALLOCATOR
+#endif
+
 // Forward declarations.
 struct IDxcBlob;
 struct IDxcBlobEncoding;

+ 1 - 1
tools/clang/lib/Sema/SemaHLSL.cpp

@@ -10412,7 +10412,7 @@ HLSLBufferDecl::Create(ASTContext &C, DeclContext *lexicalParent, bool cbuffer,
 const char *HLSLBufferDecl::getDeclKindName() const {
   static const char *HLSLBufferNames[] = {"tbuffer", "cbuffer", "TextureBuffer",
                                           "ConstantBuffer"};
-  unsigned index = isCBuffer() | (isConstantBufferView()) << 1;
+  unsigned index = (unsigned ) isCBuffer() | (isConstantBufferView()) << 1;
   return HLSLBufferNames[index];
 }
 

+ 4 - 4
tools/clang/tools/dxcompiler/DXCompiler.cpp

@@ -23,20 +23,20 @@ namespace hlsl { HRESULT SetupRegistryPassForHLSL(); }
 #pragma warning( disable : 4290 )
 
 // operator new and friends.
-void *operator new(std::size_t size) throw(std::bad_alloc) {
+void *  __CRTDECL operator new(std::size_t size) throw(std::bad_alloc) {
   void * ptr = DxcGetThreadMallocNoRef()->Alloc(size);
   if (ptr == nullptr)
     throw std::bad_alloc();
   return ptr;
 }
-void *operator new(std::size_t size,
+void * __CRTDECL operator new(std::size_t size,
   const std::nothrow_t &nothrow_value) throw() {
   return DxcGetThreadMallocNoRef()->Alloc(size);
 }
-void operator delete (void* ptr) throw() {
+void  __CRTDECL operator delete (void* ptr) throw() {
   DxcGetThreadMallocNoRef()->Free(ptr);
 }
-void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw() {
+void  __CRTDECL operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw() {
   DxcGetThreadMallocNoRef()->Free(ptr);
 }
 

+ 1 - 1
tools/clang/tools/dxcompiler/dxcdia.cpp

@@ -2053,7 +2053,7 @@ __override STDMETHODIMP DxcDiaSession::findInjectedSource(
     IDiaTable *pTable;
     IFT(CreateDxcDiaTable(this, DiaTableKind::InjectedSource, &pTable));
     DxcDiaTableInjectedSource *pInjectedSource =
-        dynamic_cast<DxcDiaTableInjectedSource *>(pTable);
+        reinterpret_cast<DxcDiaTableInjectedSource *>(pTable);
     pInjectedSource->Init(pUtf8FileName.m_psz);
     *ppResult = pInjectedSource;
     return S_OK;

+ 2 - 3
tools/clang/tools/dxcompiler/dxclinker.cpp

@@ -262,12 +262,11 @@ HRESULT STDMETHODCALLTYPE DxcLinker::Link(
 
 HRESULT CreateDxcLinker(_In_ REFIID riid, _Out_ LPVOID *ppv) {
   *ppv = nullptr;
-  CComPtr<DxcLinker> result;
   try {
-    result = DxcLinker::Alloc(DxcGetThreadMallocNoRef());
+    CComPtr<DxcLinker> result(DxcLinker::Alloc(DxcGetThreadMallocNoRef()));
     IFROOM(result.p);
     result->Initialize();
+    return result.p->QueryInterface(riid, ppv);
   }
   CATCH_CPP_RETURN_HRESULT();
-  return result.p->QueryInterface(riid, ppv);
 }

+ 2 - 3
tools/clang/tools/dxcompiler/dxcompilerobj.cpp

@@ -880,11 +880,10 @@ public:
 
 HRESULT CreateDxcCompiler(_In_ REFIID riid, _Out_ LPVOID* ppv) {
   *ppv = nullptr;
-  CComPtr<DxcCompiler> result;
   try {
-    result = DxcCompiler::Alloc(DxcGetThreadMallocNoRef());
+    CComPtr<DxcCompiler> result(DxcCompiler::Alloc(DxcGetThreadMallocNoRef()));
     IFROOM(result.p);
+    return result.p->QueryInterface(riid, ppv);
   }
   CATCH_CPP_RETURN_HRESULT();
-  return result.p->QueryInterface(riid, ppv);
 }

+ 0 - 1
tools/clang/tools/dxcompiler/dxcontainerbuilder.cpp

@@ -154,7 +154,6 @@ HRESULT STDMETHODCALLTYPE DxcContainerBuilder::SerializeContainer(_Out_ IDxcOper
     HRESULT valHR = S_OK;
     if (m_RequireValidation) {
       CComPtr<IDxcValidator> pValidator;
-      CComPtr<IDxcLibrary> pLibrary;
       IFT(CreateDxcValidator(IID_PPV_ARGS(&pValidator)));
       CComPtr<IDxcOperationResult> pValidationResult;
       IFT(pValidator->Validate(pResult, DxcValidatorFlags_RootSignatureOnly, &pValidationResult));

+ 5 - 6
tools/clang/tools/dxcompiler/dxcvalidator.cpp

@@ -260,11 +260,10 @@ HRESULT RunInternalValidator(_In_ IDxcValidator *pValidator,
 }
 
 HRESULT CreateDxcValidator(_In_ REFIID riid, _Out_ LPVOID* ppv) {
-  CComPtr<DxcValidator> result = DxcValidator::Alloc(DxcGetThreadMallocNoRef());
-  if (result == nullptr) {
-    *ppv = nullptr;
-    return E_OUTOFMEMORY;
+  try {
+      CComPtr<DxcValidator> result(DxcValidator::Alloc(DxcGetThreadMallocNoRef()));
+      IFROOM(result.p);
+      return result.p->QueryInterface(riid, ppv);
   }
-
-  return result.p->QueryInterface(riid, ppv);
+  CATCH_CPP_RETURN_HRESULT();
 }

+ 4 - 4
tools/clang/tools/dxlib-sample/dxlib_sample.cpp

@@ -21,20 +21,20 @@ using namespace hlsl;
 #pragma warning( disable : 4290 )
 
 // operator new and friends.
-void *operator new(std::size_t size) throw(std::bad_alloc) {
+void *  __CRTDECL operator new(std::size_t size) throw(std::bad_alloc) {
   void * ptr = DxcGetThreadMallocNoRef()->Alloc(size);
   if (ptr == nullptr)
     throw std::bad_alloc();
   return ptr;
 }
-void *operator new(std::size_t size,
+void *  __CRTDECL operator new(std::size_t size,
   const std::nothrow_t &nothrow_value) throw() {
   return DxcGetThreadMallocNoRef()->Alloc(size);
 }
-void operator delete (void* ptr) throw() {
+void  __CRTDECL operator delete (void* ptr) throw() {
   DxcGetThreadMallocNoRef()->Free(ptr);
 }
-void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw() {
+void  __CRTDECL operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw() {
   DxcGetThreadMallocNoRef()->Free(ptr);
 }
 // Finish of new delete.