Use a lambda for calls to ::open in RetryAfterSignal
In Bionic, open can be overloaded for _FORTIFY_SOURCE support, causing
compile errors of RetryAfterSignal due to overload resolution. Wrapping
the call in a lambda avoids this.
Based on a patch by Chih-Wei Huang <cwhuang@linux.org.tw>!
llvm-svn: 340751
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index fa515d4..3185f45 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -211,7 +211,10 @@
assert(errno == EBADF && "expected errno to have EBADF at this point!");
if (NullFD < 0) {
- if ((NullFD = RetryAfterSignal(-1, ::open, "/dev/null", O_RDWR)) < 0)
+ // Call ::open in a lambda to avoid overload resolution in
+ // RetryAfterSignal when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open("/dev/null", O_RDWR); };
+ if ((NullFD = RetryAfterSignal(-1, Open)) < 0)
return std::error_code(errno, std::generic_category());
}