Skip to content

Commit a3d5d16

Browse files
committed
When the path wasn't emitted by the frontend, discard any path on the source
filename. llvm-svn: 130897
1 parent 1d3854d commit a3d5d16

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,20 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) {
331331
for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
332332
MDNode *N = GCov->getOperand(i);
333333
if (N->getNumOperands() != 2) continue;
334-
MDString *Path = dyn_cast<MDString>(N->getOperand(0));
334+
MDString *GCovFile = dyn_cast<MDString>(N->getOperand(0));
335335
MDNode *CompileUnit = dyn_cast<MDNode>(N->getOperand(1));
336-
if (!Path || !CompileUnit) continue;
337-
if (CompileUnit == CU)
338-
return (Path->getString() + "/" +
339-
replaceStem(CU.getFilename(), NewStem)).str();
336+
if (!GCovFile || !CompileUnit) continue;
337+
if (CompileUnit == CU) {
338+
SmallString<128> Filename = GCovFile->getString();
339+
sys::path::replace_extension(Filename, NewStem);
340+
return Filename.str();
341+
}
340342
}
341343
}
342-
return replaceStem(CU.getFilename(), NewStem);
344+
345+
SmallString<128> Filename = CU.getFilename();
346+
sys::path::replace_extension(Filename, NewStem);
347+
return sys::path::filename(Filename.str());
343348
}
344349

345350
bool GCOVProfiler::runOnModule(Module &M) {

0 commit comments

Comments
 (0)