[llvm] r185225 - Fix Windows/Darwin build error in DebugIR unit tests
Daniel Malea
daniel.malea at intel.com
Fri Jun 28 14:49:53 PDT 2013
Author: dmalea
Date: Fri Jun 28 16:49:53 2013
New Revision: 185225
URL: http://llvm.org/viewvc/llvm-project?rev=185225&view=rev
Log:
Fix Windows/Darwin build error in DebugIR unit tests
- mistakenly used get_current_dir() linux function
- replaced with getcwd/_getcwd as appropriate for current platform
Modified:
llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp
Modified: llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp?rev=185225&r1=185224&r2=185225&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp (original)
+++ llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp Fri Jun 28 16:49:53 2013
@@ -32,6 +32,14 @@
#include "gtest/gtest.h"
+#if defined(LLVM_ON_WIN32)
+#include <direct.h>
+#define getcwd_impl _getcwd
+#elif defined (HAVE_GETCWD)
+#include <unistd.h>
+#define getcwd_impl getcwd
+#endif // LLVM_ON_WIN32
+
using namespace llvm;
using namespace std;
@@ -53,19 +61,21 @@ bool removeIfExists(StringRef Path) {
return existed;
}
+char * current_dir() {
+#if defined(LLVM_ON_WIN32) || defined(HAVE_GETCWD)
+ // calling getcwd (or _getcwd() on windows) with a null buffer makes it
+ // allocate a sufficiently sized buffer to store the current working dir.
+ return getcwd_impl(0, 0);
+#else
+ return 0;
+#endif
+}
+
class TestDebugIR : public ::testing::Test, public TrivialModuleBuilder {
protected:
TestDebugIR()
: TrivialModuleBuilder(sys::getProcessTriple())
-#ifdef HAVE_GETCWD
- ,
- cwd(get_current_dir_name())
-#else
- ,
- cwd(0)
-#endif
- {
- }
+ , cwd(current_dir()) {}
~TestDebugIR() { free(cwd); }
More information about the llvm-commits
mailing list