Skip to content

Commit a811f26

Browse files
committed
[llvm][test] Write temporary files into a temporary directory
1 parent 0b0ccd5 commit a811f26

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/unittests/Analysis/GraphWriterTest.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "llvm/IR/Function.h"
1313
#include "llvm/IR/LLVMContext.h"
1414
#include "llvm/IR/Module.h"
15+
#include "llvm/Testing/Support/SupportHelpers.h"
1516
#include "llvm/Support/SourceMgr.h"
1617
#include "llvm/Support/raw_ostream.h"
1718
#include "gtest/gtest.h"
@@ -56,7 +57,10 @@ class GraphWriterTest : public testing::Test {
5657
static void writeCFGToDotFile(Function &F, std::string Name,
5758
bool CFGOnly = false) {
5859
std::error_code EC;
59-
raw_fd_ostream File(Name + ".dot", EC, sys::fs::OpenFlags::OF_Text);
60+
llvm::unittest::TempDir Tmp("tmpdir", /*Unique=*/true);
61+
SmallString<128> FileName(Tmp.path().begin(), Tmp.path().end());
62+
sys::path::append(FileName, Name + ".dot");
63+
raw_fd_ostream File(FileName, EC, sys::fs::OpenFlags::OF_Text);
6064

6165
DOTFuncInfo CFGInfo(&F);
6266

0 commit comments

Comments
 (0)