Skip to content

Commit 6d1d302

Browse files
committed
Fix a number of warnings identified by higher clang warning levels
* We enable a couple of high signal-to-noise warnings in all clang builds
1 parent 7599264 commit 6d1d302

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+482
-405
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
328328
endif()
329329

330330
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
331-
list(APPEND warning_flags -Wnewline-eof)
331+
list(APPEND warning_flags -Wnewline-eof -Wunreachable-code-break -Wclass-varargs -Wcomma -Wstring-conversion)
332332
endif()
333333

334334
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 AND NOT APPLE)

qrenderdoc/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)
168168
"QMAKE_CXXFLAGS+=-Wno-unknown-warning -Wno-implicit-fallthrough -Wno-cast-function-type -Wno-stringop-truncation\n")
169169
endif()
170170

171+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
172+
file(APPEND
173+
${CMAKE_BINARY_DIR}/qrenderdoc/qrenderdoc_cmake.pri
174+
"QMAKE_CXXFLAGS+=-Wno-comma\n")
175+
endif()
176+
171177
if(ENABLE_WAYLAND)
172178
message(WARNING "!!!! Using the Wayland Qt platform in qrenderdoc is NOT SUPPORTED !!!!")
173179
file(APPEND

qrenderdoc/Code/pyrenderdoc/renderdoc.i

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,7 @@
112112
}
113113

114114
// ignore some operators SWIG doesn't have to worry about
115-
%ignore SDType::operator=;
116-
%ignore StructuredObjectList::swap;
117-
%ignore StructuredChunkList::swap;
118-
%ignore StructuredObjectList::operator=;
119-
%ignore StructuredObjectList::operator=;
120-
%ignore StructuredChunkList::operator=;
121-
%ignore StructuredBufferList::operator=;
115+
%ignore *::operator=;
122116

123117
// these objects return a new copy which the python caller should own.
124118
%newobject SDObject::Duplicate;

renderdoc/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,12 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR APPLE)
354354
# Need to add -Wno-unknown-warning-option since only newer clang versions have
355355
# -Wno-unused-lambda-capture available
356356
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
357-
# Only clang has this warning. Fixing it in this file causes a compile error on windows
358-
set_source_files_properties(os/os_specific.cpp
359-
PROPERTIES COMPILE_FLAGS "-Wno-unknown-warning-option -Wno-unused-lambda-capture")
357+
set_property(SOURCE 3rdparty/jpeg-compressor/jpgd.cpp
358+
APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-unreachable-code-break -Wno-implicit-fallthrough")
359+
360+
# Only clang has this warning. Fixing it in this file causes a compile error on windows
361+
set_source_files_properties(os/os_specific.cpp
362+
PROPERTIES COMPILE_FLAGS "-Wno-unknown-warning-option -Wno-unused-lambda-capture")
360363
endif()
361364
endif()
362365

renderdoc/android/android.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ struct AndroidRemoteServer : public RemoteServer
439439
{
440440
}
441441

442-
virtual ~AndroidRemoteServer()
442+
virtual ~AndroidRemoteServer() override
443443
{
444444
if(m_LogcatThread)
445445
m_LogcatThread->Finish();

renderdoc/android/jdwp.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ void InjectVulkanLayerSearchPath(Connection &conn, threadID thread, int32_t slot
4242

4343
if(!stringClass || !stringConcat)
4444
{
45-
RDCERR("Couldn't find java.lang.String (%llu) or java.lang.String.concat() (%llu)", stringClass,
46-
stringConcat);
45+
RDCERR("Couldn't find java.lang.String (%llu) or java.lang.String.concat() (%llu)",
46+
(uint64_t)stringClass, (uint64_t)stringConcat);
4747
return;
4848
}
4949

@@ -247,8 +247,8 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock)
247247
// (re-suspended) when the first event occurs that matches the filter function
248248
Event evData =
249249
conn.WaitForEvent(EventKind::MethodEntry, {{ModifierKind::ClassOnly, vulkanLoaderClass}},
250-
[vulkanLoaderMethod](const Event &evData) {
251-
return evData.MethodEntry.location.meth == vulkanLoaderMethod;
250+
[vulkanLoaderMethod](const Event &ev) {
251+
return ev.MethodEntry.location.meth == vulkanLoaderMethod;
252252
});
253253

254254
// if we successfully hit the event, try to inject
@@ -290,10 +290,9 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock)
290290

291291
// wait until we hit the constructor of android.app.Application
292292
{
293-
Event evData = conn.WaitForEvent(EventKind::MethodEntry, {{ModifierKind::ClassOnly, androidApp}},
294-
[appConstruct](const Event &evData) {
295-
return evData.MethodEntry.location.meth == appConstruct;
296-
});
293+
Event evData = conn.WaitForEvent(
294+
EventKind::MethodEntry, {{ModifierKind::ClassOnly, androidApp}},
295+
[appConstruct](const Event &ev) { return ev.MethodEntry.location.meth == appConstruct; });
297296

298297
if(evData.eventKind == EventKind::MethodEntry)
299298
thread = evData.MethodEntry.thread;
@@ -371,11 +370,9 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock)
371370
{
372371
thread = 0;
373372

374-
Event evData =
375-
conn.WaitForEvent(EventKind::MethodEntry, {{ModifierKind::ClassOnly, onCreateClass}},
376-
[onCreateMethod](const Event &evData) {
377-
return evData.MethodEntry.location.meth == onCreateMethod;
378-
});
373+
Event evData = conn.WaitForEvent(
374+
EventKind::MethodEntry, {{ModifierKind::ClassOnly, onCreateClass}},
375+
[onCreateMethod](const Event &ev) { return ev.MethodEntry.location.meth == onCreateMethod; });
379376

380377
if(evData.eventKind == EventKind::MethodEntry)
381378
thread = evData.MethodEntry.thread;
@@ -403,7 +400,7 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock)
403400
if(getRuntime == 0 || load == 0)
404401
{
405402
RDCERR("Couldn't find java.lang.Runtime.getRuntime() %llu or java.lang.Runtime.load() %llu",
406-
getRuntime, load);
403+
(uint64_t)getRuntime, (uint64_t)load);
407404
return false;
408405
}
409406

renderdoc/android/jdwp_connection.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ std::vector<VariableSlot> Connection::GetLocalVariables(referenceTypeID type, me
280280

281281
CommandData data = cmd.GetData();
282282
data.Read(argumentCount); // unused for now
283-
ReadVector<VariableSlot>(data, slots, [](CommandData &data, VariableSlot &s) {
284-
data.Read(s.codeIndex).Read(s.name).Read(s.signature).Read(s.length).Read(s.slot);
283+
ReadVector<VariableSlot>(data, slots, [](CommandData &d, VariableSlot &s) {
284+
d.Read(s.codeIndex).Read(s.name).Read(s.signature).Read(s.length).Read(s.slot);
285285
});
286286
data.Done();
287287

@@ -299,8 +299,8 @@ fieldID Connection::GetField(referenceTypeID type, const std::string &name,
299299

300300
std::vector<Field> fields;
301301
CommandData data = cmd.GetData();
302-
ReadVector<Field>(data, fields, [](CommandData &data, Field &f) {
303-
data.Read(f.id).Read(f.name).Read(f.signature).Read(f.modBits);
302+
ReadVector<Field>(data, fields, [](CommandData &d, Field &f) {
303+
d.Read(f.id).Read(f.name).Read(f.signature).Read(f.modBits);
304304
});
305305
data.Done();
306306

@@ -341,8 +341,8 @@ std::vector<StackFrame> Connection::GetCallStack(threadID thread)
341341

342342
std::vector<StackFrame> ret;
343343
CommandData data = cmd.GetData();
344-
ReadVector<StackFrame>(
345-
data, ret, [](CommandData &data, StackFrame &f) { data.Read(f.id).Read(f.location); });
344+
ReadVector<StackFrame>(data, ret,
345+
[](CommandData &d, StackFrame &f) { d.Read(f.id).Read(f.location); });
346346
data.Done();
347347

348348
// simplify error handling, if the stack came back as nonsense then clear it
@@ -401,10 +401,10 @@ Event Connection::WaitForEvent(EventKind kind, const std::vector<EventFilter> &e
401401
// always suspend all threads
402402
data.Write((byte)kind).Write((byte)SuspendPolicy::All);
403403

404-
WriteVector<EventFilter>(data, eventFilters, [](CommandData &data, const EventFilter &f) {
405-
data.Write((byte)f.modKind);
404+
WriteVector<EventFilter>(data, eventFilters, [](CommandData &d, const EventFilter &f) {
405+
d.Write((byte)f.modKind);
406406
if(f.modKind == ModifierKind::ClassOnly)
407-
data.Write(f.ClassOnly);
407+
d.Write(f.ClassOnly);
408408
else
409409
RDCERR("Unsupported event filter %d", f.modKind);
410410
});
@@ -444,7 +444,7 @@ Event Connection::WaitForEvent(EventKind kind, const std::vector<EventFilter> &e
444444
CommandData data = msg.GetData();
445445

446446
data.Read((byte &)suspendPolicy);
447-
ReadVector<Event>(data, events, [this](CommandData &data, Event &ev) { ReadEvent(data, ev); });
447+
ReadVector<Event>(data, events, [this](CommandData &d, Event &ev) { ReadEvent(d, ev); });
448448
data.Done();
449449

450450
// event arrived, we're now suspended
@@ -540,7 +540,7 @@ value Connection::InvokeInstance(threadID thread, classID clazz, methodID method
540540
data.Write(object).Write(thread).Write(clazz).Write(method);
541541
}
542542

543-
WriteVector<value>(data, arguments, [](CommandData &data, const value &v) { data.Write(v); });
543+
WriteVector<value>(data, arguments, [](CommandData &d, const value &v) { d.Write(v); });
544544

545545
data.Write((int32_t)options);
546546

@@ -610,8 +610,8 @@ std::vector<Method> Connection::GetMethods(referenceTypeID searchClass)
610610

611611
std::vector<Method> ret;
612612
CommandData data = cmd.GetData();
613-
ReadVector<Method>(data, ret, [](CommandData &data, Method &m) {
614-
data.Read(m.id).Read(m.name).Read(m.signature).Read(m.modBits);
613+
ReadVector<Method>(data, ret, [](CommandData &d, Method &m) {
614+
d.Read(m.id).Read(m.name).Read(m.signature).Read(m.modBits);
615615
});
616616
data.Done();
617617
return ret;

renderdoc/api/replay/basic_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,12 @@ struct rdcarray
293293
#endif
294294
return ret;
295295
}
296-
static void deallocate(const T *p)
296+
static void deallocate(T *p)
297297
{
298298
#ifdef RENDERDOC_EXPORTS
299299
free((void *)p);
300300
#else
301-
RENDERDOC_FreeArrayMem((const void *)p);
301+
RENDERDOC_FreeArrayMem((void *)p);
302302
#endif
303303
}
304304

renderdoc/api/replay/capture_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct CaptureOptions
4848
{
4949
rdcstr optstr;
5050
optstr.reserve(sizeof(CaptureOptions) * 2 + 1);
51-
byte *b = (byte *)this;
51+
const byte *b = (const byte *)this;
5252
for(size_t i = 0; i < sizeof(CaptureOptions); i++)
5353
{
5454
optstr.push_back(char('a' + ((b[i] >> 4) & 0xf)));
@@ -67,7 +67,7 @@ struct CaptureOptions
6767
// serialise from string with two chars per byte
6868
byte *b = (byte *)this;
6969
for(size_t i = 0; i < sizeof(CaptureOptions); i++)
70-
*(b++) = (byte(str[i * 2 + 0] - 'a') << 4) | byte(str[i * 2 + 1] - 'a');
70+
*(b++) = byte(((byte(str[i * 2 + 0] - 'a') & 0xf) << 4) | (byte(str[i * 2 + 1] - 'a') & 0xf));
7171
}
7272

7373
DOCUMENT(R"(Allow the application to enable vsync.

renderdoc/api/replay/common_pipestate.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct Viewport
3636
{
3737
}
3838
Viewport(const Viewport &) = default;
39+
Viewport &operator=(const Viewport &) = default;
3940

4041
bool operator==(const Viewport &o) const
4142
{
@@ -86,6 +87,7 @@ struct Scissor
8687
{
8788
}
8889
Scissor(const Scissor &) = default;
90+
Scissor &operator=(const Scissor &) = default;
8991

9092
bool operator==(const Scissor &o) const
9193
{
@@ -125,6 +127,7 @@ struct BlendEquation
125127
DOCUMENT("");
126128
BlendEquation() = default;
127129
BlendEquation(const BlendEquation &) = default;
130+
BlendEquation &operator=(const BlendEquation &) = default;
128131

129132
bool operator==(const BlendEquation &o) const
130133
{
@@ -156,6 +159,7 @@ struct ColorBlend
156159
DOCUMENT("");
157160
ColorBlend() = default;
158161
ColorBlend(const ColorBlend &) = default;
162+
ColorBlend &operator=(const ColorBlend &) = default;
159163

160164
bool operator==(const ColorBlend &o) const
161165
{
@@ -206,6 +210,7 @@ struct StencilFace
206210
DOCUMENT("");
207211
StencilFace() = default;
208212
StencilFace(const StencilFace &) = default;
213+
StencilFace &operator=(const StencilFace &) = default;
209214

210215
DOCUMENT("The :class:`StencilOperation` to apply if the stencil-test fails.");
211216
StencilOperation failOperation = StencilOperation::Keep;
@@ -246,6 +251,7 @@ struct BoundResource
246251
typeCast = CompType::Typeless;
247252
}
248253
BoundResource(const BoundResource &) = default;
254+
BoundResource &operator=(const BoundResource &) = default;
249255

250256
bool operator==(const BoundResource &o) const
251257
{
@@ -292,6 +298,7 @@ struct BoundResourceArray
292298
DOCUMENT("");
293299
BoundResourceArray() = default;
294300
BoundResourceArray(const BoundResourceArray &) = default;
301+
BoundResourceArray &operator=(const BoundResourceArray &) = default;
295302
BoundResourceArray(Bindpoint b) : bindPoint(b) {}
296303
BoundResourceArray(Bindpoint b, const rdcarray<BoundResource> &r) : bindPoint(b), resources(r)
297304
{
@@ -323,6 +330,7 @@ struct BoundVBuffer
323330
DOCUMENT("");
324331
BoundVBuffer() = default;
325332
BoundVBuffer(const BoundVBuffer &) = default;
333+
BoundVBuffer &operator=(const BoundVBuffer &) = default;
326334

327335
bool operator==(const BoundVBuffer &o) const
328336
{
@@ -354,6 +362,7 @@ struct BoundCBuffer
354362
DOCUMENT("");
355363
BoundCBuffer() = default;
356364
BoundCBuffer(const BoundCBuffer &) = default;
365+
BoundCBuffer &operator=(const BoundCBuffer &) = default;
357366

358367
DOCUMENT("A :class:`~renderdoc.ResourceId` identifying the buffer.");
359368
ResourceId resourceId;
@@ -371,6 +380,7 @@ struct VertexInputAttribute
371380
DOCUMENT("");
372381
VertexInputAttribute() = default;
373382
VertexInputAttribute(const VertexInputAttribute &) = default;
383+
VertexInputAttribute &operator=(const VertexInputAttribute &) = default;
374384

375385
bool operator==(const VertexInputAttribute &o) const
376386
{

0 commit comments

Comments
 (0)