Fixed strict aliasing warning

Summary:
Use `noquote` method instead of relying on undefined behaviour. This fixes a warning in GCC 6.3.

`noquote` method was added in Qt 5.4.

Reviewers: #swift_pilot_client, kbasan

Reviewed By: kbasan

Subscribers: jenkins

Tags: #swift_pilot_client

Differential Revision: https://dev.swift-project.org/D26
This commit is contained in:
Mathew Sutcliffe
2017-06-23 18:17:55 +01:00
parent 87aa25a351
commit de5cb56525

View File

@@ -30,14 +30,7 @@ namespace BlackMisc
CLogMessage::~CLogMessage()
{
// ostream(encodedCategory()) << message(); // QDebug::operator<<(QString) puts quote characters around the message
// hack to avoid putting quote characters around the message
// should be safe, we could directly call qt_message_output instead, but it's undocumented
QByteArray category = qtCategory();
QDebug debug = ostream(category);
auto &stream = **reinterpret_cast<QTextStream **>(&debug); // should be safe because it is relying on Qt's guarantee of ABI compatibility
stream << message();
ostream(qtCategory()).noquote() << message();
}
QByteArray CLogMessage::qtCategory() const