23 #define _WIN32_WINNT 0x0501
24 #define _WIN32_IE 0x0600 // MinGW at it again.
25 #define WIN32_LEAN_AND_MEAN
29 #include "llvm/Config/config.h"
38 inline bool MakeErrMsg(std::string* ErrMsg,
const std::string& prefix) {
42 DWORD R = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
43 FORMAT_MESSAGE_FROM_SYSTEM,
44 NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
46 *ErrMsg = prefix + buffer;
48 *ErrMsg = prefix +
"Unknown error";
54 template <
typename HandleTraits>
56 typedef typename HandleTraits::handle_type handle_type;
63 : Handle(HandleTraits::GetInvalid()) {}
69 if (HandleTraits::IsValid(Handle))
70 HandleTraits::Close(Handle);
74 handle_type t = Handle;
75 Handle = HandleTraits::GetInvalid();
80 if (HandleTraits::IsValid(Handle))
81 HandleTraits::Close(Handle);
88 return HandleTraits::IsValid(Handle) ?
true :
false;
91 operator handle_type()
const {
100 return INVALID_HANDLE_VALUE;
126 ::CryptReleaseContext(h, 0);
150 class SmallVectorImpl;
153 typename SmallVectorImpl<T>::const_pointer
ScopedHandle< JobHandleTraits > ScopedJobHandle
void push_back(const T &Elt)
static handle_type GetInvalid()
static void Close(handle_type h)
static bool IsValid(handle_type h)
static bool IsValid(handle_type h)
error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len, SmallVectorImpl< char > &utf8)
error_code UTF8ToUTF16(StringRef utf8, SmallVectorImpl< wchar_t > &utf16)
ScopedHandle< FindHandleTraits > ScopedFindHandle
static void Close(handle_type h)
static handle_type GetInvalid()
ScopedHandle(handle_type h)
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
ScopedHandle< FileHandleTraits > ScopedFileHandle
bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix)
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
#define LLVM_EXPLICIT
Expands to explicit on compilers which support explicit conversion operators. Otherwise expands to no...
ScopedHandle< CryptContextTraits > ScopedCryptContext
ScopedHandle< CommonHandleTraits > ScopedCommonHandle
ScopedHandle & operator=(handle_type h)
static handle_type GetInvalid()
static void Close(handle_type h)