LLVM 22.0.0git
Process.inc
Go to the documentation of this file.
1//===- Win32/Process.cpp - Win32 Process Implementation ------- -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides the Win32 specific implementation of the Process class.
10//
11//===----------------------------------------------------------------------===//
12
19#include <malloc.h>
20#include <optional>
21
22// The Windows.h header must be after LLVM and standard headers.
24
25#include <direct.h>
26#include <io.h>
27#include <psapi.h>
28#include <shellapi.h>
29
30#if !defined(__MINGW32__)
31#pragma comment(lib, "psapi.lib")
32#pragma comment(lib, "shell32.lib")
33#endif
34
35//===----------------------------------------------------------------------===//
36//=== WARNING: Implementation here must contain only Win32 specific code
37//=== and must not be UNIX code
38//===----------------------------------------------------------------------===//
39
40using namespace llvm;
41
43 static_assert(sizeof(Pid) >= sizeof(DWORD),
44 "Process::Pid should be big enough to store DWORD");
45 return Pid(::GetCurrentProcessId());
46}
47
48// This function retrieves the page size using GetNativeSystemInfo() and is
49// present solely so it can be called once to initialize the self_process member
50// below.
51static unsigned computePageSize() {
52 // GetNativeSystemInfo() provides the physical page size which may differ
53 // from GetSystemInfo() in 32-bit applications running under WOW64.
54 SYSTEM_INFO info;
55 GetNativeSystemInfo(&info);
56 // FIXME: FileOffset in MapViewOfFile() should be aligned to not dwPageSize,
57 // but dwAllocationGranularity.
58 return static_cast<unsigned>(info.dwPageSize);
59}
60
61Expected<unsigned> Process::getPageSize() {
62 static unsigned Ret = computePageSize();
63 return Ret;
64}
65
67 _HEAPINFO hinfo;
68 hinfo._pentry = NULL;
69
70 size_t size = 0;
71
72 while (_heapwalk(&hinfo) == _HEAPOK)
73 size += hinfo._size;
74
75 return size;
76}
77
79 std::chrono::nanoseconds &user_time,
80 std::chrono::nanoseconds &sys_time) {
81 elapsed = std::chrono::system_clock::now();
82 ;
83
84 FILETIME ProcCreate, ProcExit, KernelTime, UserTime;
85 if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime,
86 &UserTime) == 0)
87 return;
88
89 user_time = toDuration(UserTime);
90 sys_time = toDuration(KernelTime);
91}
92
93// Some LLVM programs such as bugpoint produce core files as a normal part of
94// their operation. To prevent the disk from filling up, this configuration
95// item does what's necessary to prevent their generation.
97 // Windows does have the concept of core files, called minidumps. However,
98 // disabling minidumps for a particular application extends past the lifetime
99 // of that application, which is the incorrect behavior for this API.
100 // Additionally, the APIs require elevated privileges to disable and re-
101 // enable minidumps, which makes this untenable. For more information, see
102 // WerAddExcludedApplication and WerRemoveExcludedApplication (Vista and
103 // later).
104 //
105 // Windows also has modal pop-up message boxes. As this method is used by
106 // bugpoint, preventing these pop-ups is additionally important.
107 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
108 SEM_NOOPENFILEERRORBOX);
109
110 coreFilesPrevented = true;
111}
112
113/// Returns the environment variable \arg Name's value as a string encoded in
114/// UTF-8. \arg Name is assumed to be in UTF-8 encoding.
115std::optional<std::string> Process::GetEnv(StringRef Name) {
116 // Convert the argument to UTF-16 to pass it to _wgetenv().
118 if (windows::UTF8ToUTF16(Name, NameUTF16))
119 return std::nullopt;
120
121 // Environment variable can be encoded in non-UTF8 encoding, and there's no
122 // way to know what the encoding is. The only reliable way to look up
123 // multibyte environment variable is to use GetEnvironmentVariableW().
125 size_t Size = MAX_PATH;
126 do {
128 SetLastError(NO_ERROR);
129 Size = GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.size());
130 if (Size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
131 return std::nullopt;
132
133 // Try again with larger buffer.
134 } while (Size > Buf.size());
135 Buf.truncate(Size);
136
137 // Convert the result from UTF-16 to UTF-8.
139 if (windows::UTF16ToUTF8(Buf.data(), Size, Res))
140 return std::nullopt;
141 return std::string(Res.data());
142}
143
144/// Perform wildcard expansion of Arg, or just push it into Args if it doesn't
145/// have wildcards or doesn't match any files.
146static std::error_code WildcardExpand(StringRef Arg,
148 StringSaver &Saver) {
149 std::error_code EC;
150
151 // Don't expand Arg if it does not contain any wildcard characters. This is
152 // the common case. Also don't wildcard expand /?. Always treat it as an
153 // option. Paths that start with \\?\ are absolute paths, and aren't
154 // expected to be used with wildcard expressions.
155 if (Arg.find_first_of("*?") == StringRef::npos || Arg == "/?" ||
156 Arg == "-?" || Arg.starts_with("\\\\?\\")) {
157 Args.push_back(Arg.data());
158 return EC;
159 }
160
161 // Convert back to UTF-16 so we can call FindFirstFileW.
163 EC = windows::UTF8ToUTF16(Arg, ArgW);
164 if (EC)
165 return EC;
166
167 // Search for matching files.
168 // FIXME: This assumes the wildcard is only in the file name and not in the
169 // directory portion of the file path. For example, it doesn't handle
170 // "*\foo.c" nor "s?c\bar.cpp".
171 WIN32_FIND_DATAW FileData;
172 HANDLE FindHandle = FindFirstFileW(ArgW.data(), &FileData);
173 if (FindHandle == INVALID_HANDLE_VALUE) {
174 Args.push_back(Arg.data());
175 return EC;
176 }
177
178 // Extract any directory part of the argument.
179 SmallString<MAX_PATH> Dir = Arg;
181 const int DirSize = Dir.size();
182
183 do {
184 SmallString<MAX_PATH> FileName;
185 EC = windows::UTF16ToUTF8(FileData.cFileName, wcslen(FileData.cFileName),
186 FileName);
187 if (EC)
188 break;
189
190 // Append FileName to Dir, and remove it afterwards.
191 llvm::sys::path::append(Dir, FileName);
192 Args.push_back(Saver.save(Dir.str()).data());
193 Dir.resize(DirSize);
194 } while (FindNextFileW(FindHandle, &FileData));
195
196 FindClose(FindHandle);
197 return EC;
198}
199
200static std::error_code GetExecutableName(SmallVectorImpl<char> &Filename) {
201 // The first argument may contain just the name of the executable (e.g.,
202 // "clang") rather than the full path, so swap it with the full path.
203 wchar_t ModuleName[MAX_PATH];
204 size_t Length = ::GetModuleFileNameW(NULL, ModuleName, MAX_PATH);
205 if (Length == 0 || Length == MAX_PATH) {
206 return mapWindowsError(GetLastError());
207 }
208
209 // If the first argument is a shortened (8.3) name (which is possible even
210 // if we got the module name), the driver will have trouble distinguishing it
211 // (e.g., clang.exe v. clang++.exe), so expand it now.
212 Length = GetLongPathNameW(ModuleName, ModuleName, MAX_PATH);
213 if (Length == 0)
214 return mapWindowsError(GetLastError());
215 if (Length > MAX_PATH) {
216 // We're not going to try to deal with paths longer than MAX_PATH, so we'll
217 // treat this as an error. GetLastError() returns ERROR_SUCCESS, which
218 // isn't useful, so we'll hardcode an appropriate error value.
219 return mapWindowsError(ERROR_INSUFFICIENT_BUFFER);
220 }
221
222 std::error_code EC = windows::UTF16ToUTF8(ModuleName, Length, Filename);
223 if (EC)
224 return EC;
225
226 // Make a copy of the filename since assign makes the StringRef invalid.
227 std::string Base = sys::path::filename(Filename.data()).str();
228 Filename.assign(Base.begin(), Base.end());
229 return std::error_code();
230}
231
232std::error_code
235 const wchar_t *CmdW = GetCommandLineW();
236 assert(CmdW);
237 std::error_code EC;
239 EC = windows::UTF16ToUTF8(CmdW, wcslen(CmdW), Cmd);
240 if (EC)
241 return EC;
242
244 StringSaver Saver(Alloc);
245 cl::TokenizeWindowsCommandLineFull(Cmd, Saver, TmpArgs, /*MarkEOLs=*/false);
246
247 for (const char *Arg : TmpArgs) {
248 EC = WildcardExpand(Arg, Args, Saver);
249 if (EC)
250 return EC;
251 }
252
253 if (Args.size() == 0)
254 return std::make_error_code(std::errc::invalid_argument);
255
256 SmallVector<char, MAX_PATH> Arg0(Args[0], Args[0] + strlen(Args[0]));
259 EC = GetExecutableName(Filename);
260 if (EC)
261 return EC;
263 sys::path::append(Arg0, Filename);
264 Args[0] = Saver.save(Arg0).data();
265 return std::error_code();
266}
267
269 return std::error_code();
270}
271
272std::error_code Process::SafelyCloseFileDescriptor(int FD) {
273 if (::close(FD) < 0)
274 return errnoAsErrorCode();
275 return std::error_code();
276}
277
278bool Process::StandardInIsUserInput() { return FileDescriptorIsDisplayed(0); }
279
280bool Process::StandardOutIsDisplayed() { return FileDescriptorIsDisplayed(1); }
281
282bool Process::StandardErrIsDisplayed() { return FileDescriptorIsDisplayed(2); }
283
285 DWORD Mode; // Unused
286 return (GetConsoleMode((HANDLE)_get_osfhandle(fd), &Mode) != 0);
287}
288
290 unsigned Columns = 0;
291 CONSOLE_SCREEN_BUFFER_INFO csbi;
292 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
293 Columns = csbi.dwSize.X;
294 return Columns;
295}
296
298 unsigned Columns = 0;
299 CONSOLE_SCREEN_BUFFER_INFO csbi;
300 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE), &csbi))
301 Columns = csbi.dwSize.X;
302 return Columns;
303}
304
305// The terminal always has colors.
307 return FileDescriptorIsDisplayed(fd);
308}
309
310bool Process::StandardOutHasColors() { return FileDescriptorHasColors(1); }
311
312bool Process::StandardErrHasColors() { return FileDescriptorHasColors(2); }
313
314static bool UseANSI = false;
315void Process::UseANSIEscapeCodes(bool enable) {
316#if defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
317 if (enable) {
318 HANDLE Console = GetStdHandle(STD_OUTPUT_HANDLE);
319 DWORD Mode;
320 GetConsoleMode(Console, &Mode);
321 Mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
322 SetConsoleMode(Console, Mode);
323 }
324#endif
325 UseANSI = enable;
326}
327
328namespace {
329class DefaultColors {
330private:
331 WORD defaultColor;
332
333public:
334 DefaultColors() : defaultColor(GetCurrentColor()) {}
335 static unsigned GetCurrentColor() {
336 CONSOLE_SCREEN_BUFFER_INFO csbi;
337 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
338 return csbi.wAttributes;
339 return 0;
340 }
341 WORD operator()() const { return defaultColor; }
342};
343
344DefaultColors defaultColors;
345
346WORD fg_color(WORD color) {
347 return color & (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY |
348 FOREGROUND_RED);
349}
350
351WORD bg_color(WORD color) {
352 return color & (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY |
353 BACKGROUND_RED);
354}
355} // namespace
356
357bool Process::ColorNeedsFlush() { return !UseANSI; }
358
359const char *Process::OutputBold(bool bg) {
360 if (UseANSI)
361 return "\033[1m";
362
363 WORD colors = DefaultColors::GetCurrentColor();
364 if (bg)
365 colors |= BACKGROUND_INTENSITY;
366 else
367 colors |= FOREGROUND_INTENSITY;
368 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors);
369 return 0;
370}
371
372const char *Process::OutputColor(char code, bool bold, bool bg) {
373 if (UseANSI)
374 return colorcodes[bg ? 1 : 0][bold ? 1 : 0][code & 15];
375
376 WORD current = DefaultColors::GetCurrentColor();
377 WORD colors;
378 if (bg) {
379 colors = ((code & 1) ? BACKGROUND_RED : 0) |
380 ((code & 2) ? BACKGROUND_GREEN : 0) |
381 ((code & 4) ? BACKGROUND_BLUE : 0);
382 if (bold)
383 colors |= BACKGROUND_INTENSITY;
384 colors |= fg_color(current);
385 } else {
386 colors = ((code & 1) ? FOREGROUND_RED : 0) |
387 ((code & 2) ? FOREGROUND_GREEN : 0) |
388 ((code & 4) ? FOREGROUND_BLUE : 0);
389 if (bold)
390 colors |= FOREGROUND_INTENSITY;
391 colors |= bg_color(current);
392 }
393 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors);
394 return 0;
395}
396
397static WORD GetConsoleTextAttribute(HANDLE hConsoleOutput) {
398 CONSOLE_SCREEN_BUFFER_INFO info;
399 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
400 return info.wAttributes;
401}
402
403const char *Process::OutputReverse() {
404 if (UseANSI)
405 return "\033[7m";
406
407 const WORD attributes =
408 GetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE));
409
410 const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |
411 FOREGROUND_RED | FOREGROUND_INTENSITY;
412 const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |
413 BACKGROUND_RED | BACKGROUND_INTENSITY;
414 const WORD color_mask = foreground_mask | background_mask;
415
416 WORD new_attributes =
417 ((attributes & FOREGROUND_BLUE) ? BACKGROUND_BLUE : 0) |
418 ((attributes & FOREGROUND_GREEN) ? BACKGROUND_GREEN : 0) |
419 ((attributes & FOREGROUND_RED) ? BACKGROUND_RED : 0) |
420 ((attributes & FOREGROUND_INTENSITY) ? BACKGROUND_INTENSITY : 0) |
421 ((attributes & BACKGROUND_BLUE) ? FOREGROUND_BLUE : 0) |
422 ((attributes & BACKGROUND_GREEN) ? FOREGROUND_GREEN : 0) |
423 ((attributes & BACKGROUND_RED) ? FOREGROUND_RED : 0) |
424 ((attributes & BACKGROUND_INTENSITY) ? FOREGROUND_INTENSITY : 0) | 0;
425 new_attributes = (attributes & ~color_mask) | (new_attributes & color_mask);
426
427 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), new_attributes);
428 return 0;
429}
430
431const char *Process::ResetColor() {
432 if (UseANSI)
433 return "\033[0m";
434 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColors());
435 return 0;
436}
437
438static unsigned GetRandomNumberSeed() {
439 // Generate a random number seed from the millisecond-resolution Windows
440 // system clock and the current process id.
441 FILETIME Time;
442 GetSystemTimeAsFileTime(&Time);
443 DWORD Pid = GetCurrentProcessId();
444 return hash_combine(Time.dwHighDateTime, Time.dwLowDateTime, Pid);
445}
446
447static unsigned GetPseudoRandomNumber() {
448 // Arrange to call srand once when this function is first used, and
449 // otherwise (if GetRandomNumber always succeeds in using
450 // CryptGenRandom) don't bother at all.
451 static int x = (static_cast<void>(::srand(GetRandomNumberSeed())), 0);
452 (void)x;
453 return ::rand();
454}
455
456unsigned Process::GetRandomNumber() {
457 // Try to use CryptGenRandom.
458 HCRYPTPROV HCPC;
459 if (::CryptAcquireContextW(&HCPC, NULL, NULL, PROV_RSA_FULL,
460 CRYPT_VERIFYCONTEXT)) {
461 ScopedCryptContext CryptoProvider(HCPC);
462 unsigned Ret;
463 if (::CryptGenRandom(CryptoProvider, sizeof(Ret),
464 reinterpret_cast<BYTE *>(&Ret)))
465 return Ret;
466 }
467
468 // If that fails, fall back to pseudo-random numbers.
469 return GetPseudoRandomNumber();
470}
471
472typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
473#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
474
475static RTL_OSVERSIONINFOEXW GetWindowsVer() {
476 auto getVer = []() -> RTL_OSVERSIONINFOEXW {
477 HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll");
478 assert(hMod);
479
480 auto getVer =
481 (RtlGetVersionPtr)(void *)::GetProcAddress(hMod, "RtlGetVersion");
482 assert(getVer);
483
484 RTL_OSVERSIONINFOEXW info{};
485 info.dwOSVersionInfoSize = sizeof(info);
486 NTSTATUS r = getVer((PRTL_OSVERSIONINFOW)&info);
487 (void)r;
488 assert(r == STATUS_SUCCESS);
489
490 return info;
491 };
492 static RTL_OSVERSIONINFOEXW info = getVer();
493 return info;
494}
495
497 RTL_OSVERSIONINFOEXW info = GetWindowsVer();
498 return llvm::VersionTuple(info.dwMajorVersion, info.dwMinorVersion, 0,
499 info.dwBuildNumber);
500}
501
503 // Windows 8 is version 6.2, service pack 0.
504 return GetWindowsOSVersion() >= llvm::VersionTuple(6, 2, 0, 0);
505}
506
508 RTL_OSVERSIONINFOEXW info = GetWindowsVer();
509 auto ver = llvm::VersionTuple(info.dwMajorVersion, info.dwMinorVersion, 0,
510 info.dwBuildNumber);
511
512 // Windows Server 2022
513 if (info.wProductType == VER_NT_SERVER)
514 return ver >= llvm::VersionTuple(10, 0, 0, 20348);
515
516 // Windows 11
517 return ver >= llvm::VersionTuple(10, 0, 0, 22000);
518}
519
520[[noreturn]] void Process::ExitNoCleanup(int RetCode) {
521 TerminateProcess(GetCurrentProcess(), RetCode);
522 llvm_unreachable("TerminateProcess doesn't return");
523}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Prepare AGPR Alloc
This file defines the BumpPtrAllocator interface.
lazy value info
static bool coreFilesPrevented
Definition Process.cpp:106
static const char colorcodes[2][2][16][11]
Definition Process.cpp:98
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void resize_for_overwrite(size_type N)
Like resize, but T is POD, the new values won't be initialized.
void truncate(size_type N)
Like resize, but requires that N is less than size().
void resize(size_type N)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:269
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:148
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition StringRef.h:384
static constexpr size_t npos
Definition StringRef.h:57
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:22
StringRef save(const char *S)
Definition StringSaver.h:31
Represents a version number in the form major[.minor[.subminor[.build]]].
static LLVM_ABI void UseANSIEscapeCodes(bool enable)
Enables or disables whether ANSI escape sequences are used to output colors.
static LLVM_ABI std::error_code SafelyCloseFileDescriptor(int FD)
static LLVM_ABI void GetTimeUsage(TimePoint<> &elapsed, std::chrono::nanoseconds &user_time, std::chrono::nanoseconds &sys_time)
This static function will set user_time to the amount of CPU time spent in user (non-kernel) mode and...
static LLVM_ABI std::error_code FixupStandardFileDescriptors()
static LLVM_ABI Pid getProcessId()
Get the process's identifier.
static LLVM_ABI size_t GetMallocUsage()
Return process memory usage.
static LLVM_ABI bool ColorNeedsFlush()
Whether changing colors requires the output to be flushed.
static LLVM_ABI const char * ResetColor()
Resets the terminals colors, or returns an escape sequence to do so.
static LLVM_ABI unsigned GetRandomNumber()
Get the result of a process wide random number generator.
static LLVM_ABI bool FileDescriptorIsDisplayed(int fd)
This function determines if the given file descriptor is connected to a "tty" or "console" window.
static LLVM_ABI Expected< unsigned > getPageSize()
Get the process's page size.
static LLVM_ABI const char * OutputColor(char c, bool bold, bool bg)
This function returns the colorcode escape sequences.
static LLVM_ABI const char * OutputBold(bool bg)
Same as OutputColor, but only enables the bold attribute.
static LLVM_ABI unsigned StandardErrColumns()
This function determines the number of columns in the window if standard error is connected to a "tty...
static LLVM_ABI std::optional< std::string > GetEnv(StringRef name)
static LLVM_ABI bool FileDescriptorHasColors(int fd)
This function determines if the given file descriptor is displayd and supports colors.
static LLVM_ABI bool StandardInIsUserInput()
This function determines if the standard input is connected directly to a user's input (keyboard prob...
static LLVM_ABI void PreventCoreFiles()
This function makes the necessary calls to the operating system to prevent core files or any other ki...
static LLVM_ABI bool StandardErrHasColors()
This function determines whether the terminal connected to standard error supports colors.
static LLVM_ABI const char * OutputReverse()
This function returns the escape sequence to reverse forground and background colors.
static LLVM_ABI bool StandardErrIsDisplayed()
This function determines if the standard error is connected to a "tty" or "console" window.
static LLVM_ABI bool StandardOutHasColors()
This function determines whether the terminal connected to standard output supports colors.
static LLVM_ABI unsigned StandardOutColumns()
This function determines the number of columns in the window if standard output is connected to a "tt...
static LLVM_ABI bool StandardOutIsDisplayed()
This function determines if the standard output is connected to a "tty" or "console" window.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
LLVM_ABI void TokenizeWindowsCommandLineFull(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a Windows full command line, including command name at the start.
LLVM_ABI void remove_filename(SmallVectorImpl< char > &path, Style style=Style::native)
Remove the last component from path unless it is the root dir.
Definition Path.cpp:474
void make_preferred(SmallVectorImpl< char > &path, Style style=Style::native)
For Windows path styles, convert path to use the preferred path separators.
Definition Path.h:278
LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get filename.
Definition Path.cpp:577
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition Path.cpp:456
LLVM_ABI std::error_code GetCommandLineArguments(SmallVectorImpl< const char * > &Args, BumpPtrAllocator &Alloc)
std::chrono::nanoseconds toDuration(FILETIME Time)
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
Definition Chrono.h:34
This is an optimization pass for GlobalISel generic memory operations.
@ Length
Definition DWP.cpp:477
LLVM_ABI bool RunningWindows8OrGreater()
Determines if the program is running on Windows 8 or newer.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1665
ScopedHandle< CryptContextTraits > ScopedCryptContext
LLVM_ABI llvm::VersionTuple GetWindowsOSVersion()
Returns the Windows version as Major.Minor.0.BuildNumber.
LLVM_ABI bool RunningWindows11OrGreater()
Determines if the program is running on Windows 11 or Windows Server 2022.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
LLVM_ABI std::error_code mapWindowsError(unsigned EV)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:591
std::error_code errnoAsErrorCode()
Helper to get errno as an std::error_code.
Definition Error.h:1240