llvm.org GIT mirror llvm / 9a7a3bc
Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes. Some Include What You Use suggestions were used too. Use anonymous namespaces in source files. Differential revision: http://reviews.llvm.org/D18778 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265454 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
30 changed file(s) with 534 addition(s) and 334 deletion(s). Raw diff Collapse all Expand all
1313
1414 #include "llvm/ADT/APFloat.h"
1515 #include "llvm/ADT/APSInt.h"
16 #include "llvm/ADT/ArrayRef.h"
1617 #include "llvm/ADT/FoldingSet.h"
1718 #include "llvm/ADT/Hashing.h"
19 #include "llvm/ADT/SmallVector.h"
1820 #include "llvm/ADT/StringExtras.h"
1921 #include "llvm/ADT/StringRef.h"
2022 #include "llvm/Support/ErrorHandling.h"
2123 #include "llvm/Support/MathExtras.h"
24 #include
25 #include
26 #include
2227 #include
23 #include .h>
28 #include >
2429
2530 using namespace llvm;
2631
9297 const unsigned int maxPowerOfFiveExponent = maxExponent + maxPrecision - 1;
9398 const unsigned int maxPowerOfFiveParts = 2 + ((maxPowerOfFiveExponent * 815)
9499 / (351 * integerPartWidth));
95 }
100
101 } // end namespace llvm
102
103 namespace {
96104
97105 /* A bunch of private, handy routines. */
98106
99 static inline unsigned int
107 inline unsigned int
100108 partCountForBits(unsigned int bits)
101109 {
102110 return ((bits) + integerPartWidth - 1) / integerPartWidth;
103111 }
104112
105113 /* Returns 0U-9U. Return values >= 10U are not digits. */
106 static inline unsigned int
114 inline unsigned int
107115 decDigitValue(unsigned int c)
108116 {
109117 return c - '0';
114122
115123 If the exponent overflows, returns a large exponent with the
116124 appropriate sign. */
117 static int
125 int
118126 readExponent(StringRef::iterator begin, StringRef::iterator end)
119127 {
120128 bool isNegative;
158166
159167 /* This is ugly and needs cleaning up, but I don't immediately see
160168 how whilst remaining safe. */
161 static int
169 int
162170 totalExponent(StringRef::iterator p, StringRef::iterator end,
163171 int exponentAdjustment)
164172 {
207215 return exponent;
208216 }
209217
210 static StringRef::iterator
218 StringRef::iterator
211219 skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end,
212220 StringRef::iterator *dot)
213221 {
248256 int normalizedExponent;
249257 };
250258
251 static void
259 void
252260 interpretDecimal(StringRef::iterator begin, StringRef::iterator end,
253261 decimalInfo *D)
254262 {
307315 /* Return the trailing fraction of a hexadecimal number.
308316 DIGITVALUE is the first hex digit of the fraction, P points to
309317 the next digit. */
310 static lostFraction
318 lostFraction
311319 trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end,
312320 unsigned int digitValue)
313321 {
338346
339347 /* Return the fraction lost were a bignum truncated losing the least
340348 significant BITS bits. */
341 static lostFraction
349 lostFraction
342350 lostFractionThroughTruncation(const integerPart *parts,
343351 unsigned int partCount,
344352 unsigned int bits)
360368 }
361369
362370 /* Shift DST right BITS bits noting lost fraction. */
363 static lostFraction
371 lostFraction
364372 shiftRight(integerPart *dst, unsigned int parts, unsigned int bits)
365373 {
366374 lostFraction lost_fraction;
373381 }
374382
375383 /* Combine the effect of two lost fractions. */
376 static lostFraction
384 lostFraction
377385 combineLostFractions(lostFraction moreSignificant,
378386 lostFraction lessSignificant)
379387 {
394402
395403 See "How to Read Floating Point Numbers Accurately" by William D
396404 Clinger. */
397 static unsigned int
405 unsigned int
398406 HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2)
399407 {
400408 assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
408416 /* The number of ulps from the boundary (zero, or half if ISNEAREST)
409417 when the least significant BITS are truncated. BITS cannot be
410418 zero. */
411 static integerPart
419 integerPart
412420 ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest)
413421 {
414422 unsigned int count, partBits;
453461
454462 /* Place pow(5, power) in DST, and return the number of parts used.
455463 DST must be at least one part larger than size of the answer. */
456 static unsigned int
464 unsigned int
457465 powerOf5(integerPart *dst, unsigned int power)
458466 {
459467 static const integerPart firstEightPowers[] = { 1, 5, 25, 125, 625, 3125,
516524
517525 /* Zero at the end to avoid modular arithmetic when adding one; used
518526 when rounding up during hexadecimal output. */
519 static const char hexDigitsLower[] = "0123456789abcdef0";
520 static const char hexDigitsUpper[] = "0123456789ABCDEF0";
521 static const char infinityL[] = "infinity";
522 static const char infinityU[] = "INFINITY";
523 static const char NaNL[] = "nan";
524 static const char NaNU[] = "NAN";
527 const char hexDigitsLower[] = "0123456789abcdef0";
528 const char hexDigitsUpper[] = "0123456789ABCDEF0";
529 const char infinityL[] = "infinity";
530 const char infinityU[] = "INFINITY";
531 const char NaNL[] = "nan";
532 const char NaNU[] = "NAN";
525533
526534 /* Write out an integerPart in hexadecimal, starting with the most
527535 significant nibble. Write out exactly COUNT hexdigits, return
528536 COUNT. */
529 static unsigned int
537 unsigned int
530538 partAsHex (char *dst, integerPart part, unsigned int count,
531539 const char *hexDigitChars)
532540 {
544552 }
545553
546554 /* Write out an unsigned decimal integer. */
547 static char *
555 char *
548556 writeUnsignedDecimal (char *dst, unsigned int n)
549557 {
550558 char buff[40], *p;
562570 }
563571
564572 /* Write out a signed decimal integer. */
565 static char *
573 char *
566574 writeSignedDecimal (char *dst, int value)
567575 {
568576 if (value < 0) {
573581
574582 return dst;
575583 }
584
585 } // end anonymous namespace
576586
577587 /* Constructors. */
578588 void
851861 {
852862 return semantics.precision;
853863 }
864
854865 APFloat::ExponentType
855866 APFloat::semanticsMaxExponent(const fltSemantics &semantics)
856867 {
857868 return semantics.maxExponent;
858869 }
870
859871 APFloat::ExponentType
860872 APFloat::semanticsMinExponent(const fltSemantics &semantics)
861873 {
19051917
19061918 return fs;
19071919 }
1908
19091920
19101921 /* Comparison requires normalized numbers. */
19111922 APFloat::cmpResult
25572568
25582569 /* Check whether the normalized exponent is high enough to overflow
25592570 max during the log-rebasing in the max-exponent check below. */
2560 } else if (D.normalizedExponent - 1 > INT_MAX / 42039) {
2571 } else if (D.normalizedExponent - 1 >
2572 std::numeric_limits::max() / 42039) {
25612573 fs = handleOverflow(rounding_mode);
25622574
25632575 /* If it wasn't, then it also wasn't high enough to overflow max
25642576 during the log-rebasing in the min-exponent check. Check that it
25652577 won't overflow min in either check, then perform the min-exponent
25662578 check. */
2567 } else if (D.normalizedExponent - 1 < INT_MIN / 42039 ||
2579 } else if ((D.normalizedExponent - 1 <
2580 std::numeric_limits::min() / 42039) ||
25682581 (D.normalizedExponent + 1) * 28738 <=
25692582 8651 * (semantics->minExponent - (int) semantics->precision)) {
25702583 /* Underflow to zero and round. */
32183231 uint64_t mysignificand2 = i2 & 0xffffffffffffLL;
32193232
32203233 initialize(&APFloat::IEEEquad);
3221 assert(partCount()==2);
3234 assert(partCount() == 2);
32223235
32233236 sign = static_cast(i2>>63);
32243237 if (myexponent==0 &&
34843497 }
34853498
34863499 namespace {
3500
34873501 void append(SmallVectorImpl &Buffer, StringRef Str) {
34883502 Buffer.append(Str.begin(), Str.end());
34893503 }
35193533 // Truncate the significand down to its active bit count.
35203534 significand = significand.trunc(significand.getActiveBits());
35213535 }
3522
35233536
35243537 void AdjustToPrecision(SmallVectorImpl &buffer,
35253538 int &exp, unsigned FormatPrecision) {
35653578 exp += FirstSignificant;
35663579 buffer.erase(&buffer[0], &buffer[FirstSignificant]);
35673580 }
3568 }
3581
3582 } // end anonymous namespace
35693583
35703584 void APFloat::toString(SmallVectorImpl &Str,
35713585 unsigned FormatPrecision,
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/Support/CrashRecoveryContext.h"
10 #include "llvm/ADT/STLExtras.h"
1011 #include "llvm/Config/config.h"
1112 #include "llvm/Support/ErrorHandling.h"
1213 #include "llvm/Support/ManagedStatic.h"
1314 #include "llvm/Support/Mutex.h"
1415 #include "llvm/Support/ThreadLocal.h"
15 #include
16 #include "llvm/Support/Threading.h"
17 #include
18 #include
19
1620 using namespace llvm;
1721
1822 namespace {
1923
2024 struct CrashRecoveryContextImpl;
2125
22 static ManagedStatic<
26 ManagedStatic<
2327 sys::ThreadLocal > CurrentContext;
2428
2529 struct CrashRecoveryContextImpl {
4145 Next = CurrentContext->get();
4246 CurrentContext->set(this);
4347 }
48
4449 ~CrashRecoveryContextImpl() {
4550 if (!SwitchedThread)
4651 CurrentContext->set(Next);
6974 }
7075 };
7176
72 }
73
74 static ManagedStatic gCrashRecoveryContextMutex;
75 static bool gCrashRecoveryEnabled = false;
76
77 static ManagedStatic>
77 ManagedStatic gCrashRecoveryContextMutex;
78 bool gCrashRecoveryEnabled = false;
79
80 ManagedStatic>
7881 tlIsRecoveringFromCrash;
82
83 } // end anonymous namespace
7984
8085 CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
8186
161166 // SetUnhandledExceptionFilter API, but there's a risk of that
162167 // being entirely overwritten (it's not a chain).
163168
164 static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
169 namespace {
170
171 LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
165172 {
166173 // Lookup the current thread local recovery object.
167174 const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
189196 // CrashRecoveryContext at all. So we make use of a thread-local
190197 // exception table. The handles contained in here will either be
191198 // non-NULL, valid VEH handles, or NULL.
192 static sys::ThreadLocal sCurrentExceptionHandle;
199 sys::ThreadLocal sCurrentExceptionHandle;
200
201 } // end anonymous namespace
193202
194203 void CrashRecoveryContext::Enable() {
195204 sys::ScopedLock L(*gCrashRecoveryContextMutex);
238247 // reliable fashion -- if we get a signal outside of a crash recovery context we
239248 // simply disable crash recovery and raise the signal again.
240249
241 #include
242
243 static const int Signals[] =
244 { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP };
245 static const unsigned NumSignals = array_lengthof(Signals);
246 static struct sigaction PrevActions[NumSignals];
247
248 static void CrashRecoverySignalHandler(int Signal) {
250 #include
251
252 namespace {
253
254 const int Signals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP };
255 const unsigned NumSignals = array_lengthof(Signals);
256 struct sigaction PrevActions[NumSignals];
257
258 void CrashRecoverySignalHandler(int Signal) {
249259 // Lookup the current thread local recovery object.
250260 const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
251261
277287 const_cast(CRCI)->HandleCrash();
278288 }
279289
290 } // end anonymous namespace
291
280292 void CrashRecoveryContext::Enable() {
281293 sys::ScopedLock L(*gCrashRecoveryContextMutex);
282294
333345 CRCI->HandleCrash();
334346 }
335347
348 namespace {
349
336350 // FIXME: Portability.
337 static void setThreadBackgroundPriority() {
351 void setThreadBackgroundPriority() {
338352 #ifdef __APPLE__
339353 setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
340354 #endif
341355 }
342356
343 static bool hasThreadBackgroundPriority() {
357 bool hasThreadBackgroundPriority() {
344358 #ifdef __APPLE__
345359 return getpriority(PRIO_DARWIN_THREAD, 0) == 1;
346360 #else
348362 #endif
349363 }
350364
351 namespace {
352365 struct RunSafelyOnThreadInfo {
353366 function_ref Fn;
354367 CrashRecoveryContext *CRC;
355368 bool UseBackgroundPriority;
356369 bool Result;
357370 };
358 }
359
360 static void RunSafelyOnThread_Dispatch(void *UserData) {
371
372 void RunSafelyOnThread_Dispatch(void *UserData) {
361373 RunSafelyOnThreadInfo *Info =
362374 reinterpret_cast(UserData);
363375
366378
367379 Info->Result = Info->CRC->RunSafely(Info->Fn);
368380 }
381
382 } // end anonymous namespace
383
369384 bool CrashRecoveryContext::RunSafelyOnThread(function_ref Fn,
370385 unsigned RequestedStackSize) {
371386 bool UseBackgroundPriority = hasThreadBackgroundPriority();
1313 #include "llvm/Support/Errno.h"
1414 #include "llvm/Config/config.h" // Get autoconf configuration settings
1515 #include "llvm/Support/raw_ostream.h"
16 #include
17
18 #if HAVE_ERRNO_H
19 #include
20 #endif
16 #include
17 #include
18 #include
2119
2220 //===----------------------------------------------------------------------===//
2321 //=== WARNING: Implementation here must contain only TRULY operating system
3129 std::string StrError() {
3230 return StrError(errno);
3331 }
34 #endif // HAVE_ERRNO_H
32 #endif // HAVE_ERRNO_H
3533
3634 std::string StrError(int errnum) {
3735 std::string str;
7169 return str;
7270 }
7371
74 } // namespace sys
75 } // namespace llvm
72 } // namespace sys
73 } // namespace llvm
1818 #include "llvm/Config/config.h"
1919 #include "llvm/Support/Debug.h"
2020 #include "llvm/Support/FileSystem.h"
21 #include "llvm/Support/raw_ostream.h"
22 #include <string.h>
21 #include <cstring>
22 #include
2323
2424 // Include the platform-specific parts of this class.
2525 #ifdef LLVM_ON_UNIX
4848
4949 using namespace llvm;
5050
51 namespace {
52
5153 #if defined(__linux__)
52 static ssize_t LLVM_ATTRIBUTE_UNUSED readCpuInfo(void *Buf, size_t Size) {
54 ssize_t LLVM_ATTRIBUTE_UNUSED readCpuInfo(void *Buf, size_t Size) {
5355 // Note: We cannot mmap /proc/cpuinfo here and then process the resulting
5456 // memory buffer because the 'file' has 0 size (it can be read from only
5557 // as a stream).
7375
7476 /// GetX86CpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
7577 /// specified arguments. If we can't run cpuid on the host, return true.
76 static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
77 unsigned *rECX, unsigned *rEDX) {
78 bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
79 unsigned *rECX, unsigned *rEDX) {
7880 #if defined(__GNUC__) || defined(__clang__)
7981 #if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
8082 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
119121 /// GetX86CpuIDAndInfoEx - Execute the specified cpuid with subleaf and return the
120122 /// 4 values in the specified arguments. If we can't run cpuid on the host,
121123 /// return true.
122 static bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
123 unsigned *rEAX, unsigned *rEBX, unsigned *rECX,
124 unsigned *rEDX) {
124 bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf, unsigned *rEAX,
125 unsigned *rEBX, unsigned *rECX, unsigned *rEDX) {
125126 #if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
126127 #if defined(__GNUC__)
127128 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
181182 #endif
182183 }
183184
184 static bool GetX86XCR0(unsigned *rEAX, unsigned *rEDX) {
185 bool GetX86XCR0(unsigned *rEAX, unsigned *rEDX) {
185186 #if defined(__GNUC__)
186187 // Check xgetbv; this uses a .byte sequence instead of the instruction
187188 // directly because older assemblers do not include support for xgetbv and
198199 #endif
199200 }
200201
201 static void DetectX86FamilyModel(unsigned EAX, unsigned &Family,
202 unsigned &Model) {
202 void DetectX86FamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) {
203203 Family = (EAX >> 8) & 0xf; // Bits 8 - 11
204204 Model = (EAX >> 4) & 0xf; // Bits 4 - 7
205205 if (Family == 6 || Family == 0xf) {
210210 Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
211211 }
212212 }
213
214 } // end anonymous namespace
213215
214216 StringRef sys::getHostCPUName() {
215217 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
None //===-- MathExtras.cpp - Implement the MathExtras header --------------===//
0 //===-- MathExtras.cpp - Implement the MathExtras header ------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515 #ifdef _MSC_VER
1616 #include
1717 #else
18 #include <math.h>
18 #include <cmath>
1919 #endif
2020
2121 namespace llvm {
2828 const float huge_valf = HUGE_VALF;
2929 #endif
3030
31 }
31 } // end namespace llvm
2121 #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
2222 // Define all methods as no-ops if threading is explicitly disabled
2323 namespace llvm {
24
2425 using namespace sys;
26
2527 MutexImpl::MutexImpl( bool recursive) { }
2628 MutexImpl::~MutexImpl() { }
2729 bool MutexImpl::acquire() { return true; }
2830 bool MutexImpl::release() { return true; }
2931 bool MutexImpl::tryacquire() { return true; }
30 }
32
33 } // end namespace llvm
3134 #else
3235
3336 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
3437
3538 #include
39 #include
3640 #include
37 #include
3841
3942 namespace llvm {
43
4044 using namespace sys;
4145
4246 // Construct a Mutex using pthread calls
109113 return errorcode == 0;
110114 }
111115
112 }
116 } // end namespace llvm
113117
114118 #elif defined(LLVM_ON_UNIX)
115119 #include "Unix/Mutex.inc"
1212
1313 #include "llvm/Config/config.h"
1414 #include "llvm/Support/RWMutex.h"
15 #include
1615
1716 //===----------------------------------------------------------------------===//
1817 //=== WARNING: Implementation here must contain only TRULY operating system
2221 #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
2322 // Define all methods as no-ops if threading is explicitly disabled
2423 namespace llvm {
24
2525 using namespace sys;
26
2627 RWMutexImpl::RWMutexImpl() { }
2728 RWMutexImpl::~RWMutexImpl() { }
2829 bool RWMutexImpl::reader_acquire() { return true; }
2930 bool RWMutexImpl::reader_release() { return true; }
3031 bool RWMutexImpl::writer_acquire() { return true; }
3132 bool RWMutexImpl::writer_release() { return true; }
32 }
33
34 } // end namespace llvm
3335 #else
3436
3537 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_RWLOCK_INIT)
3638
3739 #include
40 #include
3841 #include
39 #include
4042
4143 namespace llvm {
44
4245 using namespace sys;
4346
4447 // Construct a RWMutex using pthread calls
112115 return errorcode == 0;
113116 }
114117
115 }
118 } // end namespace llvm
116119
117120 #elif defined(LLVM_ON_UNIX)
118121 #include "Unix/RWMutex.inc"
None //======- SHA1.h - Private copy of the SHA1 implementation ---*- C++ -* ======//
0 //===--- SHA1.h - Private copy of the SHA1 implementation -------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1212 //
1313 //===----------------------------------------------------------------------===//
1414
15 #include "llvm/ADT/StringRef.h"
1516 #include "llvm/Support/Host.h"
1617 #include "llvm/Support/SHA1.h"
18
19 #include
20
1721 using namespace llvm;
18
19 #include
20 #include
2122
2223 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
2324 #define SHA_BIG_ENDIAN
4546 InternalState.BufferOffset = 0;
4647 }
4748
48 static uint32_t rol32(uint32_t number, uint8_t bits) {
49 namespace {
50
51 uint32_t rol32(uint32_t number, uint8_t bits) {
4952 return ((number << bits) | (number >> (32 - bits)));
5053 }
54
55 } // end anonymous namespace
5156
5257 void SHA1::hashBlock() {
5358 uint8_t i;
1313 //
1414 //===----------------------------------------------------------------------===//
1515
16 #include <string.h>
16 #include <cstring>
17
18 namespace {
1719
1820 // Must declare the symbols in the global namespace.
19 static void *DoSearch(const char* symbolName) {
21 void *DoSearch(const char* symbolName) {
2022 #define EXPLICIT_SYMBOL(SYM) \
2123 extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM
2224
5052 return nullptr;
5153 }
5254
55 } // end anonymous namespace
56
5357 namespace llvm {
58
5459 void *SearchForAddressOfSpecialSymbol(const char* symbolName) {
5560 return DoSearch(symbolName);
5661 }
57 } // namespace llvm
62
63 } // end namespace llvm
1616 //===----------------------------------------------------------------------===//
1717
1818 #include "Unix.h"
19 #include
20 #include <stdio.h>
19 #include <cassert>
20 #include
21 #include
2122 #if HAVE_SYS_STAT_H
2223 #include
2324 #endif
8586 #if defined(__FreeBSD__) || defined (__NetBSD__) || defined(__Bitrig__) || \
8687 defined(__OpenBSD__) || defined(__minix) || defined(__FreeBSD_kernel__) || \
8788 defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__)
88 static int
89
90 namespace {
91
92 int
8993 test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
9094 {
9195 struct stat sb;
100104 return 0;
101105 }
102106
103 static char *
107 char *
104108 getprogpath(char ret[PATH_MAX], const char *bin)
105109 {
106110 char *pv, *s, *t;
137141 free(pv);
138142 return nullptr;
139143 }
144
145 } // end anonymous namespace
146
140147 #endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__
141148
142149 /// GetMainExecutable - Return the path to the main executable, given the
329336 return std::error_code();
330337 }
331338
332 static int convertAccessMode(AccessMode Mode) {
339 namespace {
340
341 int convertAccessMode(AccessMode Mode) {
333342 switch (Mode) {
334343 case AccessMode::Exist:
335344 return F_OK;
341350 llvm_unreachable("invalid enum");
342351 }
343352
353 } // end anonymous namespace
354
344355 std::error_code access(const Twine &Path, AccessMode Mode) {
345356 SmallString<128> PathStorage;
346357 StringRef P = Path.toNullTerminatedStringRef(PathStorage);
380391 return std::error_code();
381392 }
382393
383 static std::error_code fillStatus(int StatRet, const struct stat &Status,
384 file_status &Result) {
394 namespace {
395
396 std::error_code fillStatus(int StatRet, const struct stat &Status,
397 file_status &Result) {
385398 if (StatRet != 0) {
386399 std::error_code ec(errno, std::generic_category());
387400 if (ec == errc::no_such_file_or_directory)
415428 return std::error_code();
416429 }
417430
431 } // end anonymous namespace
432
418433 std::error_code status(const Twine &Path, file_status &Result) {
419434 SmallString<128> PathStorage;
420435 StringRef P = Path.toNullTerminatedStringRef(PathStorage);
596611 return false;
597612 }
598613
599 static bool getDarwinConfDir(bool TempDir, SmallVectorImpl &Result) {
614 namespace {
615
616 bool getDarwinConfDir(bool TempDir, SmallVectorImpl &Result) {
600617 #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
601618 // On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
602619 // macros defined in on darwin >= 9
621638 return false;
622639 }
623640
624 static bool getUserCacheDir(SmallVectorImpl &Result) {
641 bool getUserCacheDir(SmallVectorImpl &Result) {
625642 // First try using XDG_CACHE_HOME env variable,
626643 // as specified in XDG Base Directory Specification at
627644 // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
644661 return false;
645662 }
646663
647 static const char *getEnvTempDir() {
664 const char *getEnvTempDir() {
648665 // Check whether the temporary directory is specified by an environment
649666 // variable.
650667 const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
656673 return nullptr;
657674 }
658675
659 static const char *getDefaultTempDir(bool ErasedOnReboot) {
676 const char *getDefaultTempDir(bool ErasedOnReboot) {
660677 #ifdef P_tmpdir
661678 if ((bool)P_tmpdir)
662679 return P_tmpdir;
666683 return "/tmp";
667684 return "/var/tmp";
668685 }
686
687 } // end anonymous namespace
669688
670689 void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl &Result) {
671690 Result.clear();
2929 #ifdef HAVE_SYS_STAT_H
3030 #include
3131 #endif
32 #if HAVE_SIGNAL_H
33 #include
34 #endif
32 #include
3533 // DragonFlyBSD, OpenBSD, and Bitrig have deprecated for
3634 // instead. Unix.h includes this for us already.
3735 #if defined(HAVE_MALLOC_H) && !defined(__DragonFly__) && \
5957 using namespace llvm;
6058 using namespace sys;
6159
62 static std::pair getRUsageTimes() {
60 namespace {
61
62 std::pair getRUsageTimes() {
6363 #if defined(HAVE_GETRUSAGE)
6464 struct rusage RU;
6565 ::getrusage(RUSAGE_SELF, &RU);
7777 return std::make_pair(TimeValue(), TimeValue());
7878 #endif
7979 }
80
81 } // end anonymous namespace
8082
8183 // On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
8284 // offset in mmap(3) should be aligned to the AllocationGranularity.
188190 }
189191
190192 namespace {
193
191194 class FDCloser {
192195 public:
193196 FDCloser(int &FD) : FD(FD), KeepOpen(false) {}
204207 int &FD;
205208 bool KeepOpen;
206209 };
207 }
210
211 } // end anonymous namespace
208212
209213 std::error_code Process::FixupStandardFileDescriptors() {
210214 int NullFD = -1;
299303 #endif
300304 }
301305
302 static unsigned getColumns(int FileID) {
306 namespace {
307
308 unsigned getColumns(int FileID) {
303309 // If COLUMNS is defined in the environment, wrap to that many columns.
304310 if (const char *ColumnsStr = std::getenv("COLUMNS")) {
305311 int Columns = std::atoi(ColumnsStr);
318324
319325 return Columns;
320326 }
327
328 } // end anonymous namespace
321329
322330 unsigned Process::StandardOutColumns() {
323331 if (!StandardOutIsDisplayed())
343351 extern "C" int tigetnum(char *capname);
344352 #endif
345353
354 namespace {
355
346356 #ifdef HAVE_TERMINFO
347 static ManagedStatic TermColorMutex;
348 #endif
349
350 static bool terminalHasColors(int fd) {
357 ManagedStatic TermColorMutex;
358 #endif
359
360 bool terminalHasColors(int fd) {
351361 #ifdef HAVE_TERMINFO
352362 // First, acquire a global lock because these C routines are thread hostile.
353363 MutexGuard G(*TermColorMutex);
387397 return false;
388398 }
389399
400 } // end anonymous namespace
401
390402 bool Process::FileDescriptorHasColors(int fd) {
391403 // A file descriptor has colors if it is displayed and the terminal has
392404 // colors.
427439 }
428440
429441 #if !defined(HAVE_DECL_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM
430 static unsigned GetRandomNumberSeed() {
442
443 namespace {
444
445 unsigned GetRandomNumberSeed() {
431446 // Attempt to get the initial seed from /dev/urandom, if possible.
432447 int urandomFD = open("/dev/urandom", O_RDONLY);
433448
449464 TimeValue Now = TimeValue::now();
450465 return hash_combine(Now.seconds(), Now.nanoseconds(), ::getpid());
451466 }
467
468 } // end anonymous namespace
469
452470 #endif
453471
454472 unsigned llvm::sys::Process::GetRandomNumber() {
None //===- llvm/Support/Unix/Program.cpp -----------------------------*- C++ -*-===//
0 //===- llvm/Support/Unix/Program.cpp ----------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2929 #if HAVE_SYS_RESOURCE_H
3030 #include
3131 #endif
32 #if HAVE_SIGNAL_H
33 #include
34 #endif
32 #include
3533 #if HAVE_FCNTL_H
3634 #include
3735 #endif
9593 return errc::no_such_file_or_directory;
9694 }
9795
98 static bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) {
96 namespace {
97
98 bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) {
9999 if (!Path) // Noop
100100 return false;
101101 std::string File;
124124 }
125125
126126 #ifdef HAVE_POSIX_SPAWN
127 static bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg,
128 posix_spawn_file_actions_t *FileActions) {
127 bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg,
128 posix_spawn_file_actions_t *FileActions) {
129129 if (!Path) // Noop
130130 return false;
131131 const char *File;
143143 }
144144 #endif
145145
146 static void TimeOutHandler(int Sig) {
147 }
148
149 static void SetMemoryLimits (unsigned size)
146 void TimeOutHandler(int Sig) {
147 }
148
149 void SetMemoryLimits (unsigned size)
150150 {
151151 #if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT
152152 struct rlimit r;
175175 #endif
176176 }
177177
178 }
178 } // end anonymous namespace
179
180 } // end namespace llvm
179181
180182 static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
181183 const char **envp, const StringRef **redirects,
418420 return WaitResult;
419421 }
420422
421 std::error_code sys::ChangeStdinToBinary(){
423 std::error_code sys::ChangeStdinToBinary() {
422424 // Do nothing, as Unix doesn't differentiate between text and binary.
423425 return std::error_code();
424426 }
425427
426 std::error_code sys::ChangeStdoutToBinary(){
428 std::error_code sys::ChangeStdoutToBinary() {
427429 // Do nothing, as Unix doesn't differentiate between text and binary.
428430 return std::error_code();
429431 }
465467 }
466468 return true;
467469 }
468 }
470
471 } // end namespace llvm
None //===- Signals.cpp - Generic Unix Signals Implementation -----*- C++ -*-===//
0 //===- Signals.cpp - Generic Unix Signals Implementation --------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2626 #if HAVE_EXECINFO_H
2727 # include // For backtrace().
2828 #endif
29 #if HAVE_SIGNAL_H
30 #include
31 #endif
29 #include
3230 #if HAVE_SYS_STAT_H
3331 #include
3432 #endif
4745
4846 using namespace llvm;
4947
50 static RETSIGTYPE SignalHandler(int Sig); // defined below.
51
52 static ManagedStatic > SignalsMutex;
48 namespace {
49
50 RETSIGTYPE SignalHandler(int Sig); // defined below.
51
52 ManagedStatic > SignalsMutex;
5353
5454 /// InterruptFunction - The function to call if ctrl-c is pressed.
55 static void (*InterruptFunction)() = nullptr;
56
57 static ManagedStatic> FilesToRemove;
55 void (*InterruptFunction)() = nullptr;
56
57 ManagedStatic> FilesToRemove;
5858
5959 // IntSigs - Signals that represent requested termination. There's no bug
6060 // or failure, or if there is, it's not our direct responsibility. For whatever
6161 // reason, our continued execution is no longer desirable.
62 static const int IntSigs[] = {
62 const int IntSigs[] = {
6363 SIGHUP, SIGINT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2
6464 };
6565
6666 // KillSigs - Signals that represent that we have a bug, and our prompt
6767 // termination has been ordered.
68 static const int KillSigs[] = {
68 const int KillSigs[] = {
6969 SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGQUIT
7070 #ifdef SIGSYS
7171 , SIGSYS
8181 #endif
8282 };
8383
84 static unsigned NumRegisteredSignals = 0;
85 static struct {
84 unsigned NumRegisteredSignals = 0;
85 struct {
8686 struct sigaction SA;
8787 int SigNo;
8888 } RegisteredSignalInfo[array_lengthof(IntSigs) + array_lengthof(KillSigs)];
8989
90
91 static void RegisterHandler(int Signal) {
90 void RegisterHandler(int Signal) {
9291 assert(NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) &&
9392 "Out of space for signal handlers!");
9493
105104 ++NumRegisteredSignals;
106105 }
107106
108 static void RegisterHandlers() {
107 void RegisterHandlers() {
109108 // We need to dereference the signals mutex during handler registration so
110109 // that we force its construction. This is to prevent the first use being
111110 // during handling an actual signal because you can't safely call new in a
119118 for (auto S : KillSigs) RegisterHandler(S);
120119 }
121120
122 static void UnregisterHandlers() {
121 void UnregisterHandlers() {
123122 // Restore all of the signal handlers to how they were before we showed up.
124123 for (unsigned i = 0, e = NumRegisteredSignals; i != e; ++i)
125124 sigaction(RegisteredSignalInfo[i].SigNo,
127126 NumRegisteredSignals = 0;
128127 }
129128
130
131129 /// RemoveFilesToRemove - Process the FilesToRemove list. This function
132130 /// should be called with the SignalsMutex lock held.
133131 /// NB: This must be an async signal safe function. It cannot allocate or free
134132 /// memory, even in debug builds.
135 static void RemoveFilesToRemove() {
133 void RemoveFilesToRemove() {
136134 // Avoid constructing ManagedStatic in the signal handler.
137135 // If FilesToRemove is not constructed, there are no files to remove.
138136 if (!FilesToRemove.isConstructed())
163161 }
164162
165163 // SignalHandler - The signal handler that runs.
166 static RETSIGTYPE SignalHandler(int Sig) {
164 RETSIGTYPE SignalHandler(int Sig) {
167165 // Restore the signal behavior to default, so that the program actually
168166 // crashes when we return and the signal reissues. This also ensures that if
169167 // we crash in our signal handler that the program will terminate immediately
207205 raise(Sig);
208206 #endif
209207 }
208
209 } // end anonymous namespace
210210
211211 void llvm::sys::RunInterruptHandlers() {
212212 sys::SmartScopedLock Guard(*SignalsMutex);
263263 const char *main_exec_name;
264264 };
265265
266 static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
266 namespace {
267
268 int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
267269 DlIteratePhdrData *data = (DlIteratePhdrData*)arg;
268270 const char *name = data->first ? data->main_exec_name : info->dlpi_name;
269271 data->first = false;
286288 return 0;
287289 }
288290
291 } // end anonymous namespace
292
289293 /// If this is an ELF platform, we can find all loaded modules and their virtual
290294 /// addresses with dl_iterate_phdr.
291295 static bool findModulesAndOffsets(void **StackTrace, int Depth,
374378 #endif
375379 }
376380
377 static void PrintStackTraceSignalHandler(void *) {
381 namespace {
382
383 void PrintStackTraceSignalHandler(void *) {
378384 PrintStackTrace(llvm::errs());
379385 }
386
387 } // end anonymous namespace
380388
381389 void llvm::sys::DisableSystemDialogsOnCrash() {}
382390
401409 }
402410 #endif
403411 }
404
405
406 /***/
407412
408413 // On Darwin, raise sends a signal to the main thread instead of the current
409414 // thread. This has the unfortunate effect that assert() and abort() will end up
1818 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_GETSPECIFIC)
1919
2020 #include
21 #include
2122 #include
22 #include
2323
2424 namespace llvm {
25
2526 using namespace sys;
2627
2728 ThreadLocalImpl::ThreadLocalImpl() : data() {
5556 setInstance(nullptr);
5657 }
5758
58 }
59 } // end namespace llvm
5960 #else
61
6062 namespace llvm {
63
6164 using namespace sys;
65
6266 ThreadLocalImpl::ThreadLocalImpl() : data() { }
6367 ThreadLocalImpl::~ThreadLocalImpl() { }
6468 void ThreadLocalImpl::setInstance(const void* d) { data = const_cast(d);}
6569 void *ThreadLocalImpl::getInstance() { return data; }
6670 void ThreadLocalImpl::removeInstance() { setInstance(0); }
67 }
71
72 } // end namespace llvm
73
6874 #endif
None //===- llvm/Support/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===//
0 //===- llvm/Support/Unix/Unix.h - Common Unix Include File ------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2121 #include "llvm/Config/config.h" // Get autoconf configuration settings
2222 #include "llvm/Support/Errno.h"
2323 #include
24 #include <assert.h>
24 #include <cassert>
2525 #include
2626 #include
2727 #include
4141 #ifdef HAVE_SYS_TIME_H
4242 # include
4343 #endif
44 #include <time.h>
44 #include <ctime>
4545
4646 #ifdef HAVE_DLFCN_H
4747 # include
6464 return true;
6565 }
6666
67 #endif
67 #endif // LLVM_LIB_SUPPORT_UNIX_UNIX_H
3333 #include "llvm/Support/raw_ostream.h"
3434 #include "llvm/Target/TargetMachine.h"
3535 #include "llvm/Target/TargetOptions.h"
36 #include <stdint.h>
36 #include <cstdint>
37
3738 using namespace llvm;
3839
3940 #define DEBUG_TYPE "x86-isel"
140141 }
141142 #endif
142143 };
143 }
144 } // end anonymous namespace
144145
145146 namespace {
146147 //===--------------------------------------------------------------------===//
300301 // Walk all the users of the immediate.
301302 for (SDNode::use_iterator UI = N->use_begin(),
302303 UE = N->use_end(); (UI != UE) && (UseCount < 2); ++UI) {
303
304304 SDNode *User = *UI;
305305
306306 // This user is already selected. Count it as a legitimate use and
392392 return true;
393393 }
394394 };
395 }
396
395 } // end anonymous namespace
397396
398397 bool
399398 X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const {
458457 return true;
459458 }
460459
460 namespace {
461
461462 /// Replace the original chain operand of the call with
462463 /// load's chain operand and move load below the call's chain operand.
463 static void moveBelowOrigChain(SelectionDAG *CurDAG, SDValue Load,
464 SDValue Call, SDValue OrigChain) {
464 void moveBelowOrigChain(SelectionDAG *CurDAG, SDValue Load, SDValue Call,
465 SDValue OrigChain) {
465466 SmallVector Ops;
466467 SDValue Chain = OrigChain.getOperand(0);
467468 if (Chain.getNode() == Load.getNode())
495496 /// Return the CALLSEQ_START by reference as a second output.
496497 /// In the case of a tail call, there isn't a callseq node between the call
497498 /// chain and the load.
498 static bool isCalleeLoad(SDValue Callee, SDValue &Chain, bool HasCallSeq) {
499 bool isCalleeLoad(SDValue Callee, SDValue &Chain, bool HasCallSeq) {
499500 // The transformation is somewhat dangerous if the call's chain was glued to
500501 // the call. After MoveBelowOrigChain the load is moved between the call and
501502 // the chain, this can create a cycle if the load is not folded. So it is
531532 return true;
532533 return false;
533534 }
535
536 } // end anonymous namespace
534537
535538 void X86DAGToDAGISel::PreprocessISelDAG() {
536539 // OptFor[Min]Size are used in pattern predicates that isel is matching.
650653 }
651654 }
652655
653
654656 /// Emit any code that needs to be executed only in the main function.
655657 void X86DAGToDAGISel::emitSpecialCodeForMain() {
656658 if (Subtarget->isTargetCygMing()) {
675677 emitSpecialCodeForMain();
676678 }
677679
678 static bool isDispSafeForFrameIndex(int64_t Val) {
680 namespace {
681
682 bool isDispSafeForFrameIndex(int64_t Val) {
679683 // On 64-bit platforms, we can run into an issue where a frame index
680684 // includes a displacement that, when added to the explicit displacement,
681685 // will overflow the displacement field. Assuming that the frame index
684688 // a 32-bit integer), a 31-bit disp should always be safe.
685689 return isInt<31>(Val);
686690 }
691
692 } // end anonymous namespace
687693
688694 bool X86DAGToDAGISel::foldOffsetIntoAddress(uint64_t Offset,
689695 X86ISelAddressMode &AM) {
704710 }
705711 AM.Disp = Val;
706712 return false;
707
708713 }
709714
710715 bool X86DAGToDAGISel::matchLoadInAddress(LoadSDNode *N, X86ISelAddressMode &AM){
895900 return true;
896901 }
897902
903 namespace {
904
898905 // Insert a node into the DAG at least before the Pos node's position. This
899906 // will reposition the node as needed, and will assign it a node ID that is <=
900907 // the Pos node's ID. Note that this does *not* preserve the uniqueness of node
901908 // IDs! The selection DAG must no longer depend on their uniqueness when this
902909 // is used.
903 static void insertDAGNode(SelectionDAG &DAG, SDValue Pos, SDValue N) {
910 void insertDAGNode(SelectionDAG &DAG, SDValue Pos, SDValue N) {
904911 if (N.getNode()->getNodeId() == -1 ||
905912 N.getNode()->getNodeId() > Pos.getNode()->getNodeId()) {
906913 DAG.RepositionNode(Pos.getNode()->getIterator(), N.getNode());
912919 // safe. This allows us to convert the shift and and into an h-register
913920 // extract and a scaled index. Returns false if the simplification is
914921 // performed.
915 static bool foldMaskAndShiftToExtract(SelectionDAG &DAG, SDValue N,
916 uint64_t Mask,
917 SDValue Shift, SDValue X,
918 X86ISelAddressMode &AM) {
922 bool foldMaskAndShiftToExtract(SelectionDAG &DAG, SDValue N, uint64_t Mask,
923 SDValue Shift, SDValue X,
924 X86ISelAddressMode &AM) {
919925 if (Shift.getOpcode() != ISD::SRL ||
920926 !isa(Shift.getOperand(1)) ||
921927 !Shift.hasOneUse())
955961 // Transforms "(X << C1) & C2" to "(X & (C2>>C1)) << C1" if safe and if this
956962 // allows us to fold the shift into this addressing mode. Returns false if the
957963 // transform succeeded.
958 static bool foldMaskedShiftToScaledMask(SelectionDAG &DAG, SDValue N,
959 uint64_t Mask,
960 SDValue Shift, SDValue X,
961 X86ISelAddressMode &AM) {
964 bool foldMaskedShiftToScaledMask(SelectionDAG &DAG, SDValue N, uint64_t Mask,
965 SDValue Shift, SDValue X,
966 X86ISelAddressMode &AM) {
962967 if (Shift.getOpcode() != ISD::SHL ||
963968 !isa(Shift.getOperand(1)))
964969 return true;
10221027 // Note that this function assumes the mask is provided as a mask *after* the
10231028 // value is shifted. The input chain may or may not match that, but computing
10241029 // such a mask is trivial.
1025 static bool foldMaskAndShiftToScale(SelectionDAG &DAG, SDValue N,
1026 uint64_t Mask,
1027 SDValue Shift, SDValue X,
1028 X86ISelAddressMode &AM) {
1030 bool foldMaskAndShiftToScale(SelectionDAG &DAG, SDValue N, uint64_t Mask,
1031 SDValue Shift, SDValue X, X86ISelAddressMode &AM) {
10291032 if (Shift.getOpcode() != ISD::SRL || !Shift.hasOneUse() ||
10301033 !isa(Shift.getOperand(1)))
10311034 return true;
11021105 AM.IndexReg = NewSRL;
11031106 return false;
11041107 }
1108
1109 } // end anonymous namespace
11051110
11061111 bool X86DAGToDAGISel::matchAddressRecursively(SDValue N, X86ISelAddressMode &AM,
11071112 unsigned Depth) {
14171422 bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
14181423 SDValue &Scale, SDValue &Index,
14191424 SDValue &Disp, SDValue &Segment) {
1420
14211425 MaskedGatherScatterSDNode *Mgs = dyn_cast(Parent);
14221426 if (!Mgs)
14231427 return false;
15401544 return false;
15411545 }
15421546
1543
15441547 bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
15451548 if (const ConstantSDNode *CN = dyn_cast(N)) {
15461549 uint64_t ImmVal = CN->getZExtValue();
16941697 return true;
16951698 }
16961699
1697
16981700 bool X86DAGToDAGISel::tryFoldLoad(SDNode *P, SDValue N,
16991701 SDValue &Base, SDValue &Scale,
17001702 SDValue &Index, SDValue &Disp,
17171719 return CurDAG->getRegister(GlobalBaseReg, TLI->getPointerTy(DL)).getNode();
17181720 }
17191721
1722 namespace {
1723
17201724 /// Test whether the given X86ISD::CMP node has any uses which require the SF
17211725 /// or OF bits to be accurate.
1722 static bool hasNoSignedComparisonUses(SDNode *N) {
1726 bool hasNoSignedComparisonUses(SDNode *N) {
17231727 // Examine each user of the node.
17241728 for (SDNode::use_iterator UI = N->use_begin(),
17251729 UE = N->use_end(); UI != UE; ++UI) {
17811785
17821786 /// Check whether or not the chain ending in StoreNode is suitable for doing
17831787 /// the {load; increment or decrement; store} to modify transformation.
1784 static bool isLoadIncOrDecStore(StoreSDNode *StoreNode, unsigned Opc,
1785 SDValue StoredVal, SelectionDAG *CurDAG,
1786 LoadSDNode* &LoadNode, SDValue &InputChain) {
1787
1788 bool isLoadIncOrDecStore(StoreSDNode *StoreNode, unsigned Opc,
1789 SDValue StoredVal, SelectionDAG *CurDAG,
1790 LoadSDNode* &LoadNode, SDValue &InputChain) {
17881791 // is the value stored the result of a DEC or INC?
17891792 if (!(Opc == X86ISD::DEC || Opc == X86ISD::INC)) return false;
17901793
18661869
18671870 /// Get the appropriate X86 opcode for an in-memory increment or decrement.
18681871 /// Opc should be X86ISD::DEC or X86ISD::INC.
1869 static unsigned getFusedLdStOpcode(EVT &LdVT, unsigned Opc) {
1872 unsigned getFusedLdStOpcode(EVT &LdVT, unsigned Opc) {
18701873 if (Opc == X86ISD::DEC) {
18711874 if (LdVT == MVT::i64) return X86::DEC64m;
18721875 if (LdVT == MVT::i32) return X86::DEC32m;
18811884 }
18821885 llvm_unreachable("unrecognized size for LdVT");
18831886 }
1887
1888 } // end anonymous namespace
18841889
18851890 /// Customized ISel for GATHER operations.
18861891 SDNode *X86DAGToDAGISel::selectGather(SDNode *Node, unsigned Opc) {
1515 //===----------------------------------------------------------------------===//
1616
1717 #include "llvm-c-test.h"
18 #include "llvm-c/Core.h"
19 #include "llvm-c/ErrorHandling.h"
1820 #include "llvm-c/Target.h"
21 #include "llvm-c/Types.h"
1922 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/Hashing.h"
24 #include "llvm/ADT/SmallVector.h"
2025 #include "llvm/Support/ErrorHandling.h"
2126
22 #include
23 #include <stdlib.h>
27 #include <cstdio>
28 #include
29 #include
2430
2531 using namespace llvm;
2632
3844 uintptr_t Val = static_cast(-1);
3945 return reinterpret_cast(Val);
4046 }
47
4148 static inline T* getTombstoneKey() {
4249 uintptr_t Val = static_cast(-2);
4350 return reinterpret_cast(Val);
4451 }
52
4553 static unsigned getHashValue(const T *PtrVal) {
4654 return hash_value(PtrVal);
4755 }
56
4857 static bool isEqual(const T *LHS, const T *RHS) { return LHS == RHS; }
4958 };
5059
153162 }
154163 };
155164
156 static ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
165 namespace {
166
167 ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
157168 unsigned Count = LLVMCountParams(Src);
158169 if (Count != LLVMCountParams(Dst))
159170 report_fatal_error("Parameter count mismatch");
210221
211222 return VMap;
212223 }
224
225 } // end anonymous namespace
213226
214227 LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
215228 if (!LLVMIsAConstant(Cst))
709722 }
710723 };
711724
712 static void declare_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
725 namespace {
726
727 void declare_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
713728 LLVMValueRef Begin = LLVMGetFirstGlobal(Src);
714729 LLVMValueRef End = LLVMGetLastGlobal(Src);
715730
773788 }
774789 }
775790
776 static void clone_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
791 void clone_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
777792 LLVMValueRef Begin = LLVMGetFirstGlobal(Src);
778793 LLVMValueRef End = LLVMGetLastGlobal(Src);
779794
860875 }
861876 }
862877
878 } // end anonymous namespace
879
863880 int llvm_echo(void) {
864881 LLVMEnablePrettyStackTrace();
865882
99 |* Header file for llvm-c-test *|
1010 |* *|
1111 \*===----------------------------------------------------------------------===*/
12
1213 #ifndef LLVM_C_TEST_H
1314 #define LLVM_C_TEST_H
1415
16 #ifdef __cplusplus
17 #include
18 #else
1519 #include
20 #endif
1621 #include "llvm-c/Core.h"
1722
1823 #ifdef __cplusplus
5055
5156 #ifdef __cplusplus
5257 }
53 #endif /* !defined(__cplusplus) */
58 #endif
5459
55 #endif
60 #endif // LLVM_C_TEST_H
3939 #include "llvm/Support/Win64EH.h"
4040 #include "llvm/Support/raw_ostream.h"
4141 #include
42 #include string>
42 #include assert>
43 #include
44 #include
45 #include
46 #include
47 #include
4348 #include
44 #include <time.h>
49 #include <vector>
4550
4651 using namespace llvm;
4752 using namespace llvm::object;
7075 void printCOFFBaseReloc() override;
7176 void printCodeViewDebugInfo() override;
7277 void printStackMap() const override;
78
7379 private:
7480 void printSymbol(const SymbolRef &Sym);
7581 void printRelocation(const SectionRef &Section, const RelocationRef &Reloc,
143149 StringSet<> TypeNames;
144150 };
145151
146 } // namespace
147
152 } // end anonymous namespace
148153
149154 namespace llvm {
150155
159164 return readobj_error::success;
160165 }
161166
162 } // namespace llvm
167 } // end namespace llvm
163168
164169 // Given a a section and an offset into this section the function returns the
165170 // symbol used for the relocation at the offset.
242247 }
243248 }
244249
245 static const EnumEntry ImageFileMachineType[] = {
250 namespace {
251
252 const EnumEntry ImageFileMachineType[] = {
246253 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_UNKNOWN ),
247254 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AM33 ),
248255 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AMD64 ),
266273 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_WCEMIPSV2)
267274 };
268275
269 static const EnumEntry ImageFileCharacteristics[] = {
276 const EnumEntry ImageFileCharacteristics[] = {
270277 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_RELOCS_STRIPPED ),
271278 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_EXECUTABLE_IMAGE ),
272279 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_LINE_NUMS_STRIPPED ),
284291 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_BYTES_REVERSED_HI )
285292 };
286293
287 static const EnumEntry PEWindowsSubsystem[] = {
294 const EnumEntry PEWindowsSubsystem[] = {
288295 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_UNKNOWN ),
289296 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_NATIVE ),
290297 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_WINDOWS_GUI ),
298305 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_XBOX ),
299306 };
300307
301 static const EnumEntry PEDLLCharacteristics[] = {
308 const EnumEntry PEDLLCharacteristics[] = {
302309 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA ),
303310 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE ),
304311 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY ),
312319 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE),
313320 };
314321
315 static const EnumEntry
322 const EnumEntry
316323 ImageSectionCharacteristics[] = {
317324 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NOLOAD ),
318325 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NO_PAD ),
352359 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_WRITE )
353360 };
354361
355 static const EnumEntry ImageSymType[] = {
362 const EnumEntry ImageSymType[] = {
356363 { "Null" , COFF::IMAGE_SYM_TYPE_NULL },
357364 { "Void" , COFF::IMAGE_SYM_TYPE_VOID },
358365 { "Char" , COFF::IMAGE_SYM_TYPE_CHAR },
371378 { "DWord" , COFF::IMAGE_SYM_TYPE_DWORD }
372379 };
373380
374 static const EnumEntry ImageSymDType[] = {
381 const EnumEntry ImageSymDType[] = {
375382 { "Null" , COFF::IMAGE_SYM_DTYPE_NULL },
376383 { "Pointer" , COFF::IMAGE_SYM_DTYPE_POINTER },
377384 { "Function", COFF::IMAGE_SYM_DTYPE_FUNCTION },
378385 { "Array" , COFF::IMAGE_SYM_DTYPE_ARRAY }
379386 };
380387
381 static const EnumEntry ImageSymClass[] = {
388 const EnumEntry ImageSymClass[] = {
382389 { "EndOfFunction" , COFF::IMAGE_SYM_CLASS_END_OF_FUNCTION },
383390 { "Null" , COFF::IMAGE_SYM_CLASS_NULL },
384391 { "Automatic" , COFF::IMAGE_SYM_CLASS_AUTOMATIC },
408415 { "CLRToken" , COFF::IMAGE_SYM_CLASS_CLR_TOKEN }
409416 };
410417
411 static const EnumEntry ImageCOMDATSelect[] = {
418 const EnumEntry ImageCOMDATSelect[] = {
412419 { "NoDuplicates", COFF::IMAGE_COMDAT_SELECT_NODUPLICATES },
413420 { "Any" , COFF::IMAGE_COMDAT_SELECT_ANY },
414421 { "SameSize" , COFF::IMAGE_COMDAT_SELECT_SAME_SIZE },
418425 { "Newest" , COFF::IMAGE_COMDAT_SELECT_NEWEST }
419426 };
420427
421 static const EnumEntry
428 const EnumEntry
422429 WeakExternalCharacteristics[] = {
423430 { "NoLibrary", COFF::IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY },
424431 { "Library" , COFF::IMAGE_WEAK_EXTERN_SEARCH_LIBRARY },
425432 { "Alias" , COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS }
426433 };
427434
428 static const EnumEntry CompileSym3Flags[] = {
435 const EnumEntry CompileSym3Flags[] = {
429436 LLVM_READOBJ_ENUM_ENT(CompileSym3, EC),
430437 LLVM_READOBJ_ENUM_ENT(CompileSym3, NoDbgInfo),
431438 LLVM_READOBJ_ENUM_ENT(CompileSym3, LTCG),
440447 LLVM_READOBJ_ENUM_ENT(CompileSym3, Exp),
441448 };
442449
443 static const EnumEntry SourceLanguages[] = {
450 const EnumEntry SourceLanguages[] = {
444451 LLVM_READOBJ_ENUM_ENT(SourceLanguage, C),
445452 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Cpp),
446453 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Fortran),
460467 LLVM_READOBJ_ENUM_ENT(SourceLanguage, HLSL),
461468 };
462469
463 static const EnumEntry SubSectionTypes[] = {
470 const EnumEntry SubSectionTypes[] = {
464471 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, Symbols),
465472 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, Lines),
466473 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, StringTable),
476483 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, CoffSymbolRVA),
477484 };
478485
479 static const EnumEntry CPUTypeNames[] = {
486 const EnumEntry CPUTypeNames[] = {
480487 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel8080),
481488 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel8086),
482489 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel80286),
538545 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, D3D11_Shader),
539546 };
540547
541 static const EnumEntry ProcSymFlags[] = {
548 const EnumEntry ProcSymFlags[] = {
542549 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasFP),
543550 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasIRET),
544551 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasFRET),
549556 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasOptimizedDebugInfo),
550557 };
551558
552 static const EnumEntry FrameProcSymFlags[] = {
559 const EnumEntry FrameProcSymFlags[] = {
553560 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasAlloca),
554561 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasSetJmp),
555562 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasLongJmp),
575582 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, GuardCfw),
576583 };
577584
578 static const EnumEntry FrameDataFlags[] = {
585 const EnumEntry FrameDataFlags[] = {
579586 LLVM_READOBJ_ENUM_ENT(FrameData, HasSEH),
580587 LLVM_READOBJ_ENUM_ENT(FrameData, HasEH),
581588 LLVM_READOBJ_ENUM_ENT(FrameData, IsFunctionStart),
582589 };
583590
584 static const EnumEntry LocalFlags[] = {
591 const EnumEntry LocalFlags[] = {
585592 LLVM_READOBJ_ENUM_ENT(LocalSym, IsParameter),
586593 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAddressTaken),
587594 LLVM_READOBJ_ENUM_ENT(LocalSym, IsCompilerGenerated),
595602 LLVM_READOBJ_ENUM_ENT(LocalSym, IsEnregisteredStatic),
596603 };
597604
598 static const EnumEntry FrameCookieKinds[] = {
605 const EnumEntry FrameCookieKinds[] = {
599606 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, Copy),
600607 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorStackPointer),
601608 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorFramePointer),
602609 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorR13),
603610 };
604611
605 static const EnumEntry ClassOptionNames[] = {
612 const EnumEntry ClassOptionNames[] = {
606613 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Packed),
607614 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasConstructorOrDestructor),
608615 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasOverloadedOperator),
617624 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Intrinsic),
618625 };
619626
620 static const EnumEntry MemberAccessNames[] = {
627 const EnumEntry MemberAccessNames[] = {
621628 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, None),
622629 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Private),
623630 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Protected),
624631 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Public),
625632 };
626633
627 static const EnumEntry MethodOptionNames[] = {
634 const EnumEntry MethodOptionNames[] = {
628635 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, Pseudo),
629636 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, NoInherit),
630637 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, NoConstruct),
632639 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, Sealed),
633640 };
634641
635 static const EnumEntry MemberKindNames[] = {
642 const EnumEntry MemberKindNames[] = {
636643 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Vanilla),
637644 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Virtual),
638645 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Static),
645652 /// The names here all end in "*". If the simple type is a pointer type, we
646653 /// return the whole name. Otherwise we lop off the last character in our
647654 /// StringRef.
648 static const EnumEntry SimpleTypeNames[] = {
655 const EnumEntry SimpleTypeNames[] = {
649656 {"void*", SimpleTypeKind::Void},
650657 {"*", SimpleTypeKind::NotTranslated},
651658 {"HRESULT*", SimpleTypeKind::HResult},
686693 {"__bool64*", SimpleTypeKind::Boolean64},
687694 };
688695
689 static const EnumEntry LeafTypeNames[] = {
696 const EnumEntry LeafTypeNames[] = {
690697 #define LEAF_TYPE(name, val) LLVM_READOBJ_ENUM_ENT(TypeLeafKind, name),
691698 #include "llvm/DebugInfo/CodeView/CVLeafTypes.def"
692699 };
693700
694 static const EnumEntry PtrKindNames[] = {
701 const EnumEntry PtrKindNames[] = {
695702 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near16),
696703 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Far16),
697704 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Huge16),
707714 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near64),
708715 };
709716
710 static const EnumEntry PtrModeNames[] = {
717 const EnumEntry PtrModeNames[] = {
711718 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, Pointer),
712719 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, LValueReference),
713720 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, PointerToDataMember),
715722 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, RValueReference),
716723 };
717724
718 static const EnumEntry PtrMemberRepNames[] = {
725 const EnumEntry PtrMemberRepNames[] = {
719726 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, Unknown),
720727 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
721728 SingleInheritanceData),
733740 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, GeneralFunction),
734741 };
735742
736 static const EnumEntry TypeModifierNames[] = {
743 const EnumEntry TypeModifierNames[] = {
737744 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Const),
738745 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Volatile),
739746 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Unaligned),
740747 };
741748
742 static const EnumEntry CallingConventions[] = {
749 const EnumEntry CallingConventions[] = {
743750 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearC),
744751 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarC),
745752 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearPascal),
766773 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearVector),
767774 };
768775
769 static const EnumEntry FunctionOptionEnum[] = {
776 const EnumEntry FunctionOptionEnum[] = {
770777 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, CxxReturnUdt),
771778 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, Constructor),
772779 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, ConstructorWithVirtualBases),
773780 };
774781
775 static const EnumEntry FileChecksumKindNames[] = {
782 const EnumEntry FileChecksumKindNames[] = {
776783 LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, None),
777784 LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, MD5),
778785 LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, SHA1),
780787 };
781788
782789 template
783 static std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
790 std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
784791 COFFSymbolRef Symbol,
785792 uint8_t AuxSymbolIdx, const T *&Aux) {
786793 ArrayRef AuxData = Obj->getSymbolAuxData(Symbol);
788795 Aux = reinterpret_cast(AuxData.data());
789796 return readobj_error::success;
790797 }
798
799 } // end anonymous namespace
791800
792801 void COFFDumper::cacheRelocations() {
793802 if (RelocCached)
939948 }
940949 }
941950
951 namespace {
952
942953 /// Consumes sizeof(T) bytes from the given byte sequence. Returns an error if
943954 /// there are not enough bytes remaining. Reinterprets the consumed bytes as a
944955 /// T object and points 'Res' at them.
945956 template
946 static std::error_code consumeObject(StringRef &Data, const T *&Res) {
957 std::error_code consumeObject(StringRef &Data, const T *&Res) {
947958 if (Data.size() < sizeof(*Res))
948959 return object_error::parse_failed;
949960 Res = reinterpret_cast(Data.data());
951962 return std::error_code();
952963 }
953964
954 static std::error_code consumeUInt32(StringRef &Data, uint32_t &Res) {
965 std::error_code consumeUInt32(StringRef &Data, uint32_t &Res) {
955966 const ulittle32_t *IntPtr;
956967 if (auto EC = consumeObject(Data, IntPtr))
957968 return EC;
958969 Res = *IntPtr;
959970 return std::error_code();
960971 }
972
973 } // end anonymous namespace
961974
962975 void COFFDumper::initializeFileAndStringTables(StringRef Data) {
963976 while (!Data.empty() && (CVFileChecksumTable.data() == nullptr ||
11811194 }
11821195 }
11831196
1184 static std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) {
1197 namespace {
1198
1199 std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) {
11851200 // Used to avoid overload ambiguity on APInt construtor.
11861201 bool FalseVal = false;
11871202 if (Data.size() < 2)
12471262 return object_error::parse_failed;
12481263 }
12491264
1265 } // end anonymous namespace
1266
12501267 /// Decode an unsigned integer numeric leaf value.
12511268 std::error_code decodeUIntLeaf(StringRef &Data, uint64_t &Num) {
12521269 APSInt N;
13121329 break;
13131330 }
13141331
1315 case S_PROC_ID_END: {
1332 case S_PROC_ID_END:
13161333 W.startLine() << "ProcEnd\n";
13171334 InFunctionScope = false;
13181335 break;
1319 }
13201336
13211337 case S_BLOCK32: {
13221338 DictScope S(W, "BlockStart");
13361352 break;
13371353 }
13381354
1339 case S_END: {
1355 case S_END:
13401356 W.startLine() << "BlockEnd\n";
13411357 InFunctionScope = false;
13421358 break;
1343 }
13441359
13451360 case S_LABEL32: {
13461361 DictScope S(W, "Label");
15141529 printLocalVariableAddrGap(SymData);
15151530 break;
15161531 }
1532
15171533 case S_DEFRANGE_SUBFIELD: {
15181534 DictScope S(W, "DefRangeSubfield");
15191535 const DefRangeSubfieldSym *DefRangeSubfield;
15281544 printLocalVariableAddrGap(SymData);
15291545 break;
15301546 }
1547
15311548 case S_DEFRANGE_REGISTER: {
15321549 DictScope S(W, "DefRangeRegister");
15331550 const DefRangeRegisterSym *DefRangeRegister;
15391556 printLocalVariableAddrGap(SymData);
15401557 break;
15411558 }
1559
15421560 case S_DEFRANGE_SUBFIELD_REGISTER: {
15431561 DictScope S(W, "DefRangeSubfieldRegister");
15441562 const DefRangeSubfieldRegisterSym *DefRangeSubfieldRegisterSym;
15531571 printLocalVariableAddrGap(SymData);
15541572 break;
15551573 }
1574
15561575 case S_DEFRANGE_FRAMEPOINTER_REL: {
15571576 DictScope S(W, "DefRangeFramePointerRel");
15581577 const DefRangeFramePointerRelSym *DefRangeFramePointerRel;
15631582 printLocalVariableAddrGap(SymData);
15641583 break;
15651584 }
1585
15661586 case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE: {
15671587 DictScope S(W, "DefRangeFramePointerRelFullScope");
15681588 const DefRangeFramePointerRelFullScopeSym
15711591 W.printNumber("Offset", DefRangeFramePointerRelFullScope->Offset);
15721592 break;
15731593 }
1594
15741595 case S_DEFRANGE_REGISTER_REL: {
15751596 DictScope S(W, "DefRangeRegisterRel");
15761597 const DefRangeRegisterRelSym *DefRangeRegisterRel;
19441965 W.printHex(Label, getFileNameForFileOffset(FileOffset), FileOffset);
19451966 }
19461967
1947 static StringRef getLeafTypeName(TypeLeafKind LT) {
1968 namespace {
1969
1970 StringRef getLeafTypeName(TypeLeafKind LT) {
19481971 switch (LT) {
19491972 case LF_STRING_ID: return "StringId";
19501973 case LF_FIELDLIST: return "FieldList";
19731996 return "UnknownLeaf";
19741997 }
19751998
1999 } // end anonymous namespace
2000
19762001 void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
19772002 const SectionRef &Section) {
19782003 ListScope D(W, "CodeViewTypes");
21992224 break;
22002225 }
22012226
2202 case LF_METHODLIST: {
2227 case LF_METHODLIST:
22032228 while (!LeafData.empty()) {
22042229 const MethodListEntry *Method;
22052230 error(consumeObject(LeafData, Method));
22132238 }
22142239 }
22152240 break;
2216 }
22172241
22182242 case LF_FUNC_ID: {
22192243 const FuncId *Func;
23552379 }
23562380 }
23572381
2358 static StringRef skipPadding(StringRef Data) {
2382 namespace {
2383
2384 StringRef skipPadding(StringRef Data) {
23592385 if (Data.empty())
23602386 return Data;
23612387 uint8_t Leaf = Data.front();
23652391 // low 4 bits.
23662392 return Data.drop_front(Leaf & 0x0F);
23672393 }
2394
2395 } // end anonymous namespace
23682396
23692397 void COFFDumper::printMemberAttributes(MemberAttributes Attrs) {
23702398 W.printEnum("AccessSpecifier", uint8_t(Attrs.getAccess()),
26302658
26312659 void COFFDumper::printDynamicSymbols() { ListScope Group(W, "DynamicSymbols"); }
26322660
2633 static ErrorOr
2661 namespace {
2662
2663 ErrorOr
26342664 getSectionName(const llvm::object::COFFObjectFile *Obj, int32_t SectionNumber,
26352665 const coff_section *Section) {
26362666 if (Section) {
26472677 return StringRef("IMAGE_SYM_UNDEFINED");
26482678 return StringRef("");
26492679 }
2680
2681 } // end anonymous namespace
26502682
26512683 void COFFDumper::printSymbol(const SymbolRef &Sym) {
26522684 DictScope D(W, "Symbol");
28922924 }
28932925 }
28942926
2895 static StringRef getBaseRelocTypeName(uint8_t Type) {
2927 namespace {
2928
2929 StringRef getBaseRelocTypeName(uint8_t Type) {
28962930 switch (Type) {
28972931 case COFF::IMAGE_REL_BASED_ABSOLUTE: return "ABSOLUTE";
28982932 case COFF::IMAGE_REL_BASED_HIGH: return "HIGH";
29042938 default: return "unknown (" + llvm::utostr(Type) + ")";
29052939 }
29062940 }
2941
2942 } // end anonymous namespace
29072943
29082944 void COFFDumper::printCOFFBaseReloc() {
29092945 ListScope D(W, "BaseReloc");
None //===-- sancov.cc --------------------------------------------===//
0 //===-- sancov.cc ---------------------------------------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
99 // This file is a command-line tool for reading and analyzing sanitizer
1010 // coverage.
1111 //===----------------------------------------------------------------------===//
12
13 #include "llvm/ADT/ArrayRef.h"
1214 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/Triple.h"
1319 #include "llvm/ADT/Twine.h"
1420 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
1521 #include "llvm/MC/MCAsmInfo.h"
4652 #include "llvm/Support/raw_ostream.h"
4753
4854 #include
55 #include
56 #include
57 #include
58 #include
4959 #include
50 #include
5160 #include
61 #include
5262 #include
5363 #include
5464
8292 "Print coverage statistics."),
8393 clEnumValEnd));
8494
85 static cl::list
95 cl::list
8696 ClInputFiles(cl::Positional, cl::OneOrMore,
8797 cl::desc("(|<.sancov file>)..."));
8898
89 static cl::opt ClDemangle("demangle", cl::init(true),
90 cl::desc("Print demangled function name."));
91
92 static cl::opt ClStripPathPrefix(
99 cl::opt ClDemangle("demangle", cl::init(true),
100 cl::desc("Print demangled function name."));
101
102 cl::opt ClStripPathPrefix(
93103 "strip_path_prefix", cl::init(""),
94104 cl::desc("Strip this prefix from file paths in reports."));
95105
96 static cl::opt
106 cl::opt
97107 ClBlacklist("blacklist", cl::init(""),
98108 cl::desc("Blacklist file (sanitizer blacklist format)."));
99109
100 static cl::opt ClUseDefaultBlacklist(
110 cl::opt ClUseDefaultBlacklist(
101111 "use_default_blacklist", cl::init(true), cl::Hidden,
102112 cl::desc("Controls if default blacklist should be used."));
103113
104 static const char *const DefaultBlacklistStr = "fun:__sanitizer_.*\n"
105 "src:/usr/include/.*\n"
106 "src:.*/libc\\+\\+/.*\n";
114 const char *const DefaultBlacklistStr = "fun:__sanitizer_.*\n"
115 "src:/usr/include/.*\n"
116 "src:.*/libc\\+\\+/.*\n";
107117
108118 // --------- FORMAT SPECIFICATION ---------
109119
112122 uint32_t Magic;
113123 };
114124
115 static const uint32_t BinCoverageMagic = 0xC0BFFFFF;
116 static const uint32_t Bitness32 = 0xFFFFFF32;
117 static const uint32_t Bitness64 = 0xFFFFFF64;
125 const uint32_t BinCoverageMagic = 0xC0BFFFFF;
126 const uint32_t Bitness32 = 0xFFFFFF32;
127 const uint32_t Bitness64 = 0xFFFFFF64;
118128
119129 // --------- ERROR HANDLING ---------
120130
121 static void Fail(const llvm::Twine &E) {
131 void Fail(const llvm::Twine &E) {
122132 errs() << "Error: " << E << "\n";
123133 exit(1);
124134 }
125135
126 static void FailIfError(std::error_code Error) {
136 void FailIfError(std::error_code Error) {
127137 if (!Error)
128138 return;
129139 errs() << "Error: " << Error.message() << "(" << Error.value() << ")\n";
130140 exit(1);
131141 }
132142
133 template static void FailIfError(const ErrorOr &E) {
143 template
144 void FailIfError(const ErrorOr &E) {
134145 FailIfError(E.getError());
135146 }
136147
137 static void FailIfNotEmpty(const llvm::Twine &E) {
148 void FailIfNotEmpty(const llvm::Twine &E) {
138149 if (E.str().empty())
139150 return;
140151 Fail(E);
141152 }
142153
143154 template
144 static void FailIfEmpty(const std::unique_ptr &Ptr,
145 const std::string &Message) {
155 void FailIfEmpty(const std::unique_ptr &Ptr, const std::string &Message) {
146156 if (Ptr.get())
147157 return;
148158 Fail(Message);
153163 // Produces std::map> grouping input
154164 // elements by FuncTy result.
155165 template
156 static inline auto group_by(const RangeTy &R, FuncTy F)
166 inline auto group_by(const RangeTy &R, FuncTy F)
157167 -> std::map::type,
158168 std::vector::type>> {
159169 std::map::type,
166176 }
167177
168178 template
169 static void readInts(const char *Start, const char *End,
170 std::set *Ints) {
179 void readInts(const char *Start, const char *End, std::set *Ints) {
171180 const T *S = reinterpret_cast(Start);
172181 const T *E = reinterpret_cast(End);
173182 std::copy(S, E, std::inserter(*Ints, Ints->end()));
210219 return Path.substr(Pos + ClStripPathPrefix.size());
211220 }
212221
213 static std::unique_ptr createSymbolizer() {
222 std::unique_ptr createSymbolizer() {
214223 symbolize::LLVMSymbolizer::Options SymbolizerOptions;
215224 SymbolizerOptions.Demangle = ClDemangle;
216225 SymbolizerOptions.UseSymbolTable = true;
275284 };
276285
277286 // Collect all debug info for given addresses.
278 static std::vector getAddrInfo(std::string ObjectFile,
279 const std::set &Addrs,
280 bool InlinedCode) {
287 std::vector getAddrInfo(std::string ObjectFile,
288 const std::set &Addrs,
289 bool InlinedCode) {
281290 std::vector Result;
282291 auto Symbolizer(createSymbolizer());
283292 Blacklists B;
305314
306315 // Locate __sanitizer_cov* function addresses that are used for coverage
307316 // reporting.
308 static std::set
317 std::set
309318 findSanitizerCovFunctions(const object::ObjectFile &O) {
310319 std::set Result;
311320
330339 // Locate addresses of all coverage points in a file. Coverage point
331340 // is defined as the 'address of instruction following __sanitizer_cov
332341 // call - 1'.
333 static void getObjectCoveragePoints(const object::ObjectFile &O,
334 std::set *Addrs) {
342 void getObjectCoveragePoints(const object::ObjectFile &O,
343 std::set *Addrs) {
335344 Triple TheTriple("unknown-unknown-unknown");
336345 TheTriple.setArch(Triple::ArchType(O.getArch()));
337346 auto TripleName = TheTriple.getTriple();
403412 }
404413 }
405414
406 static void
415 void
407416 visitObjectFiles(const object::Archive &A,
408417 std::function Fn) {
409418 for (auto &ErrorOrChild : A.children()) {
418427 }
419428 }
420429
421 static void
430 void
422431 visitObjectFiles(std::string FileName,
423432 std::function Fn) {
424433 ErrorOr> BinaryOrErr =
454463 return Result;
455464 }
456465
457 static void printCovPoints(std::string ObjFile, raw_ostream &OS) {
466 void printCovPoints(std::string ObjFile, raw_ostream &OS) {
458467 for (uint64_t Addr : getCoveragePoints(ObjFile)) {
459468 OS << "0x";
460469 OS.write_hex(Addr);
462471 }
463472 }
464473
465 static std::string escapeHtml(const std::string &S) {
474 std::string escapeHtml(const std::string &S) {
466475 std::string Result;
467476 Result.reserve(S.size());
468477 for (char Ch : S) {
492501
493502 // Adds leading zeroes wrapped in 'lz' style.
494503 // Leading zeroes help locate 000% coverage.
495 static std::string formatHtmlPct(size_t Pct) {
504 std::string formatHtmlPct(size_t Pct) {
496505 Pct = std::max(std::size_t{0}, std::min(std::size_t{100}, Pct));
497506
498507 std::string Num = std::to_string(Pct);
503512 return Zeroes + Num;
504513 }
505514
506 static std::string anchorName(std::string Anchor) {
515 std::string anchorName(std::string Anchor) {
507516 llvm::MD5 Hasher;
508517 llvm::MD5::MD5Result Hash;
509518 Hasher.update(Anchor);
514523 return HexString.str().str();
515524 }
516525
517 static ErrorOr isCoverageFile(std::string FileName) {
526 ErrorOr isCoverageFile(std::string FileName) {
518527 ErrorOr> BufOrErr =
519528 MemoryBuffer::getFile(FileName);
520529 if (!BufOrErr) {
541550 size_t CovFns;
542551 };
543552
544 static raw_ostream &operator<<(raw_ostream &OS, const CoverageStats &Stats) {
553 raw_ostream &operator<<(raw_ostream &OS, const CoverageStats &Stats) {
545554 OS << "all-edges: " << Stats.AllPoints << "\n";
546555 OS << "cov-edges: " << Stats.CovPoints << "\n";
547556 OS << "all-functions: " << Stats.AllFns << "\n";
821830 std::vector CovAddrInfo;
822831 };
823832
824 static void printFunctionLocs(const SourceCoverageData::FunctionLocs &FnLocs,
825 raw_ostream &OS) {
833 void printFunctionLocs(const SourceCoverageData::FunctionLocs &FnLocs,
834 raw_ostream &OS) {
826835 for (const auto &Fns : FnLocs) {
827836 for (const auto &Fn : Fns.second) {
828837 OS << stripPathPrefix(Fns.first.FileName) << ":" << Fns.first.Line << " "
11811190 const std::set CoverageFiles;
11821191 };
11831192
1184 } // namespace
1193 } // end anonymous namespace
11851194
11861195 int main(int argc, char **argv) {
11871196 // Print stack trace if we signal out.
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "llvm/ADT/StringRef.h"
1415 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
1516 #include "llvm/Support/CommandLine.h"
1617 #include "llvm/Support/ErrorOr.h"
1718 #include "llvm/Support/MemoryBuffer.h"
1819 #include "llvm/Transforms/Utils/SanitizerStats.h"
19 #include <stdint.h>
20 #include <cassert>
21 #include
22 #include
23 #include
2024
2125 using namespace llvm;
2226
23 static cl::opt ClInputFile(cl::Positional, cl::Required,
24 cl::desc(""));
27 namespace {
2528
26 static cl::opt ClDemangle("demangle", cl::init(false),
27 cl::desc("Print demangled function name."));
29 cl::opt ClInputFile(cl::Positional, cl::Required,
30 cl::desc(""));
31
32 cl::opt ClDemangle("demangle", cl::init(false),
33 cl::desc("Print demangled function name."));
2834
2935 inline uint64_t KindFromData(uint64_t Data, char SizeofPtr) {
3036 return Data >> (SizeofPtr * 8 - kSanitizerStatKindBits);
6268 SymbolizerOptions.UseSymbolTable = true;
6369 symbolize::LLVMSymbolizer Symbolizer(SymbolizerOptions);
6470
65 while (1) {
71 while (true) {
6672 uint64_t Addr = ReadLE(SizeofPtr, Begin, End);
6773 Begin += SizeofPtr;
6874 uint64_t Data = ReadLE(SizeofPtr, Begin, End);
108114 }
109115 }
110116
117 } // end anonymous namespace
118
111119 int main(int argc, char **argv) {
112120 cl::ParseCommandLineOptions(argc, argv,
113121 "Sanitizer Statistics Processing Tool");
99 #include "llvm/ADT/SCCIterator.h"
1010 #include "llvm/ADT/GraphTraits.h"
1111 #include "gtest/gtest.h"
12 #include <limits.h>
12 #include <cassert>
13 #include
14 #include
15 #include
1316
1417 using namespace llvm;
1518
2629 static void ValidateIndex(unsigned Idx) {
2730 assert(Idx < N && "Invalid node index!");
2831 }
32
2933 public:
30
3134 /// NodeSubset - A subset of the graph's nodes.
3235 class NodeSubset {
3336 typedef unsigned char BitVector; // Where the limitation N <= 8 comes from.
3437 BitVector Elements;
3538 NodeSubset(BitVector e) : Elements(e) {}
39
3640 public:
3741 /// NodeSubset - Default constructor, creates an empty subset.
3842 NodeSubset() : Elements(0) {
97101 private:
98102 /// Nodes - The list of nodes for this graph.
99103 NodeType Nodes[N];
104
100105 public:
101
102106 /// Graph - Default constructor. Creates an empty graph.
103107 Graph() {
104108 // Let each node know which node it is. This allows us to find the start of
165169 NodeSubset Children;
166170
167171 ChildIterator(); // Disable default constructor.
172
168173 protected:
169174 ChildIterator(NodeType *F, NodeSubset C) : FirstNode(F), Children(C) {}
170175
340345 }
341346 }
342347
343 }
348 } // end namespace llvm
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/ADT/SmallString.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringRef.h"
1416 #include "gtest/gtest.h"
15 #include
16 #include
17 #include
1817
1918 using namespace llvm;
2019
203202 EXPECT_EQ( 1, SmallString<10>("V8_q0").compare_numeric("V1_q0"));
204203 }
205204
206 }
205 } // end anonymous namespace
1414 #include "llvm/ADT/SmallVector.h"
1515 #include "llvm/Support/Compiler.h"
1616 #include "gtest/gtest.h"
17 #include
18 #include
1719 #include
18 #include <stdarg.h>
20 #include <utility>
1921
2022 using namespace llvm;
2123
140142 int Constructable::numMoveAssignmentCalls;
141143
142144 struct NonCopyable {
143 NonCopyable() {}
144 NonCopyable(NonCopyable &&) {}
145 NonCopyable() = default;
146 NonCopyable(NonCopyable &&) = default;
145147 NonCopyable &operator=(NonCopyable &&) { return *this; }
148
146149 private:
147150 NonCopyable(const NonCopyable &) = delete;
148151 NonCopyable &operator=(const NonCopyable &) = delete;
198201 VectorT theVector;
199202 VectorT otherVector;
200203 };
201
202204
203205 typedef ::testing::Types,
204206 SmallVector,
521523 this->assertValuesInOrder(this->theVector, 6u, 1, 16, 16, 2, 3, 4);
522524 }
523525
524
525526 TYPED_TEST(SmallVectorTest, InsertRepeatedAtEndTest) {
526527 SCOPED_TRACE("InsertRepeatedTest");
527528
580581 this->assertValuesInOrder(this->theVector, 6u, 1, 77, 77, 77, 2, 3);
581582 }
582583
583
584584 TYPED_TEST(SmallVectorTest, InsertRangeAtEndTest) {
585585 SCOPED_TRACE("InsertRangeTest");
586586
747747
748748 struct MovedFrom {
749749 bool hasValue;
750
750751 MovedFrom() : hasValue(true) {
751752 }
753
752754 MovedFrom(MovedFrom&& m) : hasValue(m.hasValue) {
753755 m.hasValue = false;
754756 }
757
755758 MovedFrom &operator=(MovedFrom&& m) {
756759 hasValue = m.hasValue;
757760 m.hasValue = false;
774777 EAS_RValue,
775778 EAS_Failure
776779 };
780
777781 template struct EmplaceableArg {
778782 EmplaceableArgState State;
779783 EmplaceableArg() : State(EAS_Defaulted) {}
923927 EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2}));
924928 }
925929
926 } // end namespace
930 } // end anonymous namespace
1212 #include "llvm-c/OrcBindings.h"
1313 #include "llvm-c/Target.h"
1414 #include "llvm-c/TargetMachine.h"
15 #include "llvm/ADT/Triple.h"
1516
16 #include
17 #include
18 #include <string.h>
17 #include <cstring>
18 #include
1919
2020 namespace llvm {
2121
156156 LLVMOrcDisposeInstance(JIT);
157157 }
158158
159 } // namespace llvm
159 } // end namespace llvm
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/ArrayRef.h"
910 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/SmallVector.h"
12 #include "llvm/ADT/StringMap.h"
13 #include "llvm/ADT/StringRef.h"
1014 #include "llvm/Config/config.h"
15 #include "llvm/Support/Allocator.h"
1116 #include "llvm/Support/CommandLine.h"
1217 #include "llvm/Support/StringSaver.h"
1318 #include "gtest/gtest.h"
14 #include <stdlib.h>
19 #include <cstdlib>
1520 #include
1621
1722 using namespace llvm;
1924 namespace {
2025
2126 class TempEnvVar {
22 public:
27 public:
2328 TempEnvVar(const char *name, const char *value)
2429 : name(name) {
2530 const char *old_value = getenv(name);
4045 #endif
4146 }
4247
43 private:
48 private:
4449 const char *const name;
4550 };
4651
4752 template
4853 class StackOption : public cl::opt {
4954 typedef cl::opt Base;
55
5056 public:
5157 // One option...
5258 template
6773
6874 ~StackOption() override { this->removeArgument(); }
6975 };
70
7176
7277 cl::OptionCategory TestCategory("Test Options", "Description");
7378 TEST(CommandLineTest, ModifyExisitingOption) {
264269 << "Hid default option that should be visable.";
265270 }
266271
267 } // anonymous namespace
272 } // end anonymous namespace
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/SmallString.h"
10 #include "llvm/ADT/StringRef.h"
911 #include "llvm/Support/ConvertUTF.h"
1012 #include "llvm/Support/CommandLine.h"
1113 #include "llvm/Support/FileSystem.h"
1214 #include "llvm/Support/Path.h"
1315 #include "llvm/Support/Program.h"
16 #include "llvm/Support/raw_ostream.h"
1417 #include "gtest/gtest.h"
15 #include <stdlib.h>
18 #include <cstdlib>
19 #include
20 #include
21 #include
1622 #if defined(__APPLE__)
1723 # include
1824 #elif !defined(_MSC_VER)
4450 GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
4551 } else { \
4652 }
53
4754 // From TestMain.cpp.
4855 extern const char *TestMainArgv0;
4956
5259 using namespace llvm;
5360 using namespace sys;
5461
55 static cl::opt
62 cl::opt
5663 ProgramTestStringArg1("program-test-string-arg1");
57 static cl::opt
64 cl::opt
5865 ProgramTestStringArg2("program-test-string-arg2");
5966
6067 class ProgramEnvTest : public testing::Test {
308315 ASSERT_TRUE(ExecutionFailed);
309316 ASSERT_FALSE(Error.empty());
310317 }
311
312318 }
313319
314320 #ifdef LLVM_ON_WIN32
1010 #include "llvm/ADT/StringRef.h"
1111 #include "llvm/Support/StreamingMemoryObject.h"
1212 #include "gtest/gtest.h"
13 #include <string.h>
13 #include <cstring>
1414
1515 using namespace llvm;
1616
6464 EXPECT_TRUE(std::equal(InputBuffer, InputBuffer + 8, O.getPointer(0, 20)));
6565 }
6666
67 } // end namespace
67 } // end anonymous namespace
88
99 #include "gtest/gtest.h"
1010 #include "llvm/Support/TimeValue.h"
11 #include <time.h>
11 #include <cstdint>
12 #include
13 #include
1214
1315 using namespace llvm;
16
1417 namespace {
1518
1619 TEST(TimeValue, time_t) {
3639 EXPECT_EQ(ft1970, epoch.toWin32Time());
3740 }
3841
39 }
42 } // end anonymous namespace
1212 #if LLVM_ON_WIN32
1313 #include
1414 #else
15 #include <time.h>
15 #include <ctime>
1616 #endif
1717
1818 using namespace llvm;
6161 EXPECT_FALSE(T1.hasTriggered());
6262 }
6363
64 } // end anon namespace
64 } // end anonymous namespace