summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Process.inc
diff options
context:
space:
mode:
authorBen Dunbobbin <bd1976llvm@gmail.com>2017-08-18 16:55:44 +0000
committerBen Dunbobbin <bd1976llvm@gmail.com>2017-08-18 16:55:44 +0000
commitac6a5aab45ef721e92a28e1b0515aa2a514d740b (patch)
tree9002927531e70abfdf8211a04ef548c80314d36c /llvm/lib/Support/Windows/Process.inc
parent849f20e4a2f3ee41e2527413674d8da44a8512a2 (diff)
downloadbcm5719-llvm-ac6a5aab45ef721e92a28e1b0515aa2a514d740b.tar.gz
bcm5719-llvm-ac6a5aab45ef721e92a28e1b0515aa2a514d740b.zip
[Support] env vars with empty values on windows
An environment variable can be in one of three states: 1. undefined. 2. defined with a non-empty value. 3. defined but with an empty value. The windows implementation did not support case 3 (it was not handling errors). The Linux implementation is already correct. Differential Revision: https://reviews.llvm.org/D36394 llvm-svn: 311174
Diffstat (limited to 'llvm/lib/Support/Windows/Process.inc')
-rw-r--r--llvm/lib/Support/Windows/Process.inc5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc
index 18aef610d54..3fe9f89f1ef 100644
--- a/llvm/lib/Support/Windows/Process.inc
+++ b/llvm/lib/Support/Windows/Process.inc
@@ -129,9 +129,10 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
size_t Size = MAX_PATH;
do {
Buf.reserve(Size);
+ SetLastError(NO_ERROR);
Size =
- GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.capacity());
- if (Size == 0)
+ GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.capacity());
+ if (Size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
return None;
// Try again with larger buffer.
OpenPOWER on IntegriCloud