forked from qt-creator/qt-creator
Clang: Fix aliasing
Task-number: QTCREATORBUG-15888 Change-Id: I0f2e28e9e0da53481c03707ab0a9abf728c7419f Reviewed-by: hjk <hjk@theqtcompany.com> Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
enum class DiagnosticSeverity // one to one mapping of the clang enum numbers
|
enum class DiagnosticSeverity : quint32 // one to one mapping of the clang enum numbers
|
||||||
{
|
{
|
||||||
Ignored = 0,
|
Ignored = 0,
|
||||||
Note = 1,
|
Note = 1,
|
||||||
@@ -75,7 +75,7 @@ enum class HighlightingType : quint8
|
|||||||
Declaration
|
Declaration
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class CompletionCorrection
|
enum class CompletionCorrection : quint32
|
||||||
{
|
{
|
||||||
NoCorrection,
|
NoCorrection,
|
||||||
DotToArrowCorrection
|
DotToArrowCorrection
|
||||||
|
@@ -56,15 +56,10 @@ quint64 CodeCompletedMessage::ticketNumber() const
|
|||||||
return ticketNumber_;
|
return ticketNumber_;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 &CodeCompletedMessage::neededCorrectionAsInt()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<quint32&>(neededCorrection_);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message)
|
QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message)
|
||||||
{
|
{
|
||||||
out << message.codeCompletions_;
|
out << message.codeCompletions_;
|
||||||
out << quint32(message.neededCorrection_);
|
out << static_cast<quint32>(message.neededCorrection_);
|
||||||
out << message.ticketNumber_;
|
out << message.ticketNumber_;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -72,10 +67,14 @@ QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message)
|
|||||||
|
|
||||||
QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message)
|
QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message)
|
||||||
{
|
{
|
||||||
|
quint32 neededCorrection;
|
||||||
|
|
||||||
in >> message.codeCompletions_;
|
in >> message.codeCompletions_;
|
||||||
in >> message.neededCorrectionAsInt();
|
in >> neededCorrection;
|
||||||
in >> message.ticketNumber_;
|
in >> message.ticketNumber_;
|
||||||
|
|
||||||
|
message.neededCorrection_ = static_cast<CompletionCorrection>(neededCorrection);
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,9 +49,6 @@ public:
|
|||||||
|
|
||||||
quint64 ticketNumber() const;
|
quint64 ticketNumber() const;
|
||||||
|
|
||||||
private:
|
|
||||||
quint32 &neededCorrectionAsInt();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CodeCompletions codeCompletions_;
|
CodeCompletions codeCompletions_;
|
||||||
quint64 ticketNumber_ = 0;
|
quint64 ticketNumber_ = 0;
|
||||||
|
@@ -115,24 +115,14 @@ const Utf8String &CodeCompletion::briefComment() const
|
|||||||
return briefComment_;
|
return briefComment_;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 &CodeCompletion::completionKindAsInt()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<quint32&>(completionKind_);
|
|
||||||
}
|
|
||||||
|
|
||||||
quint32 &CodeCompletion::availabilityAsInt()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<quint32&>(availability_);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
|
QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
|
||||||
{
|
{
|
||||||
out << message.text_;
|
out << message.text_;
|
||||||
out << message.briefComment_;
|
out << message.briefComment_;
|
||||||
out << message.chunks_;
|
out << message.chunks_;
|
||||||
out << message.priority_;
|
out << message.priority_;
|
||||||
out << message.completionKind_;
|
out << static_cast<quint32>(message.completionKind_);
|
||||||
out << message.availability_;
|
out << static_cast<quint32>(message.availability_);
|
||||||
out << message.hasParameters_;
|
out << message.hasParameters_;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -140,14 +130,20 @@ QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
|
|||||||
|
|
||||||
QDataStream &operator>>(QDataStream &in, CodeCompletion &message)
|
QDataStream &operator>>(QDataStream &in, CodeCompletion &message)
|
||||||
{
|
{
|
||||||
|
quint32 completionKind;
|
||||||
|
quint32 availability;
|
||||||
|
|
||||||
in >> message.text_;
|
in >> message.text_;
|
||||||
in >> message.briefComment_;
|
in >> message.briefComment_;
|
||||||
in >> message.chunks_;
|
in >> message.chunks_;
|
||||||
in >> message.priority_;
|
in >> message.priority_;
|
||||||
in >> message.completionKindAsInt();
|
in >> completionKind;
|
||||||
in >> message.availabilityAsInt();
|
in >> availability;
|
||||||
in >> message.hasParameters_;
|
in >> message.hasParameters_;
|
||||||
|
|
||||||
|
message.completionKind_ = static_cast<CodeCompletion::Kind>(completionKind);
|
||||||
|
message.availability_ = static_cast<CodeCompletion::Availability>(availability);
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -103,10 +103,6 @@ public:
|
|||||||
void setBriefComment(const Utf8String &briefComment);
|
void setBriefComment(const Utf8String &briefComment);
|
||||||
const Utf8String &briefComment() const;
|
const Utf8String &briefComment() const;
|
||||||
|
|
||||||
private:
|
|
||||||
quint32 &completionKindAsInt();
|
|
||||||
quint32 &availabilityAsInt();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utf8String text_;
|
Utf8String text_;
|
||||||
Utf8String briefComment_;
|
Utf8String briefComment_;
|
||||||
|
@@ -56,14 +56,9 @@ bool CodeCompletionChunk::isOptional() const
|
|||||||
return isOptional_;
|
return isOptional_;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint8 &CodeCompletionChunk::kindAsInt()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<quint8&>(kind_);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
|
QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
|
||||||
{
|
{
|
||||||
out << quint8(chunk.kind_);
|
out << static_cast<quint8>(chunk.kind_);
|
||||||
out << chunk.text_;
|
out << chunk.text_;
|
||||||
out << chunk.isOptional_;
|
out << chunk.isOptional_;
|
||||||
|
|
||||||
@@ -72,10 +67,14 @@ QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
|
|||||||
|
|
||||||
QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk)
|
QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk)
|
||||||
{
|
{
|
||||||
in >> chunk.kindAsInt();
|
quint8 kind;
|
||||||
|
|
||||||
|
in >> kind;
|
||||||
in >> chunk.text_;
|
in >> chunk.text_;
|
||||||
in >> chunk.isOptional_;
|
in >> chunk.isOptional_;
|
||||||
|
|
||||||
|
chunk.kind_ = static_cast<CodeCompletionChunk::Kind>(kind);
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -77,9 +77,6 @@ public:
|
|||||||
const Utf8String &text() const;
|
const Utf8String &text() const;
|
||||||
bool isOptional() const;
|
bool isOptional() const;
|
||||||
|
|
||||||
private:
|
|
||||||
quint8 &kindAsInt();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utf8String text_;
|
Utf8String text_;
|
||||||
Kind kind_ = Invalid;
|
Kind kind_ = Invalid;
|
||||||
|
@@ -97,11 +97,6 @@ const QVector<DiagnosticContainer> &DiagnosticContainer::children() const
|
|||||||
return children_;
|
return children_;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 &DiagnosticContainer::severityAsInt()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<quint32&>(severity_);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
|
QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
|
||||||
{
|
{
|
||||||
out << container.text_;
|
out << container.text_;
|
||||||
@@ -109,7 +104,7 @@ QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
|
|||||||
out << container.enableOption_;
|
out << container.enableOption_;
|
||||||
out << container.disableOption_;
|
out << container.disableOption_;
|
||||||
out << container.location_;
|
out << container.location_;
|
||||||
out << quint32(container.severity_);
|
out << static_cast<quint32>(container.severity_);
|
||||||
out << container.ranges_;
|
out << container.ranges_;
|
||||||
out << container.fixIts_;
|
out << container.fixIts_;
|
||||||
out << container.children_;
|
out << container.children_;
|
||||||
@@ -119,16 +114,20 @@ QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
|
|||||||
|
|
||||||
QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container)
|
QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container)
|
||||||
{
|
{
|
||||||
|
quint32 severity;
|
||||||
|
|
||||||
in >> container.text_;
|
in >> container.text_;
|
||||||
in >> container.category_;
|
in >> container.category_;
|
||||||
in >> container.enableOption_;
|
in >> container.enableOption_;
|
||||||
in >> container.disableOption_;
|
in >> container.disableOption_;
|
||||||
in >> container.location_;
|
in >> container.location_;
|
||||||
in >> container.severityAsInt();
|
in >> severity;
|
||||||
in >> container.ranges_;
|
in >> container.ranges_;
|
||||||
in >> container.fixIts_;
|
in >> container.fixIts_;
|
||||||
in >> container.children_;
|
in >> container.children_;
|
||||||
|
|
||||||
|
container.severity_ = static_cast<DiagnosticSeverity>(severity);
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,9 +61,6 @@ public:
|
|||||||
const QVector<FixItContainer> &fixIts() const;
|
const QVector<FixItContainer> &fixIts() const;
|
||||||
const QVector<DiagnosticContainer> &children() const;
|
const QVector<DiagnosticContainer> &children() const;
|
||||||
|
|
||||||
private:
|
|
||||||
quint32 &severityAsInt();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SourceLocationContainer location_;
|
SourceLocationContainer location_;
|
||||||
QVector<SourceRangeContainer> ranges_;
|
QVector<SourceRangeContainer> ranges_;
|
||||||
|
@@ -74,14 +74,21 @@ HighlightingTypes HighlightingMarkContainer::types() const
|
|||||||
return types_;
|
return types_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, HighlightingType highlightingType)
|
||||||
|
{
|
||||||
|
out << static_cast<const quint8>(highlightingType);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, HighlightingTypes highlightingTypes)
|
QDataStream &operator<<(QDataStream &out, HighlightingTypes highlightingTypes)
|
||||||
{
|
{
|
||||||
out << reinterpret_cast<const quint8&>(highlightingTypes.mainHighlightingType);
|
out << highlightingTypes.mainHighlightingType;
|
||||||
|
|
||||||
out << highlightingTypes.mixinHighlightingTypes.size();
|
out << highlightingTypes.mixinHighlightingTypes.size();
|
||||||
|
|
||||||
for (HighlightingType type : highlightingTypes.mixinHighlightingTypes)
|
for (HighlightingType type : highlightingTypes.mixinHighlightingTypes)
|
||||||
out << reinterpret_cast<const quint8&>(type);
|
out << type;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -96,16 +103,27 @@ QDataStream &operator<<(QDataStream &out, const HighlightingMarkContainer &conta
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, HighlightingType &highlightingType)
|
||||||
|
{
|
||||||
|
quint8 highlightingTypeInt;
|
||||||
|
|
||||||
|
in >> highlightingTypeInt;
|
||||||
|
|
||||||
|
highlightingType = static_cast<HighlightingType>(highlightingTypeInt);
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingTypes)
|
QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingTypes)
|
||||||
{
|
{
|
||||||
in >> reinterpret_cast<quint8&>(highlightingTypes.mainHighlightingType);
|
in >> highlightingTypes.mainHighlightingType ;
|
||||||
|
|
||||||
quint8 size;
|
quint8 size;
|
||||||
in >> size;
|
in >> size;
|
||||||
|
|
||||||
for (int counter = 0; counter < size; ++counter) {
|
for (int counter = 0; counter < size; ++counter) {
|
||||||
HighlightingType type;
|
HighlightingType type;
|
||||||
in >> reinterpret_cast<quint8&>(type);
|
in >> type;
|
||||||
highlightingTypes.mixinHighlightingTypes.push_back(type);
|
highlightingTypes.mixinHighlightingTypes.push_back(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
friend
|
friend
|
||||||
QDataStream &operator<<(QDataStream &out, const MessageEnvelop &messageEnvelop)
|
QDataStream &operator<<(QDataStream &out, const MessageEnvelop &messageEnvelop)
|
||||||
{
|
{
|
||||||
out << reinterpret_cast<const quint8&>(messageEnvelop.messageType_);
|
out << static_cast<const quint8>(messageEnvelop.messageType_);
|
||||||
out << messageEnvelop.data;
|
out << messageEnvelop.data;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -88,9 +88,13 @@ public:
|
|||||||
friend
|
friend
|
||||||
QDataStream &operator>>(QDataStream &in, MessageEnvelop &messageEnvelop)
|
QDataStream &operator>>(QDataStream &in, MessageEnvelop &messageEnvelop)
|
||||||
{
|
{
|
||||||
in >> reinterpret_cast<quint8&>(messageEnvelop.messageType_);
|
quint8 messageType;
|
||||||
|
|
||||||
|
in >> messageType;
|
||||||
in >> messageEnvelop.data;
|
in >> messageEnvelop.data;
|
||||||
|
|
||||||
|
messageEnvelop.messageType_ = static_cast<MessageType>(messageType);
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user