diff options
author | Paul Robinson <paul_robinson@playstation.sony.com> | 2015-11-11 20:49:32 +0000 |
---|---|---|
committer | Paul Robinson <paul_robinson@playstation.sony.com> | 2015-11-11 20:49:32 +0000 |
commit | 8ab79a1e8af9c37fba1867973239324e841a52e4 (patch) | |
tree | c208f03c6c5744a301dcfbeb17291ccb631621a3 /llvm/lib/Support | |
parent | 1070a09f1799633ae31a9135216d7d5b796ac9da (diff) | |
download | bcm5719-llvm-8ab79a1e8af9c37fba1867973239324e841a52e4.tar.gz bcm5719-llvm-8ab79a1e8af9c37fba1867973239324e841a52e4.zip |
Report Windows error code in a fatal error after a system call.
llvm-svn: 252800
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/Windows/Process.inc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc index 8164956d151..dae35a88132 100644 --- a/llvm/lib/Support/Windows/Process.inc +++ b/llvm/lib/Support/Windows/Process.inc @@ -417,16 +417,23 @@ const char *Process::ResetColor() { return 0; } +// Include GetLastError() in a fatal error message. +static void ReportLastErrorFatal(const char *Msg) { + std::string ErrMsg; + MakeErrMsg(&ErrMsg, Msg); + report_fatal_error(ErrMsg); +} + unsigned Process::GetRandomNumber() { HCRYPTPROV HCPC; if (!::CryptAcquireContextW(&HCPC, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - report_fatal_error("Could not acquire a cryptographic context"); + ReportLastErrorFatal("Could not acquire a cryptographic context"); ScopedCryptContext CryptoProvider(HCPC); unsigned Ret; if (!::CryptGenRandom(CryptoProvider, sizeof(Ret), reinterpret_cast<BYTE *>(&Ret))) - report_fatal_error("Could not generate a random number"); + ReportLastErrorFatal("Could not generate a random number"); return Ret; } |