Skip to content

Commit 00a09be

Browse files
[clang][DebugInfo] Handle empty comp_dir in CodeGen
Fix a logic mistake in DebugInfo CodeGen that if the compilation directory is empty, the leading separator is dropped with emitting path. This code path is usually not possible in current state unless the compilation is done from a file system that do not have current working directory and compilation caching include tree file system is such a file system. This causes PCMs are encoded with wrong path in the gmodule compilation, causing lost of debug info. Note this is a reduced and safer version from upstream fix: llvm#150130 The test is in swift repo since the only trigger in current branch is to trigger from swift caching builds. rdar://156759645
1 parent 63895c9 commit 00a09be

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,6 +3119,9 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
31193119
std::string Remapped = remapDIPath(Path);
31203120
StringRef Relative(Remapped);
31213121
StringRef CompDir = TheCU->getDirectory();
3122+
if (CompDir.empty())
3123+
return Remapped;
3124+
31223125
if (Relative.consume_front(CompDir))
31233126
Relative.consume_front(llvm::sys::path::get_separator());
31243127

0 commit comments

Comments
 (0)