return SP->getName();
}
+template<class DINode> SmallString<128> getFilename(const DINode *N) {
+ SmallString<128> Path;
+ sys::path::append(Path, N->getDirectory(), N->getFilename());
+ return Path;
+}
+
namespace {
class GCOVRecord {
protected:
}
private:
- StringRef Filename;
+ std::string Filename;
SmallVector<uint32_t, 32> Lines;
};
void writeOut() {
writeBytes(FunctionTag, 4);
+ SmallString<128> Filename = getFilename(SP);
uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(getFunctionName(SP)) +
- 1 + lengthOfGCOVString(SP->getFilename()) + 1;
+ 1 + lengthOfGCOVString(Filename) + 1;
if (UseCfgChecksum)
++BlockLen;
write(BlockLen);
if (UseCfgChecksum)
write(CfgChecksum);
writeGCOVString(getFunctionName(SP));
- writeGCOVString(SP->getFilename());
+ writeGCOVString(Filename);
write(SP->getLine());
// Emit count of blocks.
if (FilterRe.empty() && ExcludeRe.empty()) {
return true;
}
- const StringRef Filename = F.getSubprogram()->getFilename();
+ SmallString<128> Filename = getFilename(F.getSubprogram());
auto It = InstrumentedFiles.find(Filename);
if (It != InstrumentedFiles.end()) {
return It->second;
}
}
- SmallString<128> Filename = CU->getFilename();
+ SmallString<128> Filename = getFilename(CU);
sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");
StringRef FName = sys::path::filename(Filename);
SmallString<128> CurPath;
// Add the function line number to the lines of the entry block
// to have a counter for the function definition.
uint32_t Line = SP->getLine();
- Func.getBlock(&EntryBlock).getFile(SP->getFilename()).addLine(Line);
+ auto Filename = getFilename(SP);
+ Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
for (auto &BB : F) {
GCOVBlock &Block = Func.getBlock(&BB);
if (SP != getDISubprogram(Loc.getScope()))
continue;
- GCOVLines &Lines = Block.getFile(SP->getFilename());
+ GCOVLines &Lines = Block.getFile(Filename);
Lines.addLine(Loc.getLine());
}
Line = 0;