Skip to content

Commit 956fa34

Browse files
authored
[ClangCL] Cleanup rest clang-cl warnings (microsoft#5847)
1. printf format mismatch. 2. avoid cast from CComPtr<IncludeHandlerVFSOverlayForTest> to CComPtr<IDxcIncludeHandler>. 3. fix signed unsigned mismatch. 4. fix order of fields in constructor. 5. add override for override methods. 6. port llvm/llvm-project@01f4209 7. add copy assignment operator to avoid -Wdeprecated-copy-with-user-provided-copy 8. disable -Wignored-qualifiers for taef header WexTestClass.h. 9. remove unused fields. 10. add -clang-cl for hctbuild.
1 parent 1306b0c commit 956fa34

File tree

18 files changed

+110
-103
lines changed

18 files changed

+110
-103
lines changed

include/dxc/Support/microcom.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ template <typename T> void DxcCallDestructor(T *obj) { obj->T::~T(); }
7474
#define DXC_MICROCOM_REF_FIELD(m_dwRef) \
7575
volatile std::atomic<llvm::sys::cas_flag> m_dwRef = {0};
7676
#define DXC_MICROCOM_ADDREF_IMPL(m_dwRef) \
77-
ULONG STDMETHODCALLTYPE AddRef() override { return (ULONG)++m_dwRef; }
77+
ULONG STDMETHODCALLTYPE AddRef() noexcept override { \
78+
return (ULONG)++m_dwRef; \
79+
}
7880
#define DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef) \
7981
DXC_MICROCOM_ADDREF_IMPL(m_dwRef) \
8082
ULONG STDMETHODCALLTYPE Release() override { \
@@ -107,7 +109,7 @@ inline T *CreateOnMalloc(IMalloc *pMalloc, Args &&...args) {
107109

108110
#define DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL() \
109111
DXC_MICROCOM_ADDREF_IMPL(m_dwRef) \
110-
ULONG STDMETHODCALLTYPE Release() override { \
112+
ULONG STDMETHODCALLTYPE Release() noexcept override { \
111113
ULONG result = (ULONG)--m_dwRef; \
112114
if (result == 0) { \
113115
CComPtr<IMalloc> pTmp(m_pMalloc); \

include/dxc/Test/HlslTestUtils.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@
1919
#include <string>
2020
#include <vector>
2121
#ifdef _WIN32
22+
23+
// Disable -Wignored-qualifiers for WexTestClass.h.
24+
// For const size_t GetSize() const; in TestData.h.
25+
#ifdef __clang__
26+
#pragma clang diagnostic push
27+
#pragma clang diagnostic ignored "-Wignored-qualifiers"
28+
#endif
2229
#include "WexTestClass.h"
30+
#ifdef __clang__
31+
#pragma clang diagnostic pop
32+
#endif
33+
2334
#include <dxgiformat.h>
2435
#else
2536
#include "WEXAdapter.h"

projects/dxilconv/include/ShaderBinary/ShaderBinary.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ class COperandBase {
239239
public:
240240
COperandBase() { Clear(); }
241241
COperandBase(const COperandBase &Op) { memcpy(this, &Op, sizeof(*this)); }
242+
COperandBase &operator=(const COperandBase &Op) {
243+
if (this != &Op)
244+
memcpy(this, &Op, sizeof(*this));
245+
return *this;
246+
}
242247
D3D10_SB_OPERAND_TYPE OperandType() const { return m_Type; }
243248
const COperandIndex *OperandIndex(UINT Index) const {
244249
return &m_Index[Index];

tools/clang/lib/CodeGen/CGBuilder.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@ class CodeGenFunction;
2222
/// instructions.
2323
template <bool PreserveNames>
2424
class CGBuilderInserter
25-
: protected llvm::IRBuilderDefaultInserter<PreserveNames> {
25+
: protected llvm::IRBuilderDefaultInserter<PreserveNames> {
2626
public:
27-
CGBuilderInserter() : CGF(nullptr) {}
27+
CGBuilderInserter() = default;
2828
explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
2929

3030
protected:
3131
/// \brief This forwards to CodeGenFunction::InsertHelper.
3232
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
3333
llvm::BasicBlock *BB,
3434
llvm::BasicBlock::iterator InsertPt) const;
35-
private:
36-
void operator=(const CGBuilderInserter &) = delete;
3735

38-
CodeGenFunction *CGF;
36+
private:
37+
CodeGenFunction *CGF = nullptr;
3938
};
4039

4140
// Don't preserve names on values in an optimized build.

tools/clang/unittests/HLSL/AllocatorTest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
///////////////////////////////////////////////////////////////////////////////
1010

1111
#include "dxc/Support/WinIncludes.h"
12-
#ifdef _WIN32
13-
#include "WexTestClass.h"
14-
#endif
1512
#include "dxc/Test/HlslTestUtils.h"
1613

1714
#include "dxc/HLSL/DxilSpanAllocator.h"
@@ -104,6 +101,7 @@ bool Align(unsigned &pos, unsigned end, unsigned align) {
104101
struct Element {
105102
Element() = default;
106103
Element(const Element &) = default;
104+
Element &operator=(const Element &) = default;
107105
Element(unsigned id, unsigned start, unsigned end)
108106
: id(id), start(start), end(end) {}
109107
bool operator<(const Element &other) { return id < other.id; }

tools/clang/unittests/HLSL/DXIsenseTest.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include "dxc/Test/HLSLTestData.h"
1414
#include <stdint.h>
1515

16-
#ifdef _WIN32
17-
#include "WexTestClass.h"
18-
#endif
1916
#include "dxc/Support/microcom.h"
2017
#include "dxc/Test/HlslTestUtils.h"
2118

tools/clang/unittests/HLSL/LinkerTest.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
#include <fstream>
2020

21-
#ifdef _WIN32
22-
#include "WexTestClass.h"
23-
#endif
2421
#include "dxc/DxilContainer/DxilContainer.h"
2522
#include "dxc/Support/Global.h" // for IFT macro
2623
#include "dxc/Test/DxcTestUtils.h"

tools/clang/unittests/HLSL/MSFileSysTest.cpp

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// Includes on Windows are highly order dependent.
1414
#include <stdint.h>
1515
#include "dxc/Support/WinIncludes.h"
16-
#include "WexTestClass.h"
1716
#include "dxc/Test/HlslTestUtils.h"
1817

1918
#include "llvm/Support/MSFileSystem.h"
@@ -38,14 +37,15 @@ private: \
3837
volatile std::atomic<llvm::sys::cas_flag> m_dwRef; \
3938
\
4039
public: \
41-
ULONG STDMETHODCALLTYPE AddRef() { return (ULONG)++m_dwRef; } \
42-
ULONG STDMETHODCALLTYPE Release() { \
40+
ULONG STDMETHODCALLTYPE AddRef() override { return (ULONG)++m_dwRef; } \
41+
ULONG STDMETHODCALLTYPE Release() override { \
4342
ULONG result = (ULONG)--m_dwRef; \
4443
if (result == 0) \
4544
delete this; \
4645
return result; \
4746
} \
48-
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) { \
47+
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) \
48+
override { \
4949
if (ppvObject == nullptr) \
5050
return E_POINTER; \
5151
if (IsEqualIID(iid, __uuidof(IUnknown)) || \
@@ -100,12 +100,12 @@ class FixedEnumSTATSTG : public IEnumSTATSTG {
100100
m_items[i].pwcsName = CoTaskMemDup(m_items[i].pwcsName);
101101
}
102102
}
103-
~FixedEnumSTATSTG() {
103+
virtual ~FixedEnumSTATSTG() {
104104
for (auto &item : m_items)
105105
CoTaskMemFree(item.pwcsName);
106106
}
107-
virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, STATSTG *rgelt,
108-
ULONG *pceltFetched) {
107+
HRESULT STDMETHODCALLTYPE Next(ULONG celt, STATSTG *rgelt,
108+
ULONG *pceltFetched) override {
109109
if (celt != 1 || pceltFetched == nullptr)
110110
return E_NOTIMPL;
111111
if (m_index >= m_items.size()) {
@@ -119,22 +119,20 @@ class FixedEnumSTATSTG : public IEnumSTATSTG {
119119
++m_index;
120120
return S_OK;
121121
}
122-
virtual HRESULT STDMETHODCALLTYPE Skip(ULONG celt) { return E_NOTIMPL; }
123-
virtual HRESULT STDMETHODCALLTYPE Reset(void) { return E_NOTIMPL; }
124-
virtual HRESULT STDMETHODCALLTYPE Clone(IEnumSTATSTG **) { return E_NOTIMPL; }
122+
HRESULT STDMETHODCALLTYPE Skip(ULONG celt) override { return E_NOTIMPL; }
123+
HRESULT STDMETHODCALLTYPE Reset(void) override { return E_NOTIMPL; }
124+
HRESULT STDMETHODCALLTYPE Clone(IEnumSTATSTG **) override {
125+
return E_NOTIMPL;
126+
}
125127
};
126128

127129
class MockDxcSystemAccess : public IDxcSystemAccess {
128130
SIMPLE_IUNKNOWN_IMPL1(IDxcSystemAccess)
129-
private:
130-
LPCSTR m_fileName;
131-
LPCSTR m_contents;
132-
unsigned m_length;
133131

134132
public:
135133
unsigned findCount;
136134
MockDxcSystemAccess() : m_dwRef(0), findCount(1) {}
137-
135+
virtual ~MockDxcSystemAccess() {}
138136
static HRESULT Create(MockDxcSystemAccess **pResult) {
139137
*pResult = new (std::nothrow) MockDxcSystemAccess();
140138
if (*pResult == nullptr)
@@ -143,8 +141,8 @@ class MockDxcSystemAccess : public IDxcSystemAccess {
143141
return S_OK;
144142
}
145143

146-
virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName,
147-
IEnumSTATSTG **pResult) override {
144+
HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName,
145+
IEnumSTATSTG **pResult) override {
148146
wchar_t hlslName[] = L"filename.hlsl";
149147
wchar_t fxName[] = L"filename2.fx";
150148
STATSTG items[] = {{hlslName,
@@ -180,94 +178,96 @@ class MockDxcSystemAccess : public IDxcSystemAccess {
180178
*pResult = resultEnum;
181179
return S_OK;
182180
}
183-
virtual HRESULT STDMETHODCALLTYPE OpenStorage(LPCWSTR lpFileName,
184-
DWORD dwDesiredAccess,
185-
DWORD dwShareMode,
186-
DWORD dwCreationDisposition,
187-
DWORD dwFlagsAndAttributes,
188-
IUnknown **pResult) override {
181+
HRESULT STDMETHODCALLTYPE OpenStorage(LPCWSTR lpFileName,
182+
DWORD dwDesiredAccess,
183+
DWORD dwShareMode,
184+
DWORD dwCreationDisposition,
185+
DWORD dwFlagsAndAttributes,
186+
IUnknown **pResult) override {
189187
*pResult = SHCreateMemStream(nullptr, 0);
190188
return (*pResult == nullptr) ? E_OUTOFMEMORY : S_OK;
191189
}
192-
virtual HRESULT STDMETHODCALLTYPE
190+
HRESULT STDMETHODCALLTYPE
193191
SetStorageTime(IUnknown *storage, const FILETIME *lpCreationTime,
194192
const FILETIME *lpLastAccessTime,
195193
const FILETIME *lpLastWriteTime) override {
196194
return E_NOTIMPL;
197195
}
198-
virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage(
196+
HRESULT STDMETHODCALLTYPE GetFileInformationForStorage(
199197
IUnknown *storage,
200198
LPBY_HANDLE_FILE_INFORMATION lpFileInformation) override {
201199
return E_NOTIMPL;
202200
}
203-
virtual HRESULT STDMETHODCALLTYPE
204-
GetFileTypeForStorage(IUnknown *storage, DWORD *fileType) override {
201+
HRESULT STDMETHODCALLTYPE GetFileTypeForStorage(IUnknown *storage,
202+
DWORD *fileType) override {
205203
return E_NOTIMPL;
206204
}
207-
virtual HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage(
205+
HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage(
208206
LPCWSTR lpFileName, LPCWSTR lpExistingFileName) override {
209207
return E_NOTIMPL;
210208
}
211-
virtual HRESULT STDMETHODCALLTYPE MoveStorage(LPCWSTR lpExistingFileName,
212-
LPCWSTR lpNewFileName,
213-
DWORD dwFlags) override {
209+
HRESULT STDMETHODCALLTYPE MoveStorage(LPCWSTR lpExistingFileName,
210+
LPCWSTR lpNewFileName,
211+
DWORD dwFlags) override {
214212
return E_NOTIMPL;
215213
}
216-
virtual HRESULT STDMETHODCALLTYPE
214+
HRESULT STDMETHODCALLTYPE
217215
GetFileAttributesForStorage(LPCWSTR lpFileName, DWORD *pResult) override {
218216
return E_NOTIMPL;
219217
}
220-
virtual HRESULT STDMETHODCALLTYPE DeleteStorage(LPCWSTR lpFileName) override {
218+
HRESULT STDMETHODCALLTYPE DeleteStorage(LPCWSTR lpFileName) override {
221219
return E_NOTIMPL;
222220
}
223-
virtual HRESULT STDMETHODCALLTYPE
221+
HRESULT STDMETHODCALLTYPE
224222
RemoveDirectoryStorage(LPCWSTR lpFileName) override {
225223
return E_NOTIMPL;
226224
}
227-
virtual HRESULT STDMETHODCALLTYPE
225+
HRESULT STDMETHODCALLTYPE
228226
CreateDirectoryStorage(LPCWSTR lpPathName) override {
229227
return E_NOTIMPL;
230228
}
231-
virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(
232-
DWORD nBufferLength, LPWSTR lpBuffer, DWORD *len) override {
229+
HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(DWORD nBufferLength,
230+
LPWSTR lpBuffer,
231+
DWORD *len) override {
233232
return E_NOTIMPL;
234233
}
235-
virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(
236-
DWORD nBufferLength, LPWSTR lpBuffer, DWORD *len) override {
234+
HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(DWORD nBufferLength,
235+
LPWSTR lpBuffer,
236+
DWORD *len) override {
237237
return E_NOTIMPL;
238238
}
239-
virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength,
240-
LPWSTR lpBuffer,
241-
DWORD *len) override {
239+
HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength,
240+
LPWSTR lpBuffer,
241+
DWORD *len) override {
242242
return E_NOTIMPL;
243243
}
244-
virtual HRESULT STDMETHODCALLTYPE
245-
SupportsCreateSymbolicLink(BOOL *pResult) override {
244+
HRESULT STDMETHODCALLTYPE SupportsCreateSymbolicLink(BOOL *pResult) override {
246245
return E_NOTIMPL;
247246
}
248-
virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage(
247+
HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage(
249248
LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName,
250249
DWORD dwFlags) override {
251250
return E_NOTIMPL;
252251
}
253-
virtual HRESULT STDMETHODCALLTYPE CreateStorageMapping(
254-
IUnknown *hFile, DWORD flProtect, DWORD dwMaximumSizeHigh,
255-
DWORD dwMaximumSizeLow, IUnknown **pResult) override {
252+
HRESULT STDMETHODCALLTYPE CreateStorageMapping(IUnknown *hFile,
253+
DWORD flProtect,
254+
DWORD dwMaximumSizeHigh,
255+
DWORD dwMaximumSizeLow,
256+
IUnknown **pResult) override {
256257
return E_NOTIMPL;
257258
}
258-
virtual HRESULT MapViewOfFile(IUnknown *hFileMappingObject,
259-
DWORD dwDesiredAccess, DWORD dwFileOffsetHigh,
260-
DWORD dwFileOffsetLow,
261-
SIZE_T dwNumberOfBytesToMap,
262-
ID3D10Blob **pResult) override {
259+
HRESULT MapViewOfFile(IUnknown *hFileMappingObject, DWORD dwDesiredAccess,
260+
DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow,
261+
SIZE_T dwNumberOfBytesToMap,
262+
ID3D10Blob **pResult) override {
263263
return E_NOTIMPL;
264264
}
265-
virtual HRESULT STDMETHODCALLTYPE
266-
OpenStdStorage(int standardFD, IUnknown **pResult) override {
265+
HRESULT STDMETHODCALLTYPE OpenStdStorage(int standardFD,
266+
IUnknown **pResult) override {
267267
return E_NOTIMPL;
268268
}
269-
virtual HRESULT STDMETHODCALLTYPE
270-
GetStreamDisplay(ITextFont **textFont, unsigned *columnCount) override {
269+
HRESULT STDMETHODCALLTYPE GetStreamDisplay(ITextFont **textFont,
270+
unsigned *columnCount) override {
271271
return E_NOTIMPL;
272272
}
273273
};
@@ -306,7 +306,7 @@ void MSFileSysTest::FindFirstWhenInvokedThenFailsIfNoMatch() {
306306
CreateMSFileSystemForIface(access, &fileSystem);
307307
WIN32_FIND_DATAW findData;
308308
HANDLE h = fileSystem->FindFirstFileW(L"foobar", &findData);
309-
VERIFY_ARE_EQUAL(ERROR_FILE_NOT_FOUND, GetLastError());
309+
VERIFY_ARE_EQUAL(ERROR_FILE_NOT_FOUND, (long)GetLastError());
310310
VERIFY_ARE_EQUAL(INVALID_HANDLE_VALUE, h);
311311
VERIFY_ARE_EQUAL_WSTR(L"", findData.cFileName);
312312
delete fileSystem;
@@ -323,7 +323,7 @@ void MSFileSysTest::FindNextWhenLastThenNoMatch() {
323323
VERIFY_ARE_NOT_EQUAL(INVALID_HANDLE_VALUE, h);
324324
BOOL findNext = fileSystem->FindNextFileW(h, &findData);
325325
VERIFY_IS_FALSE(findNext);
326-
VERIFY_ARE_EQUAL(ERROR_FILE_NOT_FOUND, GetLastError());
326+
VERIFY_ARE_EQUAL(ERROR_FILE_NOT_FOUND, (long)GetLastError());
327327
fileSystem->FindClose(h);
328328
delete fileSystem;
329329
}
@@ -357,7 +357,7 @@ void MSFileSysTest::OpenWhenNewThenZeroSize() {
357357
char buf[4];
358358
DWORD bytesRead;
359359
VERIFY_IS_TRUE(fileSystem->ReadFile(h, buf, _countof(buf), &bytesRead));
360-
VERIFY_ARE_EQUAL(0, bytesRead);
360+
VERIFY_ARE_EQUAL(0u, bytesRead);
361361
fileSystem->CloseHandle(h);
362362
delete fileSystem;
363363
}

tools/clang/unittests/HLSL/Objects.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#include "dxc/Test/HLSLTestData.h"
1313
#include <stdint.h>
1414

15-
#ifdef _WIN32
16-
#include "WexTestClass.h"
17-
#endif
1815
#include "dxc/Test/HlslTestUtils.h"
1916

2017
#include <exception>

tools/clang/unittests/HLSL/OptionsTest.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#include <vector>
2424

2525
#include "dxc/Test/HLSLTestData.h"
26-
#ifdef _WIN32
27-
#include "WexTestClass.h"
28-
#endif
2926
#include "dxc/Test/HlslTestUtils.h"
3027

3128
#include "dxc/DxilContainer/DxilContainer.h"

0 commit comments

Comments
 (0)