1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[llvm-cov gcov] Change case to match the prevailing style && replace getString with readString

This commit is contained in:
Fangrui Song 2021-06-19 22:02:14 -07:00
parent 8a7045847f
commit f02bea7812
2 changed files with 37 additions and 34 deletions

View File

@ -190,7 +190,7 @@ public:
bool readGCNO(GCOVBuffer &Buffer);
bool readGCDA(GCOVBuffer &Buffer);
GCOV::GCOVVersion getVersion() const { return Version; }
GCOV::GCOVVersion getVersion() const { return version; }
void print(raw_ostream &OS) const;
void dump() const;
@ -199,13 +199,13 @@ public:
public:
bool GCNOInitialized = false;
GCOV::GCOVVersion Version;
uint32_t Checksum = 0;
GCOV::GCOVVersion version;
uint32_t checksum = 0;
StringRef cwd;
SmallVector<std::unique_ptr<GCOVFunction>, 16> functions;
std::map<uint32_t, GCOVFunction *> IdentToFunction;
uint32_t RunCount = 0;
uint32_t ProgramCount = 0;
std::map<uint32_t, GCOVFunction *> identToFunction;
uint32_t runCount = 0;
uint32_t programCount = 0;
using iterator = pointee_iterator<
SmallVectorImpl<std::unique_ptr<GCOVFunction>>::const_iterator>;

View File

@ -101,13 +101,13 @@ private:
bool GCOVFile::readGCNO(GCOVBuffer &buf) {
if (!buf.readGCNOFormat())
return false;
if (!buf.readGCOVVersion(Version))
if (!buf.readGCOVVersion(version))
return false;
Checksum = buf.getWord();
if (Version >= GCOV::V900)
cwd = buf.getString();
if (Version >= GCOV::V800)
checksum = buf.getWord();
if (version >= GCOV::V900 && !buf.readString(cwd))
return false;
if (version >= GCOV::V800)
buf.getWord(); // hasUnexecutedBlocks
uint32_t tag, length;
@ -120,29 +120,31 @@ bool GCOVFile::readGCNO(GCOVBuffer &buf) {
fn = functions.back().get();
fn->ident = buf.getWord();
fn->linenoChecksum = buf.getWord();
if (Version >= GCOV::V407)
if (version >= GCOV::V407)
fn->cfgChecksum = buf.getWord();
buf.readString(fn->Name);
StringRef filename;
if (Version < GCOV::V800) {
filename = buf.getString();
if (version < GCOV::V800) {
if (!buf.readString(filename))
return false;
fn->startLine = buf.getWord();
} else {
fn->artificial = buf.getWord();
filename = buf.getString();
if (!buf.readString(filename))
return false;
fn->startLine = buf.getWord();
fn->startColumn = buf.getWord();
fn->endLine = buf.getWord();
if (Version >= GCOV::V900)
if (version >= GCOV::V900)
fn->endColumn = buf.getWord();
}
auto r = filenameToIdx.try_emplace(filename, filenameToIdx.size());
if (r.second)
filenames.emplace_back(filename);
fn->srcIdx = r.first->second;
IdentToFunction[fn->ident] = fn;
identToFunction[fn->ident] = fn;
} else if (tag == GCOV_TAG_BLOCKS && fn) {
if (Version < GCOV::V800) {
if (version < GCOV::V800) {
for (uint32_t i = 0; i != length; ++i) {
buf.getWord(); // Ignored block flags
fn->blocks.push_back(std::make_unique<GCOVBlock>(i));
@ -184,7 +186,8 @@ bool GCOVFile::readGCNO(GCOVBuffer &buf) {
if (line)
Block.addLine(line);
else {
StringRef filename = buf.getString();
StringRef filename;
buf.readString(filename);
if (filename.empty())
break;
// TODO Unhandled
@ -206,7 +209,7 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
GCOV::GCOVVersion GCDAVersion;
if (!buf.readGCOVVersion(GCDAVersion))
return false;
if (Version != GCDAVersion) {
if (version != GCDAVersion) {
errs() << "GCOV versions do not match.\n";
return false;
}
@ -214,9 +217,9 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
uint32_t GCDAChecksum;
if (!buf.readInt(GCDAChecksum))
return false;
if (Checksum != GCDAChecksum) {
errs() << "File checksums do not match: " << Checksum
<< " != " << GCDAChecksum << ".\n";
if (checksum != GCDAChecksum) {
errs() << "file checksums do not match: " << checksum
<< " != " << GCDAChecksum << "\n";
return false;
}
uint32_t dummy, tag, length;
@ -227,19 +230,19 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
return false;
uint32_t pos = buf.cursor.tell();
if (tag == GCOV_TAG_OBJECT_SUMMARY) {
buf.readInt(RunCount);
buf.readInt(runCount);
buf.readInt(dummy);
// clang<11 uses a fake 4.2 format which sets length to 9.
if (length == 9)
buf.readInt(RunCount);
buf.readInt(runCount);
} else if (tag == GCOV_TAG_PROGRAM_SUMMARY) {
// clang<11 uses a fake 4.2 format which sets length to 0.
if (length > 0) {
buf.readInt(dummy);
buf.readInt(dummy);
buf.readInt(RunCount);
buf.readInt(runCount);
}
++ProgramCount;
++programCount;
} else if (tag == GCOV_TAG_FUNCTION) {
if (length == 0) // Placeholder
continue;
@ -248,12 +251,12 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
// than 3.
if (length < 2 || !buf.readInt(ident))
return false;
auto It = IdentToFunction.find(ident);
auto It = identToFunction.find(ident);
uint32_t linenoChecksum, cfgChecksum = 0;
buf.readInt(linenoChecksum);
if (Version >= GCOV::V407)
if (version >= GCOV::V407)
buf.readInt(cfgChecksum);
if (It != IdentToFunction.end()) {
if (It != identToFunction.end()) {
fn = It->second;
if (linenoChecksum != fn->linenoChecksum ||
cfgChecksum != fn->cfgChecksum) {
@ -281,7 +284,7 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
if (fn->blocks.size() >= 2) {
GCOVBlock &src = *fn->blocks[0];
GCOVBlock &sink =
Version < GCOV::V408 ? *fn->blocks.back() : *fn->blocks[1];
version < GCOV::V408 ? *fn->blocks.back() : *fn->blocks[1];
auto arc = std::make_unique<GCOVArc>(sink, src, GCOV_ARC_ON_TREE);
sink.addDstEdge(arc.get());
src.addSrcEdge(arc.get());
@ -735,9 +738,9 @@ void Context::annotateSource(SourceInfo &si, const GCOVFile &file,
os << " -: 0:Source:" << si.displayName << '\n';
os << " -: 0:Graph:" << gcno << '\n';
os << " -: 0:Data:" << gcda << '\n';
os << " -: 0:Runs:" << file.RunCount << '\n';
if (file.Version < GCOV::V900)
os << " -: 0:Programs:" << file.ProgramCount << '\n';
os << " -: 0:Runs:" << file.runCount << '\n';
if (file.version < GCOV::V900)
os << " -: 0:Programs:" << file.programCount << '\n';
for (size_t lineNum = 1; !source.empty(); ++lineNum) {
if (lineNum >= si.lines.size()) {