Fix some signed / unsigned conversion problems.

llvm-svn: 328881
This commit is contained in:
Zachary Turner 2018-03-30 17:28:35 +00:00
parent 5aab635e10
commit ce5b834abf
1 changed files with 15 additions and 13 deletions

View File

@ -339,15 +339,16 @@ static void explainSubstreamOffset(LinePrinter &P, uint32_t OffsetInStream,
const SubstreamRangeT &Substreams) { const SubstreamRangeT &Substreams) {
uint32_t SubOffset = OffsetInStream; uint32_t SubOffset = OffsetInStream;
for (const auto &Entry : Substreams) { for (const auto &Entry : Substreams) {
if (Entry.Size == 0) if (Entry.Size <= 0)
continue; continue;
if (SubOffset < Entry.Size) { uint32_t S = static_cast<uint32_t>(Entry.Size);
P.formatLine("address is at offset {0}/{1} of the {2}.", SubOffset, if (SubOffset < S) {
Entry.Size, Entry.Label); P.formatLine("address is at offset {0}/{1} of the {2}.", SubOffset, S,
Entry.Label);
Entry.Explain(P, Stream, SubOffset); Entry.Explain(P, Stream, SubOffset);
return; return;
} }
SubOffset -= Entry.Size; SubOffset -= S;
} }
} }
@ -360,22 +361,23 @@ void ExplainOutputStyle::explainDbiStream(uint32_t StreamIdx,
assert(Header != nullptr); assert(Header != nullptr);
struct SubstreamInfo { struct SubstreamInfo {
uint32_t Size; int32_t Size;
StringRef Label; StringRef Label;
void (*Explain)(LinePrinter &, DbiStream &, uint32_t); void (*Explain)(LinePrinter &, DbiStream &, uint32_t);
} Substreams[] = { } Substreams[] = {
{sizeof(DbiStreamHeader), "DBI Stream Header", explainDbiHeaderOffset}, {sizeof(DbiStreamHeader), "DBI Stream Header", explainDbiHeaderOffset},
{Header->ModiSubstreamSize, "Module Info Substream", {int32_t(Header->ModiSubstreamSize), "Module Info Substream",
explainDbiModiSubstreamOffset}, explainDbiModiSubstreamOffset},
{Header->SecContrSubstreamSize, "Section Contribution Substream", {int32_t(Header->SecContrSubstreamSize), "Section Contribution Substream",
dontExplain<DbiStream>}, dontExplain<DbiStream>},
{Header->SectionMapSize, "Section Map", dontExplain<DbiStream>}, {int32_t(Header->SectionMapSize), "Section Map", dontExplain<DbiStream>},
{Header->FileInfoSize, "File Info Substream", dontExplain<DbiStream>}, {int32_t(Header->FileInfoSize), "File Info Substream",
{Header->TypeServerSize, "Type Server Map Substream",
dontExplain<DbiStream>}, dontExplain<DbiStream>},
{Header->ECSubstreamSize, "Edit & Continue Substream", {int32_t(Header->TypeServerSize), "Type Server Map Substream",
dontExplain<DbiStream>}, dontExplain<DbiStream>},
{Header->OptionalDbgHdrSize, "Optional Debug Stream Array", {int32_t(Header->ECSubstreamSize), "Edit & Continue Substream",
dontExplain<DbiStream>},
{int32_t(Header->OptionalDbgHdrSize), "Optional Debug Stream Array",
dontExplain<DbiStream>}, dontExplain<DbiStream>},
}; };