Index: docs/TestingGuide.rst =================================================================== --- docs/TestingGuide.rst +++ docs/TestingGuide.rst @@ -598,3 +598,10 @@ For more information on the ``test-suite`` Makefile setup, please see the :doc:`Test Suite Makefile Guide `. + +Capturing Diagnostic Information +-------------------------------- + +The compiler may crash while running a test. In this situation, it may emit +useful diagnostic information in the system temp directory. To specify an +alternate temp directory, set the ``LLVM_TEMP_DIR`` environment variable. Index: lib/Support/Path.cpp =================================================================== --- lib/Support/Path.cpp +++ lib/Support/Path.cpp @@ -157,6 +157,20 @@ FS_Name }; +template +static void getTempDirectory(bool ErasedOnReboot, SmallString &TDir) { + Optional TempDir = sys::Process::GetEnv("LLVM_TEMP_DIR"); + if (TempDir.hasValue()) { + std::string &Dir = TempDir.getValue(); + if (sys::fs::is_directory(Dir)) { + TDir.assign(Dir.begin(), Dir.end()); + return; + } + } + + sys::path::system_temp_directory(ErasedOnReboot, TDir); +} + static std::error_code createUniqueEntity(const Twine &Model, int &ResultFD, SmallVectorImpl &ResultPath, bool MakeAbsolute, unsigned Mode, @@ -168,7 +182,7 @@ // Make model absolute by prepending a temp directory if it's not already. if (!sys::path::is_absolute(Twine(ModelStorage))) { SmallString<128> TDir; - sys::path::system_temp_directory(true, TDir); + getTempDirectory(true, TDir); sys::path::append(TDir, Twine(ModelStorage)); ModelStorage.swap(TDir); }