Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit ea325f9

Browse files
committed
Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"
This reverts commit f6777964bde28c349d3e289ea37ecf5f5eeedbc4. Because the absolute path check relies on temporary path containing "clang", "test" and "CoverageMapping" as a subsequence, which is not necessarily true on all systems(breaks internal integrates). Wanted to fix it by checking for a leading "/" instead, but then noticed that it would break windows tests, so leaving it to the author instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374324 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a579abf commit ea325f9

File tree

3 files changed

+9
-40
lines changed

3 files changed

+9
-40
lines changed

lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,13 @@ std::string getCoverageSection(const CodeGenModule &CGM) {
12781278
CGM.getContext().getTargetInfo().getTriple().getObjectFormat());
12791279
}
12801280

1281+
std::string normalizeFilename(StringRef Filename) {
1282+
llvm::SmallString<256> Path(Filename);
1283+
llvm::sys::fs::make_absolute(Path);
1284+
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
1285+
return Path.str().str();
1286+
}
1287+
12811288
} // end anonymous namespace
12821289

12831290
static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
@@ -1310,24 +1317,6 @@ static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
13101317
}
13111318
}
13121319

1313-
CoverageMappingModuleGen::CoverageMappingModuleGen(
1314-
CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
1315-
: CGM(CGM), SourceInfo(SourceInfo), FunctionRecordTy(nullptr) {
1316-
// Honor -fdebug-compilation-dir in paths in coverage data. Otherwise, use the
1317-
// regular working directory when normalizing paths.
1318-
if (!CGM.getCodeGenOpts().DebugCompilationDir.empty())
1319-
CWD = CGM.getCodeGenOpts().DebugCompilationDir;
1320-
else
1321-
llvm::sys::fs::current_path(CWD);
1322-
}
1323-
1324-
std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
1325-
llvm::SmallString<256> Path(Filename);
1326-
llvm::sys::fs::make_absolute(CWD, Path);
1327-
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
1328-
return Path.str().str();
1329-
}
1330-
13311320
void CoverageMappingModuleGen::addFunctionMappingRecord(
13321321
llvm::GlobalVariable *NamePtr, StringRef NameValue, uint64_t FuncHash,
13331322
const std::string &CoverageMapping, bool IsUsed) {

lib/CodeGen/CoverageMappingGen.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,10 @@ class CoverageMappingModuleGen {
5454
std::vector<llvm::Constant *> FunctionNames;
5555
llvm::StructType *FunctionRecordTy;
5656
std::vector<std::string> CoverageMappings;
57-
SmallString<256> CWD;
58-
59-
/// Make the filename absolute, remove dots, and normalize slashes to local
60-
/// path style.
61-
std::string normalizeFilename(StringRef Filename);
6257

6358
public:
64-
CoverageMappingModuleGen(CodeGenModule &CGM, CoverageSourceInfo &SourceInfo);
59+
CoverageMappingModuleGen(CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
60+
: CGM(CGM), SourceInfo(SourceInfo), FunctionRecordTy(nullptr) {}
6561

6662
CoverageSourceInfo &getSourceInfo() const {
6763
return SourceInfo;

test/CoverageMapping/debug-dir.cpp

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)