diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp --- a/llvm/lib/Support/FileCollector.cpp +++ b/llvm/lib/Support/FileCollector.cpp @@ -50,7 +50,9 @@ } FileCollector::FileCollector(std::string Root, std::string OverlayRoot) - : Root(std::move(Root)), OverlayRoot(std::move(OverlayRoot)) { + : Root(Root), OverlayRoot(OverlayRoot) { + assert(sys::path::is_absolute(Root) && "Root not absolute"); + assert(sys::path::is_absolute(OverlayRoot) && "OverlayRoot not absolute"); } void FileCollector::PathCanonicalizer::updateWithRealPath( diff --git a/llvm/test/tools/dsymutil/X86/reproducer.test b/llvm/test/tools/dsymutil/X86/reproducer.test --- a/llvm/test/tools/dsymutil/X86/reproducer.test +++ b/llvm/test/tools/dsymutil/X86/reproducer.test @@ -13,6 +13,9 @@ # Verify all the files are present. RUN: dsymutil -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s +# Make sure we don't crash with an empty TMPDIR. +RUN: env TMPDIR="" dsymutil -o -f %t.generate -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 + # Create a reproducer. RUN: env DSYMUTIL_REPRODUCER_PATH=%t.repro dsymutil -gen-reproducer -f -o %t.generate -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefixes=REPRODUCER RUN: llvm-dwarfdump -a %t.generate | FileCheck %s diff --git a/llvm/tools/dsymutil/Reproducer.cpp b/llvm/tools/dsymutil/Reproducer.cpp --- a/llvm/tools/dsymutil/Reproducer.cpp +++ b/llvm/tools/dsymutil/Reproducer.cpp @@ -20,6 +20,7 @@ } else { EC = sys::fs::createUniqueDirectory("dsymutil", Root); } + sys::fs::make_absolute(Root); return EC ? "" : std::string(Root); }