Skip to content

Commit 769b504

Browse files
authored
[ClangCL] fix warning in clang tools (microsoft#5706)
1. Remove useless argument cast for CreateBlobWith*. 2. add override for override methods. 3. remove unused field. 4. keep const when cast. 5. change to unsigned to avoid signed unsigned mismatch. 6. change (committed.prim && (tri->t >= committed.t) || -d * computeCullFaceDir(instFlags, rayFlags) < 0) to ((committed.prim && (tri->t >= committed.t)) || -d * computeCullFaceDir(instFlags, rayFlags) < 0) for -Wlogical-op-parentheses.
1 parent e4304d9 commit 769b504

File tree

7 files changed

+50
-48
lines changed

7 files changed

+50
-48
lines changed

tools/clang/tools/d3dcomp/d3dcomp.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ HRESULT WINAPI BridgeD3DCompile(LPCVOID pSrcData, SIZE_T SrcDataSize,
156156
*ppErrorMsgs = nullptr;
157157

158158
IFR(CreateLibrary(&library));
159-
IFR(library->CreateBlobWithEncodingFromPinned((LPBYTE)pSrcData, SrcDataSize,
160-
CP_ACP, &source));
159+
IFR(library->CreateBlobWithEncodingFromPinned(pSrcData, SrcDataSize, CP_ACP,
160+
&source));
161161

162162
// Until we actually wrap the include handler, fail if there's a user-supplied
163163
// handler.
@@ -240,8 +240,8 @@ HRESULT WINAPI BridgeD3DDisassemble(LPCVOID pSrcData, SIZE_T SrcDataSize,
240240
UNREFERENCED_PARAMETER(Flags);
241241

242242
IFR(CreateLibrary(&library));
243-
IFR(library->CreateBlobWithEncodingFromPinned((LPBYTE)pSrcData, SrcDataSize,
244-
CP_ACP, &source));
243+
IFR(library->CreateBlobWithEncodingFromPinned(pSrcData, SrcDataSize, CP_ACP,
244+
&source));
245245
IFR(CreateCompiler(&compiler));
246246
IFR(compiler->Disassemble(source, &disassemblyText));
247247
IFR(disassemblyText.QueryInterface(ppDisassembly));
@@ -259,8 +259,8 @@ HRESULT WINAPI BridgeD3DReflect(LPCVOID pSrcData, SIZE_T SrcDataSize,
259259
*ppReflector = nullptr;
260260

261261
IFR(CreateLibrary(&library));
262-
IFR(library->CreateBlobWithEncodingOnHeapCopy((LPBYTE)pSrcData, SrcDataSize,
263-
CP_ACP, &source));
262+
IFR(library->CreateBlobWithEncodingOnHeapCopy(pSrcData, SrcDataSize, CP_ACP,
263+
&source));
264264
IFR(CreateContainerReflection(&reflection));
265265
IFR(reflection->Load(source));
266266
IFR(reflection->FindFirstPartKind(hlsl::DFCC_DXIL, &shaderIdx));
@@ -353,8 +353,8 @@ HRESULT WINAPI BridgeD3DPreprocess(LPCVOID pSrcData, SIZE_T SrcDataSize,
353353
*ppErrorMsgs = nullptr;
354354

355355
IFR(CreateLibrary(&library));
356-
IFR(library->CreateBlobWithEncodingFromPinned((LPBYTE)pSrcData, SrcDataSize,
357-
CP_ACP, &source));
356+
IFR(library->CreateBlobWithEncodingFromPinned(pSrcData, SrcDataSize, CP_ACP,
357+
&source));
358358

359359
// Until we actually wrap the include handler, fail if there's a user-supplied
360360
// handler.

tools/clang/tools/dxlib-sample/lib_share_compile.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ HRESULT CompileFromBlob(IDxcBlobEncoding *pSource, LPCWSTR pSourceName,
160160
std::string processedHeader = "";
161161
std::vector<std::wstring> hashStrList;
162162
std::vector<LPCWSTR> hashList;
163-
//#define LIB_SHARE_DBG
163+
// #define LIB_SHARE_DBG
164164
#ifdef LIB_SHARE_DBG
165165
std::vector<std::wstring> defineList;
166166
defineList.emplace_back(L"");
@@ -235,8 +235,8 @@ HRESULT WINAPI DxilD3DCompile(LPCVOID pSrcData, SIZE_T SrcDataSize,
235235
*ppErrorMsgs = nullptr;
236236

237237
IFR(CreateLibrary(&library));
238-
IFR(library->CreateBlobWithEncodingFromPinned((LPBYTE)pSrcData, SrcDataSize,
239-
CP_ACP, &source));
238+
IFR(library->CreateBlobWithEncodingFromPinned(pSrcData, SrcDataSize, CP_ACP,
239+
&source));
240240
HRESULT hr = S_OK;
241241
CComPtr<IMalloc> m_pMalloc(GetGlobalHeapMalloc());
242242
DxcThreadMalloc TM(m_pMalloc);
@@ -337,8 +337,8 @@ HRESULT WINAPI DxilD3DCompile2(
337337
*ppOperationResult = nullptr;
338338

339339
IFR(CreateLibrary(&library));
340-
IFR(library->CreateBlobWithEncodingFromPinned((LPBYTE)pSrcData, SrcDataSize,
341-
CP_ACP, &source));
340+
IFR(library->CreateBlobWithEncodingFromPinned(pSrcData, SrcDataSize, CP_ACP,
341+
&source));
342342
HRESULT hr = S_OK;
343343
CComPtr<IMalloc> m_pMalloc(GetGlobalHeapMalloc());
344344
DxcThreadMalloc TM(m_pMalloc);

tools/clang/tools/dxlib-sample/lib_share_preprocessor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class IncPathIncludeHandler : public IDxcIncludeHandler {
5252
public:
5353
DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef)
5454
virtual ~IncPathIncludeHandler() {}
55-
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) {
55+
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
56+
void **ppvObject) override {
5657
return DoBasicQueryInterface<::IDxcIncludeHandler>(this, riid, ppvObject);
5758
}
5859
IncPathIncludeHandler(IDxcIncludeHandler *handler,

tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,38 +129,41 @@ class DxcDxrFallbackCompiler : public IDxcDxrFallbackCompiler {
129129
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
130130
DXC_MICROCOM_TM_CTOR(DxcDxrFallbackCompiler)
131131

132-
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
132+
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
133+
void **ppvObject) override {
133134
return DoBasicQueryInterface<IDxcDxrFallbackCompiler>(this, iid, ppvObject);
134135
}
135136

136-
__override HRESULT STDMETHODCALLTYPE SetFindCalledShaders(bool val) {
137+
HRESULT STDMETHODCALLTYPE SetFindCalledShaders(bool val) override {
137138
m_findCalledShaders = val;
138139
return S_OK;
139140
}
140141

141-
__override HRESULT STDMETHODCALLTYPE SetDebugOutput(int val) {
142+
HRESULT STDMETHODCALLTYPE SetDebugOutput(int val) override {
142143
m_debugOutput = val;
143144
return S_OK;
144145
}
145146

146-
__override HRESULT STDMETHODCALLTYPE PatchShaderBindingTables(
147+
HRESULT STDMETHODCALLTYPE PatchShaderBindingTables(
147148
const LPCWSTR pEntryName, DxcShaderBytecode *pShaderBytecode,
148-
void *pShaderInfo, IDxcOperationResult **ppResult);
149+
void *pShaderInfo, IDxcOperationResult **ppResult) override;
149150

150-
__override HRESULT STDMETHODCALLTYPE RenameAndLink(
151+
HRESULT STDMETHODCALLTYPE RenameAndLink(
151152
DxcShaderBytecode *pLibs, UINT32 libCount, DxcExportDesc *pExports,
152-
UINT32 ExportCount, IDxcOperationResult **ppResult);
153-
154-
__override HRESULT STDMETHODCALLTYPE Compile(
155-
DxcShaderBytecode *pLibs, UINT32 libCount, const LPCWSTR *pShaderNames,
156-
DxcShaderInfo *pShaderInfo, UINT32 shaderCount, UINT32 maxAttributeSize,
157-
IDxcOperationResult **ppResult);
158-
159-
__override HRESULT STDMETHODCALLTYPE
160-
Link(const LPCWSTR pEntryName, IDxcBlob **pLibs, UINT32 libCount,
161-
const LPCWSTR *pShaderNames, DxcShaderInfo *pShaderInfo,
162-
UINT32 shaderCount, UINT32 maxAttributeSize, UINT32 stackSizeInBytes,
163-
IDxcOperationResult **ppResult);
153+
UINT32 ExportCount, IDxcOperationResult **ppResult) override;
154+
155+
HRESULT STDMETHODCALLTYPE Compile(DxcShaderBytecode *pLibs, UINT32 libCount,
156+
const LPCWSTR *pShaderNames,
157+
DxcShaderInfo *pShaderInfo,
158+
UINT32 shaderCount, UINT32 maxAttributeSize,
159+
IDxcOperationResult **ppResult) override;
160+
161+
HRESULT STDMETHODCALLTYPE Link(const LPCWSTR pEntryName, IDxcBlob **pLibs,
162+
UINT32 libCount, const LPCWSTR *pShaderNames,
163+
DxcShaderInfo *pShaderInfo, UINT32 shaderCount,
164+
UINT32 maxAttributeSize,
165+
UINT32 stackSizeInBytes,
166+
IDxcOperationResult **ppResult) override;
164167
};
165168

166169
// TODO: Stolen from Brandon's code, merge

tools/clang/tools/dxrfallbackcompiler/dxcvalidator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class DxcValidator : public IDxcValidator, public IDxcVersionInfo {
6363
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
6464
DXC_MICROCOM_TM_CTOR(DxcValidator)
6565

66-
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
66+
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
67+
void **ppvObject) override {
6768
return DoBasicQueryInterface<IDxcValidator, IDxcVersionInfo>(this, iid,
6869
ppvObject);
6970
}
@@ -79,17 +80,16 @@ class DxcValidator : public IDxcValidator, public IDxcVersionInfo {
7980
);
8081

8182
// IDxcValidator
82-
__override HRESULT STDMETHODCALLTYPE Validate(
83+
HRESULT STDMETHODCALLTYPE Validate(
8384
IDxcBlob *pShader, // Shader to validate.
8485
UINT32 Flags, // Validation flags.
8586
IDxcOperationResult *
8687
*ppResult // Validation output status, buffer, and errors
87-
);
88+
) override;
8889

8990
// IDxcVersionInfo
90-
__override HRESULT STDMETHODCALLTYPE GetVersion(UINT32 *pMajor,
91-
UINT32 *pMinor);
92-
__override HRESULT STDMETHODCALLTYPE GetFlags(UINT32 *pFlags);
91+
HRESULT STDMETHODCALLTYPE GetVersion(UINT32 *pMajor, UINT32 *pMinor) override;
92+
HRESULT STDMETHODCALLTYPE GetFlags(UINT32 *pFlags) override;
9393
};
9494

9595
// Compile a single entry point to the target shader model

tools/clang/unittests/DxrFallback/ShaderTesterImpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class ShaderTesterImpl : public ShaderTester {
1010
ShaderTesterImpl(ID3DBlob *blob);
1111
virtual ~ShaderTesterImpl();
1212

13-
virtual void setDevice(const std::wstring &namePrefix);
14-
virtual void runShader(int initialShaderId, const std::vector<int> &input,
15-
std::vector<int> &output) override;
13+
void setDevice(const std::wstring &namePrefix) override;
14+
void runShader(int initialShaderId, const std::vector<int> &input,
15+
std::vector<int> &output) override;
1616

1717
private:
1818
void init();

tools/clang/unittests/DxrFallback/test_DxrFallback.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ class Tester {
191191

192192
bool checkResult(const std::vector<int> &output,
193193
const std::vector<int> &expectedOutput) {
194-
int count = output.empty() ? 0 : output[0];
194+
const unsigned count = output.empty() ? 0 : output[0];
195195
std::cout << count << ": ";
196196

197197
// print result
198-
for (int i = 0; i < count; ++i)
198+
for (unsigned i = 0; i < count; ++i)
199199
std::cout << output[i + 1] << " ";
200200
std::cout << "\n";
201201

@@ -368,11 +368,9 @@ Custom *custom(const std::vector<Custom::Hit> &hits, int geomOpaque = 0,
368368
struct Payload {
369369
int val;
370370
int primIdx;
371-
float t;
372371

373372
bool operator!=(const Payload &other) {
374-
return this->val != other.val || this->primIdx != other.primIdx ||
375-
this->t != other.t;
373+
return this->val != other.val || this->primIdx != other.primIdx;
376374
}
377375
};
378376

@@ -441,7 +439,7 @@ class TestData {
441439
float d = (instFlags & INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE)
442440
? -tri->d
443441
: tri->d;
444-
if (committed.prim && (tri->t >= committed.t) ||
442+
if ((committed.prim && (tri->t >= committed.t)) ||
445443
-d * computeCullFaceDir(instFlags, rayFlags) < 0)
446444
continue;
447445

@@ -515,7 +513,7 @@ class TestData {
515513
shade(ch, "miss");
516514
if (committed.prim) {
517515
if (committed.prim->leafType == LEAF_TRIS) {
518-
Triangle *tri = (Triangle *)committed.prim;
516+
const Triangle *tri = (const Triangle *)committed.prim;
519517
expect({CLOSESTHIT, (int)tri->u, (int)tri->v});
520518
} else {
521519
expect({CLOSESTHIT + 1, committed.hit->attr0, committed.hit->attr1});

0 commit comments

Comments
 (0)