llvm.org GIT mirror llvm / 2707ee3
Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes." This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265459 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 3 years ago
30 changed file(s) with 334 addition(s) and 534 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"
1716 #include "llvm/ADT/FoldingSet.h"
1817 #include "llvm/ADT/Hashing.h"
19 #include "llvm/ADT/SmallVector.h"
2018 #include "llvm/ADT/StringExtras.h"
2119 #include "llvm/ADT/StringRef.h"
2220 #include "llvm/Support/ErrorHandling.h"
2321 #include "llvm/Support/MathExtras.h"
24 #include
25 #include
26 #include
2722 #include
28 #include >
23 #include .h>
2924
3025 using namespace llvm;
3126
9792 const unsigned int maxPowerOfFiveExponent = maxExponent + maxPrecision - 1;
9893 const unsigned int maxPowerOfFiveParts = 2 + ((maxPowerOfFiveExponent * 815)
9994 / (351 * integerPartWidth));
100
101 } // end namespace llvm
102
103 namespace {
95 }
10496
10597 /* A bunch of private, handy routines. */
10698
107 inline unsigned int
99 static inline unsigned int
108100 partCountForBits(unsigned int bits)
109101 {
110102 return ((bits) + integerPartWidth - 1) / integerPartWidth;
111103 }
112104
113105 /* Returns 0U-9U. Return values >= 10U are not digits. */
114 inline unsigned int
106 static inline unsigned int
115107 decDigitValue(unsigned int c)
116108 {
117109 return c - '0';
122114
123115 If the exponent overflows, returns a large exponent with the
124116 appropriate sign. */
125 int
117 static int
126118 readExponent(StringRef::iterator begin, StringRef::iterator end)
127119 {
128120 bool isNegative;
166158
167159 /* This is ugly and needs cleaning up, but I don't immediately see
168160 how whilst remaining safe. */
169 int
161 static int
170162 totalExponent(StringRef::iterator p, StringRef::iterator end,
171163 int exponentAdjustment)
172164 {
215207 return exponent;
216208 }
217209
218 StringRef::iterator
210 static StringRef::iterator
219211 skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end,
220212 StringRef::iterator *dot)
221213 {
256248 int normalizedExponent;
257249 };
258250
259 void
251 static void
260252 interpretDecimal(StringRef::iterator begin, StringRef::iterator end,
261253 decimalInfo *D)
262254 {
315307 /* Return the trailing fraction of a hexadecimal number.
316308 DIGITVALUE is the first hex digit of the fraction, P points to
317309 the next digit. */
318 lostFraction
310 static lostFraction
319311 trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end,
320312 unsigned int digitValue)
321313 {
346338
347339 /* Return the fraction lost were a bignum truncated losing the least
348340 significant BITS bits. */
349 lostFraction
341 static lostFraction
350342 lostFractionThroughTruncation(const integerPart *parts,
351343 unsigned int partCount,
352344 unsigned int bits)
368360 }
369361
370362 /* Shift DST right BITS bits noting lost fraction. */
371 lostFraction
363 static lostFraction
372364 shiftRight(integerPart *dst, unsigned int parts, unsigned int bits)
373365 {
374366 lostFraction lost_fraction;
381373 }
382374
383375 /* Combine the effect of two lost fractions. */
384 lostFraction
376 static lostFraction
385377 combineLostFractions(lostFraction moreSignificant,
386378 lostFraction lessSignificant)
387379 {
402394
403395 See "How to Read Floating Point Numbers Accurately" by William D
404396 Clinger. */
405 unsigned int
397 static unsigned int
406398 HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2)
407399 {
408400 assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
416408 /* The number of ulps from the boundary (zero, or half if ISNEAREST)
417409 when the least significant BITS are truncated. BITS cannot be
418410 zero. */
419 integerPart
411 static integerPart
420412 ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest)
421413 {
422414 unsigned int count, partBits;
461453
462454 /* Place pow(5, power) in DST, and return the number of parts used.
463455 DST must be at least one part larger than size of the answer. */
464 unsigned int
456 static unsigned int
465457 powerOf5(integerPart *dst, unsigned int power)
466458 {
467459 static const integerPart firstEightPowers[] = { 1, 5, 25, 125, 625, 3125,
524516
525517 /* Zero at the end to avoid modular arithmetic when adding one; used
526518 when rounding up during hexadecimal output. */
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";
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";
533525
534526 /* Write out an integerPart in hexadecimal, starting with the most
535527 significant nibble. Write out exactly COUNT hexdigits, return
536528 COUNT. */
537 unsigned int
529 static unsigned int
538530 partAsHex (char *dst, integerPart part, unsigned int count,
539531 const char *hexDigitChars)
540532 {
552544 }
553545
554546 /* Write out an unsigned decimal integer. */
555 char *
547 static char *
556548 writeUnsignedDecimal (char *dst, unsigned int n)
557549 {
558550 char buff[40], *p;
570562 }
571563
572564 /* Write out a signed decimal integer. */
573 char *
565 static char *
574566 writeSignedDecimal (char *dst, int value)
575567 {
576568 if (value < 0) {
581573
582574 return dst;
583575 }
584
585 } // end anonymous namespace
586576
587577 /* Constructors. */
588578 void
861851 {
862852 return semantics.precision;
863853 }
864
865854 APFloat::ExponentType
866855 APFloat::semanticsMaxExponent(const fltSemantics &semantics)
867856 {
868857 return semantics.maxExponent;
869858 }
870
871859 APFloat::ExponentType
872860 APFloat::semanticsMinExponent(const fltSemantics &semantics)
873861 {
19171905
19181906 return fs;
19191907 }
1908
19201909
19211910 /* Comparison requires normalized numbers. */
19221911 APFloat::cmpResult
25682557
25692558 /* Check whether the normalized exponent is high enough to overflow
25702559 max during the log-rebasing in the max-exponent check below. */
2571 } else if (D.normalizedExponent - 1 >
2572 std::numeric_limits::max() / 42039) {
2560 } else if (D.normalizedExponent - 1 > INT_MAX / 42039) {
25732561 fs = handleOverflow(rounding_mode);
25742562
25752563 /* If it wasn't, then it also wasn't high enough to overflow max
25762564 during the log-rebasing in the min-exponent check. Check that it
25772565 won't overflow min in either check, then perform the min-exponent
25782566 check. */
2579 } else if ((D.normalizedExponent - 1 <
2580 std::numeric_limits::min() / 42039) ||
2567 } else if (D.normalizedExponent - 1 < INT_MIN / 42039 ||
25812568 (D.normalizedExponent + 1) * 28738 <=
25822569 8651 * (semantics->minExponent - (int) semantics->precision)) {
25832570 /* Underflow to zero and round. */
32313218 uint64_t mysignificand2 = i2 & 0xffffffffffffLL;
32323219
32333220 initialize(&APFloat::IEEEquad);
3234 assert(partCount() == 2);
3221 assert(partCount()==2);
32353222
32363223 sign = static_cast(i2>>63);
32373224 if (myexponent==0 &&
34973484 }
34983485
34993486 namespace {
3500
35013487 void append(SmallVectorImpl &Buffer, StringRef Str) {
35023488 Buffer.append(Str.begin(), Str.end());
35033489 }
35333519 // Truncate the significand down to its active bit count.
35343520 significand = significand.trunc(significand.getActiveBits());
35353521 }
3522
35363523
35373524 void AdjustToPrecision(SmallVectorImpl &buffer,
35383525 int &exp, unsigned FormatPrecision) {
35783565 exp += FirstSignificant;
35793566 buffer.erase(&buffer[0], &buffer[FirstSignificant]);
35803567 }
3581
3582 } // end anonymous namespace
3568 }
35833569
35843570 void APFloat::toString(SmallVectorImpl &Str,
35853571 unsigned FormatPrecision,
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/Support/CrashRecoveryContext.h"
10 #include "llvm/ADT/STLExtras.h"
1110 #include "llvm/Config/config.h"
1211 #include "llvm/Support/ErrorHandling.h"
1312 #include "llvm/Support/ManagedStatic.h"
1413 #include "llvm/Support/Mutex.h"
1514 #include "llvm/Support/ThreadLocal.h"
16 #include "llvm/Support/Threading.h"
17 #include
18 #include
19
15 #include
2016 using namespace llvm;
2117
2218 namespace {
2319
2420 struct CrashRecoveryContextImpl;
2521
26 ManagedStatic<
22 static ManagedStatic<
2723 sys::ThreadLocal > CurrentContext;
2824
2925 struct CrashRecoveryContextImpl {
4541 Next = CurrentContext->get();
4642 CurrentContext->set(this);
4743 }
48
4944 ~CrashRecoveryContextImpl() {
5045 if (!SwitchedThread)
5146 CurrentContext->set(Next);
7469 }
7570 };
7671
77 ManagedStatic gCrashRecoveryContextMutex;
78 bool gCrashRecoveryEnabled = false;
79
80 ManagedStatic>
72 }
73
74 static ManagedStatic gCrashRecoveryContextMutex;
75 static bool gCrashRecoveryEnabled = false;
76
77 static ManagedStatic>
8178 tlIsRecoveringFromCrash;
82
83 } // end anonymous namespace
8479
8580 CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
8681
166161 // SetUnhandledExceptionFilter API, but there's a risk of that
167162 // being entirely overwritten (it's not a chain).
168163
169 namespace {
170
171 LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
164 static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
172165 {
173166 // Lookup the current thread local recovery object.
174167 const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
196189 // CrashRecoveryContext at all. So we make use of a thread-local
197190 // exception table. The handles contained in here will either be
198191 // non-NULL, valid VEH handles, or NULL.
199 sys::ThreadLocal sCurrentExceptionHandle;
200
201 } // end anonymous namespace
192 static sys::ThreadLocal sCurrentExceptionHandle;
202193
203194 void CrashRecoveryContext::Enable() {
204195 sys::ScopedLock L(*gCrashRecoveryContextMutex);
247238 // reliable fashion -- if we get a signal outside of a crash recovery context we
248239 // simply disable crash recovery and raise the signal again.
249240
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) {
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) {
259249 // Lookup the current thread local recovery object.
260250 const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
261251
287277 const_cast(CRCI)->HandleCrash();
288278 }
289279
290 } // end anonymous namespace
291
292280 void CrashRecoveryContext::Enable() {
293281 sys::ScopedLock L(*gCrashRecoveryContextMutex);
294282
345333 CRCI->HandleCrash();
346334 }
347335
348 namespace {
349
350336 // FIXME: Portability.
351 void setThreadBackgroundPriority() {
337 static void setThreadBackgroundPriority() {
352338 #ifdef __APPLE__
353339 setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
354340 #endif
355341 }
356342
357 bool hasThreadBackgroundPriority() {
343 static bool hasThreadBackgroundPriority() {
358344 #ifdef __APPLE__
359345 return getpriority(PRIO_DARWIN_THREAD, 0) == 1;
360346 #else
362348 #endif
363349 }
364350
351 namespace {
365352 struct RunSafelyOnThreadInfo {
366353 function_ref Fn;
367354 CrashRecoveryContext *CRC;
368355 bool UseBackgroundPriority;
369356 bool Result;
370357 };
371
372 void RunSafelyOnThread_Dispatch(void *UserData) {
358 }
359
360 static void RunSafelyOnThread_Dispatch(void *UserData) {
373361 RunSafelyOnThreadInfo *Info =
374362 reinterpret_cast(UserData);
375363
378366
379367 Info->Result = Info->CRC->RunSafely(Info->Fn);
380368 }
381
382 } // end anonymous namespace
383
384369 bool CrashRecoveryContext::RunSafelyOnThread(function_ref Fn,
385370 unsigned RequestedStackSize) {
386371 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 #include
18 #include >
16 #include .h>
17
18 #if HAVE_ERRNO_H
19 #include
20 #endif
1921
2022 //===----------------------------------------------------------------------===//
2123 //=== WARNING: Implementation here must contain only TRULY operating system
2931 std::string StrError() {
3032 return StrError(errno);
3133 }
32 #endif // HAVE_ERRNO_H
34 #endif // HAVE_ERRNO_H
3335
3436 std::string StrError(int errnum) {
3537 std::string str;
6971 return str;
7072 }
7173
72 } // namespace sys
73 } // namespace llvm
74 } // namespace sys
75 } // namespace llvm
1818 #include "llvm/Config/config.h"
1919 #include "llvm/Support/Debug.h"
2020 #include "llvm/Support/FileSystem.h"
21 #include
22 #include
21 #include "llvm/Support/raw_ostream.h"
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
5351 #if defined(__linux__)
54 ssize_t LLVM_ATTRIBUTE_UNUSED readCpuInfo(void *Buf, size_t Size) {
52 static ssize_t LLVM_ATTRIBUTE_UNUSED readCpuInfo(void *Buf, size_t Size) {
5553 // Note: We cannot mmap /proc/cpuinfo here and then process the resulting
5654 // memory buffer because the 'file' has 0 size (it can be read from only
5755 // as a stream).
7573
7674 /// GetX86CpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
7775 /// specified arguments. If we can't run cpuid on the host, return true.
78 bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
79 unsigned *rECX, unsigned *rEDX) {
76 static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
77 unsigned *rECX, unsigned *rEDX) {
8078 #if defined(__GNUC__) || defined(__clang__)
8179 #if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
8280 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
121119 /// GetX86CpuIDAndInfoEx - Execute the specified cpuid with subleaf and return the
122120 /// 4 values in the specified arguments. If we can't run cpuid on the host,
123121 /// return true.
124 bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf, unsigned *rEAX,
125 unsigned *rEBX, unsigned *rECX, unsigned *rEDX) {
122 static bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
123 unsigned *rEAX, unsigned *rEBX, unsigned *rECX,
124 unsigned *rEDX) {
126125 #if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
127126 #if defined(__GNUC__)
128127 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
182181 #endif
183182 }
184183
185 bool GetX86XCR0(unsigned *rEAX, unsigned *rEDX) {
184 static bool GetX86XCR0(unsigned *rEAX, unsigned *rEDX) {
186185 #if defined(__GNUC__)
187186 // Check xgetbv; this uses a .byte sequence instead of the instruction
188187 // directly because older assemblers do not include support for xgetbv and
199198 #endif
200199 }
201200
202 void DetectX86FamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) {
201 static void DetectX86FamilyModel(unsigned EAX, unsigned &Family,
202 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
215213
216214 StringRef sys::getHostCPUName() {
217215 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 <cmath>
18 #include <math.h>
1919 #endif
2020
2121 namespace llvm {
2828 const float huge_valf = HUGE_VALF;
2929 #endif
3030
31 } // end namespace llvm
31 }
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
2524 using namespace sys;
26
2725 MutexImpl::MutexImpl( bool recursive) { }
2826 MutexImpl::~MutexImpl() { }
2927 bool MutexImpl::acquire() { return true; }
3028 bool MutexImpl::release() { return true; }
3129 bool MutexImpl::tryacquire() { return true; }
32
33 } // end namespace llvm
30 }
3431 #else
3532
3633 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
3734
3835 #include
39 #include
4036 #include
37 #include
4138
4239 namespace llvm {
43
4440 using namespace sys;
4541
4642 // Construct a Mutex using pthread calls
113109 return errorcode == 0;
114110 }
115111
116 } // end namespace llvm
112 }
117113
118114 #elif defined(LLVM_ON_UNIX)
119115 #include "Unix/Mutex.inc"
1212
1313 #include "llvm/Config/config.h"
1414 #include "llvm/Support/RWMutex.h"
15 #include
1516
1617 //===----------------------------------------------------------------------===//
1718 //=== WARNING: Implementation here must contain only TRULY operating system
2122 #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
2223 // Define all methods as no-ops if threading is explicitly disabled
2324 namespace llvm {
24
2525 using namespace sys;
26
2726 RWMutexImpl::RWMutexImpl() { }
2827 RWMutexImpl::~RWMutexImpl() { }
2928 bool RWMutexImpl::reader_acquire() { return true; }
3029 bool RWMutexImpl::reader_release() { return true; }
3130 bool RWMutexImpl::writer_acquire() { return true; }
3231 bool RWMutexImpl::writer_release() { return true; }
33
34 } // end namespace llvm
32 }
3533 #else
3634
3735 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_RWLOCK_INIT)
3836
3937 #include
40 #include
4138 #include
39 #include
4240
4341 namespace llvm {
44
4542 using namespace sys;
4643
4744 // Construct a RWMutex using pthread calls
115112 return errorcode == 0;
116113 }
117114
118 } // end namespace llvm
115 }
119116
120117 #elif defined(LLVM_ON_UNIX)
121118 #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"
1615 #include "llvm/Support/Host.h"
1716 #include "llvm/Support/SHA1.h"
17 using namespace llvm;
1818
19 #include
20
21 using namespace llvm;
19 #include
20 #include
2221
2322 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
2423 #define SHA_BIG_ENDIAN
4645 InternalState.BufferOffset = 0;
4746 }
4847
49 namespace {
50
51 uint32_t rol32(uint32_t number, uint8_t bits) {
48 static uint32_t rol32(uint32_t number, uint8_t bits) {
5249 return ((number << bits) | (number >> (32 - bits)));
5350 }
54
55 } // end anonymous namespace
5651
5752 void SHA1::hashBlock() {
5853 uint8_t i;
1313 //
1414 //===----------------------------------------------------------------------===//
1515
16 #include
17
18 namespace {
16 #include
1917
2018 // Must declare the symbols in the global namespace.
21 void *DoSearch(const char* symbolName) {
19 static void *DoSearch(const char* symbolName) {
2220 #define EXPLICIT_SYMBOL(SYM) \
2321 extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM
2422
5250 return nullptr;
5351 }
5452
55 } // end anonymous namespace
56
5753 namespace llvm {
58
5954 void *SearchForAddressOfSpecialSymbol(const char* symbolName) {
6055 return DoSearch(symbolName);
6156 }
62
63 } // end namespace llvm
57 } // namespace llvm
1616 //===----------------------------------------------------------------------===//
1717
1818 #include "Unix.h"
19 #include
20 #include
21 #include <cstdio>
19 #include <limits.h>
20 #include
2221 #if HAVE_SYS_STAT_H
2322 #include
2423 #endif
8685 #if defined(__FreeBSD__) || defined (__NetBSD__) || defined(__Bitrig__) || \
8786 defined(__OpenBSD__) || defined(__minix) || defined(__FreeBSD_kernel__) || \
8887 defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__)
89
90 namespace {
91
92 int
88 static int
9389 test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
9490 {
9591 struct stat sb;
104100 return 0;
105101 }
106102
107 char *
103 static char *
108104 getprogpath(char ret[PATH_MAX], const char *bin)
109105 {
110106 char *pv, *s, *t;
141137 free(pv);
142138 return nullptr;
143139 }
144
145 } // end anonymous namespace
146
147140 #endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__
148141
149142 /// GetMainExecutable - Return the path to the main executable, given the
336329 return std::error_code();
337330 }
338331
339 namespace {
340
341 int convertAccessMode(AccessMode Mode) {
332 static int convertAccessMode(AccessMode Mode) {
342333 switch (Mode) {
343334 case AccessMode::Exist:
344335 return F_OK;
350341 llvm_unreachable("invalid enum");
351342 }
352343
353 } // end anonymous namespace
354
355344 std::error_code access(const Twine &Path, AccessMode Mode) {
356345 SmallString<128> PathStorage;
357346 StringRef P = Path.toNullTerminatedStringRef(PathStorage);
391380 return std::error_code();
392381 }
393382
394 namespace {
395
396 std::error_code fillStatus(int StatRet, const struct stat &Status,
397 file_status &Result) {
383 static std::error_code fillStatus(int StatRet, const struct stat &Status,
384 file_status &Result) {
398385 if (StatRet != 0) {
399386 std::error_code ec(errno, std::generic_category());
400387 if (ec == errc::no_such_file_or_directory)
428415 return std::error_code();
429416 }
430417
431 } // end anonymous namespace
432
433418 std::error_code status(const Twine &Path, file_status &Result) {
434419 SmallString<128> PathStorage;
435420 StringRef P = Path.toNullTerminatedStringRef(PathStorage);
611596 return false;
612597 }
613598
614 namespace {
615
616 bool getDarwinConfDir(bool TempDir, SmallVectorImpl &Result) {
599 static bool getDarwinConfDir(bool TempDir, SmallVectorImpl &Result) {
617600 #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
618601 // On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
619602 // macros defined in on darwin >= 9
638621 return false;
639622 }
640623
641 bool getUserCacheDir(SmallVectorImpl &Result) {
624 static bool getUserCacheDir(SmallVectorImpl &Result) {
642625 // First try using XDG_CACHE_HOME env variable,
643626 // as specified in XDG Base Directory Specification at
644627 // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
661644 return false;
662645 }
663646
664 const char *getEnvTempDir() {
647 static const char *getEnvTempDir() {
665648 // Check whether the temporary directory is specified by an environment
666649 // variable.
667650 const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
673656 return nullptr;
674657 }
675658
676 const char *getDefaultTempDir(bool ErasedOnReboot) {
659 static const char *getDefaultTempDir(bool ErasedOnReboot) {
677660 #ifdef P_tmpdir
678661 if ((bool)P_tmpdir)
679662 return P_tmpdir;
683666 return "/tmp";
684667 return "/var/tmp";
685668 }
686
687 } // end anonymous namespace
688669
689670 void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl &Result) {
690671 Result.clear();
2929 #ifdef HAVE_SYS_STAT_H
3030 #include
3131 #endif
32 #include
32 #if HAVE_SIGNAL_H
33 #include
34 #endif
3335 // DragonFlyBSD, OpenBSD, and Bitrig have deprecated for
3436 // instead. Unix.h includes this for us already.
3537 #if defined(HAVE_MALLOC_H) && !defined(__DragonFly__) && \
5759 using namespace llvm;
5860 using namespace sys;
5961
60 namespace {
61
62 std::pair getRUsageTimes() {
62 static 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
8280
8381 // On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
8482 // offset in mmap(3) should be aligned to the AllocationGranularity.
190188 }
191189
192190 namespace {
193
194191 class FDCloser {
195192 public:
196193 FDCloser(int &FD) : FD(FD), KeepOpen(false) {}
207204 int &FD;
208205 bool KeepOpen;
209206 };
210
211 } // end anonymous namespace
207 }
212208
213209 std::error_code Process::FixupStandardFileDescriptors() {
214210 int NullFD = -1;
303299 #endif
304300 }
305301
306 namespace {
307
308 unsigned getColumns(int FileID) {
302 static unsigned getColumns(int FileID) {
309303 // If COLUMNS is defined in the environment, wrap to that many columns.
310304 if (const char *ColumnsStr = std::getenv("COLUMNS")) {
311305 int Columns = std::atoi(ColumnsStr);
324318
325319 return Columns;
326320 }
327
328 } // end anonymous namespace
329321
330322 unsigned Process::StandardOutColumns() {
331323 if (!StandardOutIsDisplayed())
351343 extern "C" int tigetnum(char *capname);
352344 #endif
353345
354 namespace {
355
356346 #ifdef HAVE_TERMINFO
357 ManagedStatic TermColorMutex;
358 #endif
359
360 bool terminalHasColors(int fd) {
347 static ManagedStatic TermColorMutex;
348 #endif
349
350 static bool terminalHasColors(int fd) {
361351 #ifdef HAVE_TERMINFO
362352 // First, acquire a global lock because these C routines are thread hostile.
363353 MutexGuard G(*TermColorMutex);
397387 return false;
398388 }
399389
400 } // end anonymous namespace
401
402390 bool Process::FileDescriptorHasColors(int fd) {
403391 // A file descriptor has colors if it is displayed and the terminal has
404392 // colors.
439427 }
440428
441429 #if !defined(HAVE_DECL_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM
442
443 namespace {
444
445 unsigned GetRandomNumberSeed() {
430 static unsigned GetRandomNumberSeed() {
446431 // Attempt to get the initial seed from /dev/urandom, if possible.
447432 int urandomFD = open("/dev/urandom", O_RDONLY);
448433
464449 TimeValue Now = TimeValue::now();
465450 return hash_combine(Now.seconds(), Now.nanoseconds(), ::getpid());
466451 }
467
468 } // end anonymous namespace
469
470452 #endif
471453
472454 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 #include
32 #if HAVE_SIGNAL_H
33 #include
34 #endif
3335 #if HAVE_FCNTL_H
3436 #include
3537 #endif
9395 return errc::no_such_file_or_directory;
9496 }
9597
96 namespace {
97
98 bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) {
98 static 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 bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg,
128 posix_spawn_file_actions_t *FileActions) {
127 static 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 void TimeOutHandler(int Sig) {
147 }
148
149 void SetMemoryLimits (unsigned size)
146 static void TimeOutHandler(int Sig) {
147 }
148
149 static void SetMemoryLimits (unsigned size)
150150 {
151151 #if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT
152152 struct rlimit r;
175175 #endif
176176 }
177177
178 } // end anonymous namespace
179
180 } // end namespace llvm
178 }
181179
182180 static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
183181 const char **envp, const StringRef **redirects,
420418 return WaitResult;
421419 }
422420
423 std::error_code sys::ChangeStdinToBinary() {
421 std::error_code sys::ChangeStdinToBinary(){
424422 // Do nothing, as Unix doesn't differentiate between text and binary.
425423 return std::error_code();
426424 }
427425
428 std::error_code sys::ChangeStdoutToBinary() {
426 std::error_code sys::ChangeStdoutToBinary(){
429427 // Do nothing, as Unix doesn't differentiate between text and binary.
430428 return std::error_code();
431429 }
467465 }
468466 return true;
469467 }
470
471 } // end namespace llvm
468 }
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 #include
29 #if HAVE_SIGNAL_H
30 #include
31 #endif
3032 #if HAVE_SYS_STAT_H
3133 #include
3234 #endif
4547
4648 using namespace llvm;
4749
48 namespace {
49
50 RETSIGTYPE SignalHandler(int Sig); // defined below.
51
52 ManagedStatic > SignalsMutex;
50 static RETSIGTYPE SignalHandler(int Sig); // defined below.
51
52 static ManagedStatic > SignalsMutex;
5353
5454 /// InterruptFunction - The function to call if ctrl-c is pressed.
55 void (*InterruptFunction)() = nullptr;
56
57 ManagedStatic> FilesToRemove;
55 static void (*InterruptFunction)() = nullptr;
56
57 static 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 const int IntSigs[] = {
62 static 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 const int KillSigs[] = {
68 static const int KillSigs[] = {
6969 SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGQUIT
7070 #ifdef SIGSYS
7171 , SIGSYS
8181 #endif
8282 };
8383
84 unsigned NumRegisteredSignals = 0;
85 struct {
84 static unsigned NumRegisteredSignals = 0;
85 static struct {
8686 struct sigaction SA;
8787 int SigNo;
8888 } RegisteredSignalInfo[array_lengthof(IntSigs) + array_lengthof(KillSigs)];
8989
90 void RegisterHandler(int Signal) {
90
91 static void RegisterHandler(int Signal) {
9192 assert(NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) &&
9293 "Out of space for signal handlers!");
9394
104105 ++NumRegisteredSignals;
105106 }
106107
107 void RegisterHandlers() {
108 static void RegisterHandlers() {
108109 // We need to dereference the signals mutex during handler registration so
109110 // that we force its construction. This is to prevent the first use being
110111 // during handling an actual signal because you can't safely call new in a
118119 for (auto S : KillSigs) RegisterHandler(S);
119120 }
120121
121 void UnregisterHandlers() {
122 static void UnregisterHandlers() {
122123 // Restore all of the signal handlers to how they were before we showed up.
123124 for (unsigned i = 0, e = NumRegisteredSignals; i != e; ++i)
124125 sigaction(RegisteredSignalInfo[i].SigNo,
126127 NumRegisteredSignals = 0;
127128 }
128129
130
129131 /// RemoveFilesToRemove - Process the FilesToRemove list. This function
130132 /// should be called with the SignalsMutex lock held.
131133 /// NB: This must be an async signal safe function. It cannot allocate or free
132134 /// memory, even in debug builds.
133 void RemoveFilesToRemove() {
135 static void RemoveFilesToRemove() {
134136 // Avoid constructing ManagedStatic in the signal handler.
135137 // If FilesToRemove is not constructed, there are no files to remove.
136138 if (!FilesToRemove.isConstructed())
161163 }
162164
163165 // SignalHandler - The signal handler that runs.
164 RETSIGTYPE SignalHandler(int Sig) {
166 static RETSIGTYPE SignalHandler(int Sig) {
165167 // Restore the signal behavior to default, so that the program actually
166168 // crashes when we return and the signal reissues. This also ensures that if
167169 // we crash in our signal handler that the program will terminate immediately
205207 raise(Sig);
206208 #endif
207209 }
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 namespace {
267
268 int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
266 static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
269267 DlIteratePhdrData *data = (DlIteratePhdrData*)arg;
270268 const char *name = data->first ? data->main_exec_name : info->dlpi_name;
271269 data->first = false;
288286 return 0;
289287 }
290288
291 } // end anonymous namespace
292
293289 /// If this is an ELF platform, we can find all loaded modules and their virtual
294290 /// addresses with dl_iterate_phdr.
295291 static bool findModulesAndOffsets(void **StackTrace, int Depth,
378374 #endif
379375 }
380376
381 namespace {
382
383 void PrintStackTraceSignalHandler(void *) {
377 static void PrintStackTraceSignalHandler(void *) {
384378 PrintStackTrace(llvm::errs());
385379 }
386
387 } // end anonymous namespace
388380
389381 void llvm::sys::DisableSystemDialogsOnCrash() {}
390382
409401 }
410402 #endif
411403 }
404
405
406 /***/
412407
413408 // On Darwin, raise sends a signal to the main thread instead of the current
414409 // 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
2221 #include
22 #include
2323
2424 namespace llvm {
25
2625 using namespace sys;
2726
2827 ThreadLocalImpl::ThreadLocalImpl() : data() {
5655 setInstance(nullptr);
5756 }
5857
59 } // end namespace llvm
58 }
6059 #else
61
6260 namespace llvm {
63
6461 using namespace sys;
65
6662 ThreadLocalImpl::ThreadLocalImpl() : data() { }
6763 ThreadLocalImpl::~ThreadLocalImpl() { }
6864 void ThreadLocalImpl::setInstance(const void* d) { data = const_cast(d);}
6965 void *ThreadLocalImpl::getInstance() { return data; }
7066 void ThreadLocalImpl::removeInstance() { setInstance(0); }
71
72 } // end namespace llvm
73
67 }
7468 #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 <cassert>
24 #include <assert.h>
2525 #include
2626 #include
2727 #include
4141 #ifdef HAVE_SYS_TIME_H
4242 # include
4343 #endif
44 #include <ctime>
44 #include <time.h>
4545
4646 #ifdef HAVE_DLFCN_H
4747 # include
6464 return true;
6565 }
6666
67 #endif // LLVM_LIB_SUPPORT_UNIX_UNIX_H
67 #endif
3333 #include "llvm/Support/raw_ostream.h"
3434 #include "llvm/Target/TargetMachine.h"
3535 #include "llvm/Target/TargetOptions.h"
36 #include
37
36 #include
3837 using namespace llvm;
3938
4039 #define DEBUG_TYPE "x86-isel"
141140 }
142141 #endif
143142 };
144 } // end anonymous namespace
143 }
145144
146145 namespace {
147146 //===--------------------------------------------------------------------===//
301300 // Walk all the users of the immediate.
302301 for (SDNode::use_iterator UI = N->use_begin(),
303302 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 } // end anonymous namespace
395 }
396
396397
397398 bool
398399 X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const {
457458 return true;
458459 }
459460
460 namespace {
461
462461 /// Replace the original chain operand of the call with
463462 /// load's chain operand and move load below the call's chain operand.
464 void moveBelowOrigChain(SelectionDAG *CurDAG, SDValue Load, SDValue Call,
465 SDValue OrigChain) {
463 static void moveBelowOrigChain(SelectionDAG *CurDAG, SDValue Load,
464 SDValue Call, SDValue OrigChain) {
466465 SmallVector Ops;
467466 SDValue Chain = OrigChain.getOperand(0);
468467 if (Chain.getNode() == Load.getNode())
496495 /// Return the CALLSEQ_START by reference as a second output.
497496 /// In the case of a tail call, there isn't a callseq node between the call
498497 /// chain and the load.
499 bool isCalleeLoad(SDValue Callee, SDValue &Chain, bool HasCallSeq) {
498 static bool isCalleeLoad(SDValue Callee, SDValue &Chain, bool HasCallSeq) {
500499 // The transformation is somewhat dangerous if the call's chain was glued to
501500 // the call. After MoveBelowOrigChain the load is moved between the call and
502501 // the chain, this can create a cycle if the load is not folded. So it is
532531 return true;
533532 return false;
534533 }
535
536 } // end anonymous namespace
537534
538535 void X86DAGToDAGISel::PreprocessISelDAG() {
539536 // OptFor[Min]Size are used in pattern predicates that isel is matching.
653650 }
654651 }
655652
653
656654 /// Emit any code that needs to be executed only in the main function.
657655 void X86DAGToDAGISel::emitSpecialCodeForMain() {
658656 if (Subtarget->isTargetCygMing()) {
677675 emitSpecialCodeForMain();
678676 }
679677
680 namespace {
681
682 bool isDispSafeForFrameIndex(int64_t Val) {
678 static bool isDispSafeForFrameIndex(int64_t Val) {
683679 // On 64-bit platforms, we can run into an issue where a frame index
684680 // includes a displacement that, when added to the explicit displacement,
685681 // will overflow the displacement field. Assuming that the frame index
688684 // a 32-bit integer), a 31-bit disp should always be safe.
689685 return isInt<31>(Val);
690686 }
691
692 } // end anonymous namespace
693687
694688 bool X86DAGToDAGISel::foldOffsetIntoAddress(uint64_t Offset,
695689 X86ISelAddressMode &AM) {
710704 }
711705 AM.Disp = Val;
712706 return false;
707
713708 }
714709
715710 bool X86DAGToDAGISel::matchLoadInAddress(LoadSDNode *N, X86ISelAddressMode &AM){
900895 return true;
901896 }
902897
903 namespace {
904
905898 // Insert a node into the DAG at least before the Pos node's position. This
906899 // will reposition the node as needed, and will assign it a node ID that is <=
907900 // the Pos node's ID. Note that this does *not* preserve the uniqueness of node
908901 // IDs! The selection DAG must no longer depend on their uniqueness when this
909902 // is used.
910 void insertDAGNode(SelectionDAG &DAG, SDValue Pos, SDValue N) {
903 static void insertDAGNode(SelectionDAG &DAG, SDValue Pos, SDValue N) {
911904 if (N.getNode()->getNodeId() == -1 ||
912905 N.getNode()->getNodeId() > Pos.getNode()->getNodeId()) {
913906 DAG.RepositionNode(Pos.getNode()->getIterator(), N.getNode());
919912 // safe. This allows us to convert the shift and and into an h-register
920913 // extract and a scaled index. Returns false if the simplification is
921914 // performed.
922 bool foldMaskAndShiftToExtract(SelectionDAG &DAG, SDValue N, uint64_t Mask,
923 SDValue Shift, SDValue X,
924 X86ISelAddressMode &AM) {
915 static bool foldMaskAndShiftToExtract(SelectionDAG &DAG, SDValue N,
916 uint64_t Mask,
917 SDValue Shift, SDValue X,
918 X86ISelAddressMode &AM) {
925919 if (Shift.getOpcode() != ISD::SRL ||
926920 !isa(Shift.getOperand(1)) ||
927921 !Shift.hasOneUse())
961955 // Transforms "(X << C1) & C2" to "(X & (C2>>C1)) << C1" if safe and if this
962956 // allows us to fold the shift into this addressing mode. Returns false if the
963957 // transform succeeded.
964 bool foldMaskedShiftToScaledMask(SelectionDAG &DAG, SDValue N, uint64_t Mask,
965 SDValue Shift, SDValue X,
966 X86ISelAddressMode &AM) {
958 static bool foldMaskedShiftToScaledMask(SelectionDAG &DAG, SDValue N,
959 uint64_t Mask,
960 SDValue Shift, SDValue X,
961 X86ISelAddressMode &AM) {
967962 if (Shift.getOpcode() != ISD::SHL ||
968963 !isa(Shift.getOperand(1)))
969964 return true;
10271022 // Note that this function assumes the mask is provided as a mask *after* the
10281023 // value is shifted. The input chain may or may not match that, but computing
10291024 // such a mask is trivial.
1030 bool foldMaskAndShiftToScale(SelectionDAG &DAG, SDValue N, uint64_t Mask,
1031 SDValue Shift, SDValue X, X86ISelAddressMode &AM) {
1025 static bool foldMaskAndShiftToScale(SelectionDAG &DAG, SDValue N,
1026 uint64_t Mask,
1027 SDValue Shift, SDValue X,
1028 X86ISelAddressMode &AM) {
10321029 if (Shift.getOpcode() != ISD::SRL || !Shift.hasOneUse() ||
10331030 !isa(Shift.getOperand(1)))
10341031 return true;
11051102 AM.IndexReg = NewSRL;
11061103 return false;
11071104 }
1108
1109 } // end anonymous namespace
11101105
11111106 bool X86DAGToDAGISel::matchAddressRecursively(SDValue N, X86ISelAddressMode &AM,
11121107 unsigned Depth) {
14221417 bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
14231418 SDValue &Scale, SDValue &Index,
14241419 SDValue &Disp, SDValue &Segment) {
1420
14251421 MaskedGatherScatterSDNode *Mgs = dyn_cast(Parent);
14261422 if (!Mgs)
14271423 return false;
15441540 return false;
15451541 }
15461542
1543
15471544 bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
15481545 if (const ConstantSDNode *CN = dyn_cast(N)) {
15491546 uint64_t ImmVal = CN->getZExtValue();
16971694 return true;
16981695 }
16991696
1697
17001698 bool X86DAGToDAGISel::tryFoldLoad(SDNode *P, SDValue N,
17011699 SDValue &Base, SDValue &Scale,
17021700 SDValue &Index, SDValue &Disp,
17191717 return CurDAG->getRegister(GlobalBaseReg, TLI->getPointerTy(DL)).getNode();
17201718 }
17211719
1722 namespace {
1723
17241720 /// Test whether the given X86ISD::CMP node has any uses which require the SF
17251721 /// or OF bits to be accurate.
1726 bool hasNoSignedComparisonUses(SDNode *N) {
1722 static bool hasNoSignedComparisonUses(SDNode *N) {
17271723 // Examine each user of the node.
17281724 for (SDNode::use_iterator UI = N->use_begin(),
17291725 UE = N->use_end(); UI != UE; ++UI) {
17851781
17861782 /// Check whether or not the chain ending in StoreNode is suitable for doing
17871783 /// the {load; increment or decrement; store} to modify transformation.
1788 bool isLoadIncOrDecStore(StoreSDNode *StoreNode, unsigned Opc,
1789 SDValue StoredVal, SelectionDAG *CurDAG,
1790 LoadSDNode* &LoadNode, SDValue &InputChain) {
1784 static bool isLoadIncOrDecStore(StoreSDNode *StoreNode, unsigned Opc,
1785 SDValue StoredVal, SelectionDAG *CurDAG,
1786 LoadSDNode* &LoadNode, SDValue &InputChain) {
1787
17911788 // is the value stored the result of a DEC or INC?
17921789 if (!(Opc == X86ISD::DEC || Opc == X86ISD::INC)) return false;
17931790
18691866
18701867 /// Get the appropriate X86 opcode for an in-memory increment or decrement.
18711868 /// Opc should be X86ISD::DEC or X86ISD::INC.
1872 unsigned getFusedLdStOpcode(EVT &LdVT, unsigned Opc) {
1869 static unsigned getFusedLdStOpcode(EVT &LdVT, unsigned Opc) {
18731870 if (Opc == X86ISD::DEC) {
18741871 if (LdVT == MVT::i64) return X86::DEC64m;
18751872 if (LdVT == MVT::i32) return X86::DEC32m;
18841881 }
18851882 llvm_unreachable("unrecognized size for LdVT");
18861883 }
1887
1888 } // end anonymous namespace
18891884
18901885 /// Customized ISel for GATHER operations.
18911886 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"
2018 #include "llvm-c/Target.h"
21 #include "llvm-c/Types.h"
2219 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/Hashing.h"
24 #include "llvm/ADT/SmallVector.h"
2520 #include "llvm/Support/ErrorHandling.h"
2621
27 #include
28 #include
29 #include <cstring>
22 #include <stdio.h>
23 #include
3024
3125 using namespace llvm;
3226
4438 uintptr_t Val = static_cast(-1);
4539 return reinterpret_cast(Val);
4640 }
47
4841 static inline T* getTombstoneKey() {
4942 uintptr_t Val = static_cast(-2);
5043 return reinterpret_cast(Val);
5144 }
52
5345 static unsigned getHashValue(const T *PtrVal) {
5446 return hash_value(PtrVal);
5547 }
56
5748 static bool isEqual(const T *LHS, const T *RHS) { return LHS == RHS; }
5849 };
5950
162153 }
163154 };
164155
165 namespace {
166
167 ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
156 static ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
168157 unsigned Count = LLVMCountParams(Src);
169158 if (Count != LLVMCountParams(Dst))
170159 report_fatal_error("Parameter count mismatch");
221210
222211 return VMap;
223212 }
224
225 } // end anonymous namespace
226213
227214 LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
228215 if (!LLVMIsAConstant(Cst))
722709 }
723710 };
724711
725 namespace {
726
727 void declare_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
712 static void declare_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
728713 LLVMValueRef Begin = LLVMGetFirstGlobal(Src);
729714 LLVMValueRef End = LLVMGetLastGlobal(Src);
730715
788773 }
789774 }
790775
791 void clone_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
776 static void clone_symbols(LLVMModuleRef Src, LLVMModuleRef M) {
792777 LLVMValueRef Begin = LLVMGetFirstGlobal(Src);
793778 LLVMValueRef End = LLVMGetLastGlobal(Src);
794779
875860 }
876861 }
877862
878 } // end anonymous namespace
879
880863 int llvm_echo(void) {
881864 LLVMEnablePrettyStackTrace();
882865
99 |* Header file for llvm-c-test *|
1010 |* *|
1111 \*===----------------------------------------------------------------------===*/
12
1312 #ifndef LLVM_C_TEST_H
1413 #define LLVM_C_TEST_H
1514
16 #ifdef __cplusplus
17 #include
18 #else
1915 #include
20 #endif
2116 #include "llvm-c/Core.h"
2217
2318 #ifdef __cplusplus
5550
5651 #ifdef __cplusplus
5752 }
53 #endif /* !defined(__cplusplus) */
54
5855 #endif
59
60 #endif // LLVM_C_TEST_H
3939 #include "llvm/Support/Win64EH.h"
4040 #include "llvm/Support/raw_ostream.h"
4141 #include
42 #include
43 #include
44 #include
45 #include
46 #include
47 #include <tuple>
42 #include <cstring>
4843 #include
49 #include <vector>
44 #include <time.h>
5045
5146 using namespace llvm;
5247 using namespace llvm::object;
7570 void printCOFFBaseReloc() override;
7671 void printCodeViewDebugInfo() override;
7772 void printStackMap() const override;
78
7973 private:
8074 void printSymbol(const SymbolRef &Sym);
8175 void printRelocation(const SectionRef &Section, const RelocationRef &Reloc,
149143 StringSet<> TypeNames;
150144 };
151145
152 } // end anonymous namespace
146 } // namespace
147
153148
154149 namespace llvm {
155150
164159 return readobj_error::success;
165160 }
166161
167 } // end namespace llvm
162 } // namespace llvm
168163
169164 // Given a a section and an offset into this section the function returns the
170165 // symbol used for the relocation at the offset.
247242 }
248243 }
249244
250 namespace {
251
252 const EnumEntry ImageFileMachineType[] = {
245 static const EnumEntry ImageFileMachineType[] = {
253246 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_UNKNOWN ),
254247 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AM33 ),
255248 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AMD64 ),
273266 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_WCEMIPSV2)
274267 };
275268
276 const EnumEntry ImageFileCharacteristics[] = {
269 static const EnumEntry ImageFileCharacteristics[] = {
277270 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_RELOCS_STRIPPED ),
278271 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_EXECUTABLE_IMAGE ),
279272 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_LINE_NUMS_STRIPPED ),
291284 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_BYTES_REVERSED_HI )
292285 };
293286
294 const EnumEntry PEWindowsSubsystem[] = {
287 static const EnumEntry PEWindowsSubsystem[] = {
295288 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_UNKNOWN ),
296289 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_NATIVE ),
297290 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_WINDOWS_GUI ),
305298 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_XBOX ),
306299 };
307300
308 const EnumEntry PEDLLCharacteristics[] = {
301 static const EnumEntry PEDLLCharacteristics[] = {
309302 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA ),
310303 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE ),
311304 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY ),
319312 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE),
320313 };
321314
322 const EnumEntry
315 static const EnumEntry
323316 ImageSectionCharacteristics[] = {
324317 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NOLOAD ),
325318 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NO_PAD ),
359352 LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_WRITE )
360353 };
361354
362 const EnumEntry ImageSymType[] = {
355 static const EnumEntry ImageSymType[] = {
363356 { "Null" , COFF::IMAGE_SYM_TYPE_NULL },
364357 { "Void" , COFF::IMAGE_SYM_TYPE_VOID },
365358 { "Char" , COFF::IMAGE_SYM_TYPE_CHAR },
378371 { "DWord" , COFF::IMAGE_SYM_TYPE_DWORD }
379372 };
380373
381 const EnumEntry ImageSymDType[] = {
374 static const EnumEntry ImageSymDType[] = {
382375 { "Null" , COFF::IMAGE_SYM_DTYPE_NULL },
383376 { "Pointer" , COFF::IMAGE_SYM_DTYPE_POINTER },
384377 { "Function", COFF::IMAGE_SYM_DTYPE_FUNCTION },
385378 { "Array" , COFF::IMAGE_SYM_DTYPE_ARRAY }
386379 };
387380
388 const EnumEntry ImageSymClass[] = {
381 static const EnumEntry ImageSymClass[] = {
389382 { "EndOfFunction" , COFF::IMAGE_SYM_CLASS_END_OF_FUNCTION },
390383 { "Null" , COFF::IMAGE_SYM_CLASS_NULL },
391384 { "Automatic" , COFF::IMAGE_SYM_CLASS_AUTOMATIC },
415408 { "CLRToken" , COFF::IMAGE_SYM_CLASS_CLR_TOKEN }
416409 };
417410
418 const EnumEntry ImageCOMDATSelect[] = {
411 static const EnumEntry ImageCOMDATSelect[] = {
419412 { "NoDuplicates", COFF::IMAGE_COMDAT_SELECT_NODUPLICATES },
420413 { "Any" , COFF::IMAGE_COMDAT_SELECT_ANY },
421414 { "SameSize" , COFF::IMAGE_COMDAT_SELECT_SAME_SIZE },
425418 { "Newest" , COFF::IMAGE_COMDAT_SELECT_NEWEST }
426419 };
427420
428 const EnumEntry
421 static const EnumEntry
429422 WeakExternalCharacteristics[] = {
430423 { "NoLibrary", COFF::IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY },
431424 { "Library" , COFF::IMAGE_WEAK_EXTERN_SEARCH_LIBRARY },
432425 { "Alias" , COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS }
433426 };
434427
435 const EnumEntry CompileSym3Flags[] = {
428 static const EnumEntry CompileSym3Flags[] = {
436429 LLVM_READOBJ_ENUM_ENT(CompileSym3, EC),
437430 LLVM_READOBJ_ENUM_ENT(CompileSym3, NoDbgInfo),
438431 LLVM_READOBJ_ENUM_ENT(CompileSym3, LTCG),
447440 LLVM_READOBJ_ENUM_ENT(CompileSym3, Exp),
448441 };
449442
450 const EnumEntry SourceLanguages[] = {
443 static const EnumEntry SourceLanguages[] = {
451444 LLVM_READOBJ_ENUM_ENT(SourceLanguage, C),
452445 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Cpp),
453446 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Fortran),
467460 LLVM_READOBJ_ENUM_ENT(SourceLanguage, HLSL),
468461 };
469462
470 const EnumEntry SubSectionTypes[] = {
463 static const EnumEntry SubSectionTypes[] = {
471464 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, Symbols),
472465 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, Lines),
473466 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, StringTable),
483476 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, CoffSymbolRVA),
484477 };
485478
486 const EnumEntry CPUTypeNames[] = {
479 static const EnumEntry CPUTypeNames[] = {
487480 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel8080),
488481 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel8086),
489482 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel80286),
545538 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, D3D11_Shader),
546539 };
547540
548 const EnumEntry ProcSymFlags[] = {
541 static const EnumEntry ProcSymFlags[] = {
549542 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasFP),
550543 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasIRET),
551544 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasFRET),
556549 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasOptimizedDebugInfo),
557550 };
558551
559 const EnumEntry FrameProcSymFlags[] = {
552 static const EnumEntry FrameProcSymFlags[] = {
560553 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasAlloca),
561554 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasSetJmp),
562555 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasLongJmp),
582575 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, GuardCfw),
583576 };
584577
585 const EnumEntry FrameDataFlags[] = {
578 static const EnumEntry FrameDataFlags[] = {
586579 LLVM_READOBJ_ENUM_ENT(FrameData, HasSEH),
587580 LLVM_READOBJ_ENUM_ENT(FrameData, HasEH),
588581 LLVM_READOBJ_ENUM_ENT(FrameData, IsFunctionStart),
589582 };
590583
591 const EnumEntry LocalFlags[] = {
584 static const EnumEntry LocalFlags[] = {
592585 LLVM_READOBJ_ENUM_ENT(LocalSym, IsParameter),
593586 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAddressTaken),
594587 LLVM_READOBJ_ENUM_ENT(LocalSym, IsCompilerGenerated),
602595 LLVM_READOBJ_ENUM_ENT(LocalSym, IsEnregisteredStatic),
603596 };
604597
605 const EnumEntry FrameCookieKinds[] = {
598 static const EnumEntry FrameCookieKinds[] = {
606599 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, Copy),
607600 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorStackPointer),
608601 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorFramePointer),
609602 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorR13),
610603 };
611604
612 const EnumEntry ClassOptionNames[] = {
605 static const EnumEntry ClassOptionNames[] = {
613606 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Packed),
614607 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasConstructorOrDestructor),
615608 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasOverloadedOperator),
624617 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Intrinsic),
625618 };
626619
627 const EnumEntry MemberAccessNames[] = {
620 static const EnumEntry MemberAccessNames[] = {
628621 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, None),
629622 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Private),
630623 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Protected),
631624 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Public),
632625 };
633626
634 const EnumEntry MethodOptionNames[] = {
627 static const EnumEntry MethodOptionNames[] = {
635628 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, Pseudo),
636629 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, NoInherit),
637630 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, NoConstruct),
639632 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, Sealed),
640633 };
641634
642 const EnumEntry MemberKindNames[] = {
635 static const EnumEntry MemberKindNames[] = {
643636 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Vanilla),
644637 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Virtual),
645638 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Static),
652645 /// The names here all end in "*". If the simple type is a pointer type, we
653646 /// return the whole name. Otherwise we lop off the last character in our
654647 /// StringRef.
655 const EnumEntry SimpleTypeNames[] = {
648 static const EnumEntry SimpleTypeNames[] = {
656649 {"void*", SimpleTypeKind::Void},
657650 {"*", SimpleTypeKind::NotTranslated},
658651 {"HRESULT*", SimpleTypeKind::HResult},
693686 {"__bool64*", SimpleTypeKind::Boolean64},
694687 };
695688
696 const EnumEntry LeafTypeNames[] = {
689 static const EnumEntry LeafTypeNames[] = {
697690 #define LEAF_TYPE(name, val) LLVM_READOBJ_ENUM_ENT(TypeLeafKind, name),
698691 #include "llvm/DebugInfo/CodeView/CVLeafTypes.def"
699692 };
700693
701 const EnumEntry PtrKindNames[] = {
694 static const EnumEntry PtrKindNames[] = {
702695 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near16),
703696 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Far16),
704697 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Huge16),
714707 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near64),
715708 };
716709
717 const EnumEntry PtrModeNames[] = {
710 static const EnumEntry PtrModeNames[] = {
718711 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, Pointer),
719712 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, LValueReference),
720713 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, PointerToDataMember),
722715 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, RValueReference),
723716 };
724717
725 const EnumEntry PtrMemberRepNames[] = {
718 static const EnumEntry PtrMemberRepNames[] = {
726719 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, Unknown),
727720 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
728721 SingleInheritanceData),
740733 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, GeneralFunction),
741734 };
742735
743 const EnumEntry TypeModifierNames[] = {
736 static const EnumEntry TypeModifierNames[] = {
744737 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Const),
745738 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Volatile),
746739 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Unaligned),
747740 };
748741
749 const EnumEntry CallingConventions[] = {
742 static const EnumEntry CallingConventions[] = {
750743 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearC),
751744 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarC),
752745 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearPascal),
773766 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearVector),
774767 };
775768
776 const EnumEntry FunctionOptionEnum[] = {
769 static const EnumEntry FunctionOptionEnum[] = {
777770 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, CxxReturnUdt),
778771 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, Constructor),
779772 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, ConstructorWithVirtualBases),
780773 };
781774
782 const EnumEntry FileChecksumKindNames[] = {
775 static const EnumEntry FileChecksumKindNames[] = {
783776 LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, None),
784777 LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, MD5),
785778 LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, SHA1),
787780 };
788781
789782 template
790 std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
783 static std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
791784 COFFSymbolRef Symbol,
792785 uint8_t AuxSymbolIdx, const T *&Aux) {
793786 ArrayRef AuxData = Obj->getSymbolAuxData(Symbol);
795788 Aux = reinterpret_cast(AuxData.data());
796789 return readobj_error::success;
797790 }
798
799 } // end anonymous namespace
800791
801792 void COFFDumper::cacheRelocations() {
802793 if (RelocCached)
948939 }
949940 }
950941
951 namespace {
952
953942 /// Consumes sizeof(T) bytes from the given byte sequence. Returns an error if
954943 /// there are not enough bytes remaining. Reinterprets the consumed bytes as a
955944 /// T object and points 'Res' at them.
956945 template
957 std::error_code consumeObject(StringRef &Data, const T *&Res) {
946 static std::error_code consumeObject(StringRef &Data, const T *&Res) {
958947 if (Data.size() < sizeof(*Res))
959948 return object_error::parse_failed;
960949 Res = reinterpret_cast(Data.data());
962951 return std::error_code();
963952 }
964953
965 std::error_code consumeUInt32(StringRef &Data, uint32_t &Res) {
954 static std::error_code consumeUInt32(StringRef &Data, uint32_t &Res) {
966955 const ulittle32_t *IntPtr;
967956 if (auto EC = consumeObject(Data, IntPtr))
968957 return EC;
969958 Res = *IntPtr;
970959 return std::error_code();
971960 }
972
973 } // end anonymous namespace
974961
975962 void COFFDumper::initializeFileAndStringTables(StringRef Data) {
976963 while (!Data.empty() && (CVFileChecksumTable.data() == nullptr ||
11941181 }
11951182 }
11961183
1197 namespace {
1198
1199 std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) {
1184 static std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) {
12001185 // Used to avoid overload ambiguity on APInt construtor.
12011186 bool FalseVal = false;
12021187 if (Data.size() < 2)
12621247 return object_error::parse_failed;
12631248 }
12641249
1265 } // end anonymous namespace
1266
12671250 /// Decode an unsigned integer numeric leaf value.
12681251 std::error_code decodeUIntLeaf(StringRef &Data, uint64_t &Num) {
12691252 APSInt N;
13291312 break;
13301313 }
13311314
1332 case S_PROC_ID_END:
1315 case S_PROC_ID_END: {
13331316 W.startLine() << "ProcEnd\n";
13341317 InFunctionScope = false;
13351318 break;
1319 }
13361320
13371321 case S_BLOCK32: {
13381322 DictScope S(W, "BlockStart");
13521336 break;
13531337 }
13541338
1355 case S_END:
1339 case S_END: {
13561340 W.startLine() << "BlockEnd\n";
13571341 InFunctionScope = false;
13581342 break;
1343 }
13591344
13601345 case S_LABEL32: {
13611346 DictScope S(W, "Label");
15291514 printLocalVariableAddrGap(SymData);
15301515 break;
15311516 }
1532
15331517 case S_DEFRANGE_SUBFIELD: {
15341518 DictScope S(W, "DefRangeSubfield");
15351519 const DefRangeSubfieldSym *DefRangeSubfield;
15441528 printLocalVariableAddrGap(SymData);
15451529 break;
15461530 }
1547
15481531 case S_DEFRANGE_REGISTER: {
15491532 DictScope S(W, "DefRangeRegister");
15501533 const DefRangeRegisterSym *DefRangeRegister;
15561539 printLocalVariableAddrGap(SymData);
15571540 break;
15581541 }
1559
15601542 case S_DEFRANGE_SUBFIELD_REGISTER: {
15611543 DictScope S(W, "DefRangeSubfieldRegister");
15621544 const DefRangeSubfieldRegisterSym *DefRangeSubfieldRegisterSym;
15711553 printLocalVariableAddrGap(SymData);
15721554 break;
15731555 }
1574
15751556 case S_DEFRANGE_FRAMEPOINTER_REL: {
15761557 DictScope S(W, "DefRangeFramePointerRel");
15771558 const DefRangeFramePointerRelSym *DefRangeFramePointerRel;
15821563 printLocalVariableAddrGap(SymData);
15831564 break;
15841565 }
1585
15861566 case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE: {
15871567 DictScope S(W, "DefRangeFramePointerRelFullScope");
15881568 const DefRangeFramePointerRelFullScopeSym
15911571 W.printNumber("Offset", DefRangeFramePointerRelFullScope->Offset);
15921572 break;
15931573 }
1594
15951574 case S_DEFRANGE_REGISTER_REL: {
15961575 DictScope S(W, "DefRangeRegisterRel");
15971576 const DefRangeRegisterRelSym *DefRangeRegisterRel;
19651944 W.printHex(Label, getFileNameForFileOffset(FileOffset), FileOffset);
19661945 }
19671946
1968 namespace {
1969
1970 StringRef getLeafTypeName(TypeLeafKind LT) {
1947 static StringRef getLeafTypeName(TypeLeafKind LT) {
19711948 switch (LT) {
19721949 case LF_STRING_ID: return "StringId";
19731950 case LF_FIELDLIST: return "FieldList";
19961973 return "UnknownLeaf";
19971974 }
19981975
1999 } // end anonymous namespace
2000
20011976 void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
20021977 const SectionRef &Section) {
20031978 ListScope D(W, "CodeViewTypes");
22242199 break;
22252200 }
22262201
2227 case LF_METHODLIST:
2202 case LF_METHODLIST: {
22282203 while (!LeafData.empty()) {
22292204 const MethodListEntry *Method;
22302205 error(consumeObject(LeafData, Method));
22382213 }
22392214 }
22402215 break;
2216 }
22412217
22422218 case LF_FUNC_ID: {
22432219 const FuncId *Func;
23792355 }
23802356 }
23812357
2382 namespace {
2383
2384 StringRef skipPadding(StringRef Data) {
2358 static StringRef skipPadding(StringRef Data) {
23852359 if (Data.empty())
23862360 return Data;
23872361 uint8_t Leaf = Data.front();
23912365 // low 4 bits.
23922366 return Data.drop_front(Leaf & 0x0F);
23932367 }
2394
2395 } // end anonymous namespace
23962368
23972369 void COFFDumper::printMemberAttributes(MemberAttributes Attrs) {
23982370 W.printEnum("AccessSpecifier", uint8_t(Attrs.getAccess()),
26582630
26592631 void COFFDumper::printDynamicSymbols() { ListScope Group(W, "DynamicSymbols"); }
26602632
2661 namespace {
2662
2663 ErrorOr
2633 static ErrorOr
26642634 getSectionName(const llvm::object::COFFObjectFile *Obj, int32_t SectionNumber,
26652635 const coff_section *Section) {
26662636 if (Section) {
26772647 return StringRef("IMAGE_SYM_UNDEFINED");
26782648 return StringRef("");
26792649 }
2680
2681 } // end anonymous namespace
26822650
26832651 void COFFDumper::printSymbol(const SymbolRef &Sym) {
26842652 DictScope D(W, "Symbol");
29242892 }
29252893 }
29262894
2927 namespace {
2928
2929 StringRef getBaseRelocTypeName(uint8_t Type) {
2895 static StringRef getBaseRelocTypeName(uint8_t Type) {
29302896 switch (Type) {
29312897 case COFF::IMAGE_REL_BASED_ABSOLUTE: return "ABSOLUTE";
29322898 case COFF::IMAGE_REL_BASED_HIGH: return "HIGH";
29382904 default: return "unknown (" + llvm::utostr(Type) + ")";
29392905 }
29402906 }
2941
2942 } // end anonymous namespace
29432907
29442908 void COFFDumper::printCOFFBaseReloc() {
29452909 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"
1412 #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"
1913 #include "llvm/ADT/Twine.h"
2014 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
2115 #include "llvm/MC/MCAsmInfo.h"
5246 #include "llvm/Support/raw_ostream.h"
5347
5448 #include
55 #include
56 #include
57 #include
58 #include
5949 #include
50 #include
6051 #include
61 #include
6252 #include
6353 #include
6454
9282 "Print coverage statistics."),
9383 clEnumValEnd));
9484
95 cl::list
85 static cl::list
9686 ClInputFiles(cl::Positional, cl::OneOrMore,
9787 cl::desc("(|<.sancov file>)..."));
9888
99 cl::opt ClDemangle("demangle", cl::init(true),
100 cl::desc("Print demangled function name."));
101
102 cl::opt ClStripPathPrefix(
89 static cl::opt ClDemangle("demangle", cl::init(true),
90 cl::desc("Print demangled function name."));
91
92 static cl::opt ClStripPathPrefix(
10393 "strip_path_prefix", cl::init(""),
10494 cl::desc("Strip this prefix from file paths in reports."));
10595
106 cl::opt
96 static cl::opt
10797 ClBlacklist("blacklist", cl::init(""),
10898 cl::desc("Blacklist file (sanitizer blacklist format)."));
10999
110 cl::opt ClUseDefaultBlacklist(
100 static cl::opt ClUseDefaultBlacklist(
111101 "use_default_blacklist", cl::init(true), cl::Hidden,
112102 cl::desc("Controls if default blacklist should be used."));
113103
114 const char *const DefaultBlacklistStr = "fun:__sanitizer_.*\n"
115 "src:/usr/include/.*\n"
116 "src:.*/libc\\+\\+/.*\n";
104 static const char *const DefaultBlacklistStr = "fun:__sanitizer_.*\n"
105 "src:/usr/include/.*\n"
106 "src:.*/libc\\+\\+/.*\n";
117107
118108 // --------- FORMAT SPECIFICATION ---------
119109
122112 uint32_t Magic;
123113 };
124114
125 const uint32_t BinCoverageMagic = 0xC0BFFFFF;
126 const uint32_t Bitness32 = 0xFFFFFF32;
127 const uint32_t Bitness64 = 0xFFFFFF64;
115 static const uint32_t BinCoverageMagic = 0xC0BFFFFF;
116 static const uint32_t Bitness32 = 0xFFFFFF32;
117 static const uint32_t Bitness64 = 0xFFFFFF64;
128118
129119 // --------- ERROR HANDLING ---------
130120
131 void Fail(const llvm::Twine &E) {
121 static void Fail(const llvm::Twine &E) {
132122 errs() << "Error: " << E << "\n";
133123 exit(1);
134124 }
135125
136 void FailIfError(std::error_code Error) {
126 static void FailIfError(std::error_code Error) {
137127 if (!Error)
138128 return;
139129 errs() << "Error: " << Error.message() << "(" << Error.value() << ")\n";
140130 exit(1);
141131 }
142132
143 template
144 void FailIfError(const ErrorOr &E) {
133 template static void FailIfError(const ErrorOr &E) {
145134 FailIfError(E.getError());
146135 }
147136
148 void FailIfNotEmpty(const llvm::Twine &E) {
137 static void FailIfNotEmpty(const llvm::Twine &E) {
149138 if (E.str().empty())
150139 return;
151140 Fail(E);
152141 }
153142
154143 template
155 void FailIfEmpty(const std::unique_ptr &Ptr, const std::string &Message) {
144 static void FailIfEmpty(const std::unique_ptr &Ptr,
145 const std::string &Message) {
156146 if (Ptr.get())
157147 return;
158148 Fail(Message);
163153 // Produces std::map> grouping input
164154 // elements by FuncTy result.
165155 template
166 inline auto group_by(const RangeTy &R, FuncTy F)
156 static inline auto group_by(const RangeTy &R, FuncTy F)
167157 -> std::map::type,
168158 std::vector::type>> {
169159 std::map::type,
176166 }
177167
178168 template
179 void readInts(const char *Start, const char *End, std::set *Ints) {
169 static void readInts(const char *Start, const char *End,
170 std::set *Ints) {
180171 const T *S = reinterpret_cast(Start);
181172 const T *E = reinterpret_cast(End);
182173 std::copy(S, E, std::inserter(*Ints, Ints->end()));
219210 return Path.substr(Pos + ClStripPathPrefix.size());
220211 }
221212
222 std::unique_ptr createSymbolizer() {
213 static std::unique_ptr createSymbolizer() {
223214 symbolize::LLVMSymbolizer::Options SymbolizerOptions;
224215 SymbolizerOptions.Demangle = ClDemangle;
225216 SymbolizerOptions.UseSymbolTable = true;
284275 };
285276
286277 // Collect all debug info for given addresses.
287 std::vector getAddrInfo(std::string ObjectFile,
288 const std::set &Addrs,
289 bool InlinedCode) {
278 static std::vector getAddrInfo(std::string ObjectFile,
279 const std::set &Addrs,
280 bool InlinedCode) {
290281 std::vector Result;
291282 auto Symbolizer(createSymbolizer());
292283 Blacklists B;
314305
315306 // Locate __sanitizer_cov* function addresses that are used for coverage
316307 // reporting.
317 std::set
308 static std::set
318309 findSanitizerCovFunctions(const object::ObjectFile &O) {
319310 std::set Result;
320311
339330 // Locate addresses of all coverage points in a file. Coverage point
340331 // is defined as the 'address of instruction following __sanitizer_cov
341332 // call - 1'.
342 void getObjectCoveragePoints(const object::ObjectFile &O,
343 std::set *Addrs) {
333 static void getObjectCoveragePoints(const object::ObjectFile &O,
334 std::set *Addrs) {
344335 Triple TheTriple("unknown-unknown-unknown");
345336 TheTriple.setArch(Triple::ArchType(O.getArch()));
346337 auto TripleName = TheTriple.getTriple();
412403 }
413404 }
414405
415 void
406 static void
416407 visitObjectFiles(const object::Archive &A,
417408 std::function Fn) {
418409 for (auto &ErrorOrChild : A.children()) {
427418 }
428419 }
429420
430 void
421 static void
431422 visitObjectFiles(std::string FileName,
432423 std::function Fn) {
433424 ErrorOr> BinaryOrErr =
463454 return Result;
464455 }
465456
466 void printCovPoints(std::string ObjFile, raw_ostream &OS) {
457 static void printCovPoints(std::string ObjFile, raw_ostream &OS) {
467458 for (uint64_t Addr : getCoveragePoints(ObjFile)) {
468459 OS << "0x";
469460 OS.write_hex(Addr);
471462 }
472463 }
473464
474 std::string escapeHtml(const std::string &S) {
465 static std::string escapeHtml(const std::string &S) {
475466 std::string Result;
476467 Result.reserve(S.size());
477468 for (char Ch : S) {
501492
502493 // Adds leading zeroes wrapped in 'lz' style.
503494 // Leading zeroes help locate 000% coverage.
504 std::string formatHtmlPct(size_t Pct) {
495 static std::string formatHtmlPct(size_t Pct) {
505496 Pct = std::max(std::size_t{0}, std::min(std::size_t{100}, Pct));
506497
507498 std::string Num = std::to_string(Pct);
512503 return Zeroes + Num;
513504 }
514505
515 std::string anchorName(std::string Anchor) {
506 static std::string anchorName(std::string Anchor) {
516507 llvm::MD5 Hasher;
517508 llvm::MD5::MD5Result Hash;
518509 Hasher.update(Anchor);
523514 return HexString.str().str();
524515 }
525516
526 ErrorOr isCoverageFile(std::string FileName) {
517 static ErrorOr isCoverageFile(std::string FileName) {
527518 ErrorOr> BufOrErr =
528519 MemoryBuffer::getFile(FileName);
529520 if (!BufOrErr) {
550541 size_t CovFns;
551542 };
552543
553 raw_ostream &operator<<(raw_ostream &OS, const CoverageStats &Stats) {
544 static raw_ostream &operator<<(raw_ostream &OS, const CoverageStats &Stats) {
554545 OS << "all-edges: " << Stats.AllPoints << "\n";
555546 OS << "cov-edges: " << Stats.CovPoints << "\n";
556547 OS << "all-functions: " << Stats.AllFns << "\n";
830821 std::vector CovAddrInfo;
831822 };
832823
833 void printFunctionLocs(const SourceCoverageData::FunctionLocs &FnLocs,
834 raw_ostream &OS) {
824 static void printFunctionLocs(const SourceCoverageData::FunctionLocs &FnLocs,
825 raw_ostream &OS) {
835826 for (const auto &Fns : FnLocs) {
836827 for (const auto &Fn : Fns.second) {
837828 OS << stripPathPrefix(Fns.first.FileName) << ":" << Fns.first.Line << " "
11901181 const std::set CoverageFiles;
11911182 };
11921183
1193 } // end anonymous namespace
1184 } // namespace
11941185
11951186 int main(int argc, char **argv) {
11961187 // Print stack trace if we signal out.
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "llvm/ADT/StringRef.h"
1514 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
1615 #include "llvm/Support/CommandLine.h"
1716 #include "llvm/Support/ErrorOr.h"
1817 #include "llvm/Support/MemoryBuffer.h"
1918 #include "llvm/Transforms/Utils/SanitizerStats.h"
20 #include
21 #include
22 #include
23 #include ring>
19 #include dint.h>
2420
2521 using namespace llvm;
2622
27 namespace {
23 static cl::opt ClInputFile(cl::Positional, cl::Required,
24 cl::desc(""));
2825
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."));
26 static cl::opt ClDemangle("demangle", cl::init(false),
27 cl::desc("Print demangled function name."));
3428
3529 inline uint64_t KindFromData(uint64_t Data, char SizeofPtr) {
3630 return Data >> (SizeofPtr * 8 - kSanitizerStatKindBits);
6862 SymbolizerOptions.UseSymbolTable = true;
6963 symbolize::LLVMSymbolizer Symbolizer(SymbolizerOptions);
7064
71 while (true) {
65 while (1) {
7266 uint64_t Addr = ReadLE(SizeofPtr, Begin, End);
7367 Begin += SizeofPtr;
7468 uint64_t Data = ReadLE(SizeofPtr, Begin, End);
114108 }
115109 }
116110
117 } // end anonymous namespace
118
119111 int main(int argc, char **argv) {
120112 cl::ParseCommandLineOptions(argc, argv,
121113 "Sanitizer Statistics Processing Tool");
99 #include "llvm/ADT/SCCIterator.h"
1010 #include "llvm/ADT/GraphTraits.h"
1111 #include "gtest/gtest.h"
12 #include
13 #include
14 #include
15 #include <vector>
12 #include <limits.h>
1613
1714 using namespace llvm;
1815
2926 static void ValidateIndex(unsigned Idx) {
3027 assert(Idx < N && "Invalid node index!");
3128 }
32
3329 public:
30
3431 /// NodeSubset - A subset of the graph's nodes.
3532 class NodeSubset {
3633 typedef unsigned char BitVector; // Where the limitation N <= 8 comes from.
3734 BitVector Elements;
3835 NodeSubset(BitVector e) : Elements(e) {}
39
4036 public:
4137 /// NodeSubset - Default constructor, creates an empty subset.
4238 NodeSubset() : Elements(0) {
10197 private:
10298 /// Nodes - The list of nodes for this graph.
10399 NodeType Nodes[N];
104
105100 public:
101
106102 /// Graph - Default constructor. Creates an empty graph.
107103 Graph() {
108104 // Let each node know which node it is. This allows us to find the start of
169165 NodeSubset Children;
170166
171167 ChildIterator(); // Disable default constructor.
172
173168 protected:
174169 ChildIterator(NodeType *F, NodeSubset C) : FirstNode(F), Children(C) {}
175170
345340 }
346341 }
347342
348 } // end namespace llvm
343 }
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/ADT/SmallString.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringRef.h"
1614 #include "gtest/gtest.h"
15 #include
16 #include
17 #include
1718
1819 using namespace llvm;
1920
202203 EXPECT_EQ( 1, SmallString<10>("V8_q0").compare_numeric("V1_q0"));
203204 }
204205
205 } // end anonymous namespace
206 }
1414 #include "llvm/ADT/SmallVector.h"
1515 #include "llvm/Support/Compiler.h"
1616 #include "gtest/gtest.h"
17 #include
18 #include
1917 #include
20 #include <utility>
18 #include <stdarg.h>
2119
2220 using namespace llvm;
2321
142140 int Constructable::numMoveAssignmentCalls;
143141
144142 struct NonCopyable {
145 NonCopyable() = default;
146 NonCopyable(NonCopyable &&) = default;
143 NonCopyable() {}
144 NonCopyable(NonCopyable &&) {}
147145 NonCopyable &operator=(NonCopyable &&) { return *this; }
148
149146 private:
150147 NonCopyable(const NonCopyable &) = delete;
151148 NonCopyable &operator=(const NonCopyable &) = delete;
201198 VectorT theVector;
202199 VectorT otherVector;
203200 };
201
204202
205203 typedef ::testing::Types,
206204 SmallVector,
523521 this->assertValuesInOrder(this->theVector, 6u, 1, 16, 16, 2, 3, 4);
524522 }
525523
524
526525 TYPED_TEST(SmallVectorTest, InsertRepeatedAtEndTest) {
527526 SCOPED_TRACE("InsertRepeatedTest");
528527
581580 this->assertValuesInOrder(this->theVector, 6u, 1, 77, 77, 77, 2, 3);
582581 }
583582
583
584584 TYPED_TEST(SmallVectorTest, InsertRangeAtEndTest) {
585585 SCOPED_TRACE("InsertRangeTest");
586586
747747
748748 struct MovedFrom {
749749 bool hasValue;
750
751750 MovedFrom() : hasValue(true) {
752751 }
753
754752 MovedFrom(MovedFrom&& m) : hasValue(m.hasValue) {
755753 m.hasValue = false;
756754 }
757
758755 MovedFrom &operator=(MovedFrom&& m) {
759756 hasValue = m.hasValue;
760757 m.hasValue = false;
777774 EAS_RValue,
778775 EAS_Failure
779776 };
780
781777 template struct EmplaceableArg {
782778 EmplaceableArgState State;
783779 EmplaceableArg() : State(EAS_Defaulted) {}
927923 EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2}));
928924 }
929925
930 } // end anonymous namespace
926 } // end 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"
1615
17 #include
18 #include <memory>
16 #include <stdio.h>
17 #include
18 #include
1919
2020 namespace llvm {
2121
156156 LLVMOrcDisposeInstance(JIT);
157157 }
158158
159 } // end namespace llvm
159 } // namespace llvm
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/ArrayRef.h"
109 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/SmallVector.h"
12 #include "llvm/ADT/StringMap.h"
13 #include "llvm/ADT/StringRef.h"
1410 #include "llvm/Config/config.h"
15 #include "llvm/Support/Allocator.h"
1611 #include "llvm/Support/CommandLine.h"
1712 #include "llvm/Support/StringSaver.h"
1813 #include "gtest/gtest.h"
19 #include <cstdlib>
14 #include <stdlib.h>
2015 #include
2116
2217 using namespace llvm;
2419 namespace {
2520
2621 class TempEnvVar {
27 public:
22 public:
2823 TempEnvVar(const char *name, const char *value)
2924 : name(name) {
3025 const char *old_value = getenv(name);
4540 #endif
4641 }
4742
48 private:
43 private:
4944 const char *const name;
5045 };
5146
5247 template
5348 class StackOption : public cl::opt {
5449 typedef cl::opt Base;
55
5650 public:
5751 // One option...
5852 template
7367
7468 ~StackOption() override { this->removeArgument(); }
7569 };
70
7671
7772 cl::OptionCategory TestCategory("Test Options", "Description");
7873 TEST(CommandLineTest, ModifyExisitingOption) {
269264 << "Hid default option that should be visable.";
270265 }
271266
272 } // end anonymous namespace
267 } // anonymous namespace
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/SmallString.h"
10 #include "llvm/ADT/StringRef.h"
119 #include "llvm/Support/ConvertUTF.h"
1210 #include "llvm/Support/CommandLine.h"
1311 #include "llvm/Support/FileSystem.h"
1412 #include "llvm/Support/Path.h"
1513 #include "llvm/Support/Program.h"
16 #include "llvm/Support/raw_ostream.h"
1714 #include "gtest/gtest.h"
18 #include
19 #include
20 #include
21 #include <vector>
15 #include <stdlib.h>
2216 #if defined(__APPLE__)
2317 # include
2418 #elif !defined(_MSC_VER)
5044 GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
5145 } else { \
5246 }
53
5447 // From TestMain.cpp.
5548 extern const char *TestMainArgv0;
5649
5952 using namespace llvm;
6053 using namespace sys;
6154
62 cl::opt
55 static cl::opt
6356 ProgramTestStringArg1("program-test-string-arg1");
64 cl::opt
57 static cl::opt
6558 ProgramTestStringArg2("program-test-string-arg2");
6659
6760 class ProgramEnvTest : public testing::Test {
315308 ASSERT_TRUE(ExecutionFailed);
316309 ASSERT_FALSE(Error.empty());
317310 }
311
318312 }
319313
320314 #ifdef LLVM_ON_WIN32
1010 #include "llvm/ADT/StringRef.h"
1111 #include "llvm/Support/StreamingMemoryObject.h"
1212 #include "gtest/gtest.h"
13 #include <cstring>
13 #include <string.h>
1414
1515 using namespace llvm;
1616
6464 EXPECT_TRUE(std::equal(InputBuffer, InputBuffer + 8, O.getPointer(0, 20)));
6565 }
6666
67 } // end anonymous namespace
67 } // end namespace
88
99 #include "gtest/gtest.h"
1010 #include "llvm/Support/TimeValue.h"
11 #include
12 #include
13 #include <ctime>
11 #include <time.h>
1412
1513 using namespace llvm;
16
1714 namespace {
1815
1916 TEST(TimeValue, time_t) {
3936 EXPECT_EQ(ft1970, epoch.toWin32Time());
4037 }
4138
42 } // end anonymous namespace
39 }
1212 #if LLVM_ON_WIN32
1313 #include
1414 #else
15 #include <ctime>
15 #include <time.h>
1616 #endif
1717
1818 using namespace llvm;
6161 EXPECT_FALSE(T1.hasTriggered());
6262 }
6363
64 } // end anonymous namespace
64 } // end anon namespace