r374324 - Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 05:20:12 PDT 2019
Author: kadircet
Date: Thu Oct 10 05:20:11 2019
New Revision: 374324
URL: http://llvm.org/viewvc/llvm-project?rev=374324&view=rev
Log:
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.
Removed:
cfe/trunk/test/CoverageMapping/debug-dir.cpp
Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.h
Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=374324&r1=374323&r2=374324&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Oct 10 05:20:11 2019
@@ -1278,6 +1278,13 @@ std::string getCoverageSection(const Cod
CGM.getContext().getTargetInfo().getTriple().getObjectFormat());
}
+std::string normalizeFilename(StringRef Filename) {
+ llvm::SmallString<256> Path(Filename);
+ llvm::sys::fs::make_absolute(Path);
+ llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+ return Path.str().str();
+}
+
} // end anonymous namespace
static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
@@ -1310,24 +1317,6 @@ static void dump(llvm::raw_ostream &OS,
}
}
-CoverageMappingModuleGen::CoverageMappingModuleGen(
- CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
- : CGM(CGM), SourceInfo(SourceInfo), FunctionRecordTy(nullptr) {
- // Honor -fdebug-compilation-dir in paths in coverage data. Otherwise, use the
- // regular working directory when normalizing paths.
- if (!CGM.getCodeGenOpts().DebugCompilationDir.empty())
- CWD = CGM.getCodeGenOpts().DebugCompilationDir;
- else
- llvm::sys::fs::current_path(CWD);
-}
-
-std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
- llvm::SmallString<256> Path(Filename);
- llvm::sys::fs::make_absolute(CWD, Path);
- llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
- return Path.str().str();
-}
-
void CoverageMappingModuleGen::addFunctionMappingRecord(
llvm::GlobalVariable *NamePtr, StringRef NameValue, uint64_t FuncHash,
const std::string &CoverageMapping, bool IsUsed) {
Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.h?rev=374324&r1=374323&r2=374324&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.h (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.h Thu Oct 10 05:20:11 2019
@@ -54,14 +54,10 @@ class CoverageMappingModuleGen {
std::vector<llvm::Constant *> FunctionNames;
llvm::StructType *FunctionRecordTy;
std::vector<std::string> CoverageMappings;
- SmallString<256> CWD;
-
- /// Make the filename absolute, remove dots, and normalize slashes to local
- /// path style.
- std::string normalizeFilename(StringRef Filename);
public:
- CoverageMappingModuleGen(CodeGenModule &CGM, CoverageSourceInfo &SourceInfo);
+ CoverageMappingModuleGen(CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
+ : CGM(CGM), SourceInfo(SourceInfo), FunctionRecordTy(nullptr) {}
CoverageSourceInfo &getSourceInfo() const {
return SourceInfo;
Removed: cfe/trunk/test/CoverageMapping/debug-dir.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/debug-dir.cpp?rev=374323&view=auto
==============================================================================
--- cfe/trunk/test/CoverageMapping/debug-dir.cpp (original)
+++ cfe/trunk/test/CoverageMapping/debug-dir.cpp (removed)
@@ -1,16 +0,0 @@
-// %s expands to an absolute path, so to test relative paths we need to create a
-// clean directory, put the source there, and cd into it.
-// RUN: rm -rf %t
-// RUN: mkdir -p %t/foobar
-// RUN: cd %t
-// RUN: cp %s foobar/debug-dir.cpp
-
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -main-file-name debug-dir.cpp foobar/debug-dir.cpp -o - | FileCheck -check-prefix=ABSOLUTE %s
-//
-// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\01.*clang.*test.*CoverageMapping.*.*foobar.*debug-dir\.cpp}}
-
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -main-file-name debug-dir.cpp foobar/debug-dir.cpp -fdebug-compilation-dir . -o - | FileCheck -check-prefix=RELATIVE %s
-//
-// RELATIVE: @__llvm_coverage_mapping = {{.*"\\01[^/]*foobar.*debug-dir\.cpp}}
-
-void f1() {}
More information about the cfe-commits
mailing list