[llvm] a811f26 - [llvm][test] Write temporary files into a temporary directory
Dmitri Gribenko via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 01:21:14 PDT 2024
Author: Dmitri Gribenko
Date: 2024-08-21T10:21:06+02:00
New Revision: a811f263356af4fcf5b479c7a32d1bab44ac8954
URL: https://github.com/llvm/llvm-project/commit/a811f263356af4fcf5b479c7a32d1bab44ac8954
DIFF: https://github.com/llvm/llvm-project/commit/a811f263356af4fcf5b479c7a32d1bab44ac8954.diff
LOG: [llvm][test] Write temporary files into a temporary directory
Added:
Modified:
llvm/unittests/Analysis/GraphWriterTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Analysis/GraphWriterTest.cpp b/llvm/unittests/Analysis/GraphWriterTest.cpp
index a723c92d157618..4017e63a8c8675 100644
--- a/llvm/unittests/Analysis/GraphWriterTest.cpp
+++ b/llvm/unittests/Analysis/GraphWriterTest.cpp
@@ -12,6 +12,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
@@ -56,7 +57,10 @@ class GraphWriterTest : public testing::Test {
static void writeCFGToDotFile(Function &F, std::string Name,
bool CFGOnly = false) {
std::error_code EC;
- raw_fd_ostream File(Name + ".dot", EC, sys::fs::OpenFlags::OF_Text);
+ llvm::unittest::TempDir Tmp("tmpdir", /*Unique=*/true);
+ SmallString<128> FileName(Tmp.path().begin(), Tmp.path().end());
+ sys::path::append(FileName, Name + ".dot");
+ raw_fd_ostream File(FileName, EC, sys::fs::OpenFlags::OF_Text);
DOTFuncInfo CFGInfo(&F);
More information about the llvm-commits
mailing list