summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* Support formatv of TimePoint with strftime-style formats.Sam McCall2017-10-241-25/+27
| | | | | | | | | | | | | | | | Summary: Support formatv of TimePoint with strftime-style formats. Extensions for millis/micros/nanos are added. Inital use case is HH:MM:SS.MMM timestamps in clangd logs. Reviewers: bkramer, ilya-biryukov Subscribers: labath, llvm-commits Differential Revision: https://reviews.llvm.org/D38992 llvm-svn: 316419
* Fix FormatVariadicTest with GCCJonas Hahnfeld2017-10-231-1/+3
| | | | | | Looks like GCC didn't like the original specialization, try within namespace. llvm-svn: 316361
* Support formatting formatv_objects.Sam McCall2017-10-231-0/+29
| | | | | | | | | | | | | | | | Summary: Support formatting formatv_objects. While here, fix documentation about member-formatters, and attempted perfect-forwarding (I think). Reviewers: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38997 llvm-svn: 316330
* Untabify.NAKAMURA Takumi2017-10-181-10/+10
| | | | llvm-svn: 316079
* Add DK_Remark to SMDiagnosticAdam Nemet2017-10-121-0/+10
| | | | | | | | | | | Swift uses SMDiagnostic for diagnostic messages. For https://github.com/apple/swift/pull/12294, we need remark support. I picked the color that clang uses to display them. Differential Revision: https://reviews.llvm.org/D38865 llvm-svn: 315642
* Support: Have directory_iterator::status() return ↵Peter Collingbourne2017-10-101-2/+2
| | | | | | | | | | | | | | | | | | FindFirstFileEx/FindNextFile results on Windows. This allows clients to avoid an unnecessary fs::status() call on each directory entry. Because the information returned by FindFirstFileEx is a subset of the information returned by a regular status() call, I needed to extract a base class from file_status that contains only that information. On my machine, this reduces the time required to enumerate a ThinLTO cache directory containing 520k files from almost 4 minutes to less than 2 seconds. Differential Revision: https://reviews.llvm.org/D38716 llvm-svn: 315378
* Remove unused variables. No functionality change.Benjamin Kramer2017-10-081-2/+0
| | | | llvm-svn: 315196
* Remove unused variables. No functionality change.Benjamin Kramer2017-10-081-1/+0
| | | | llvm-svn: 315185
* Support: Rewrite Windows implementation of sys::fs::rename to be more POSIXy.Peter Collingbourne2017-10-061-14/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of rename uses ReplaceFile if the destination file already exists. According to the documentation for ReplaceFile, the source file is opened without a sharing mode. This means that there is a short interval of time between when ReplaceFile renames the file and when it closes the file during which the destination file cannot be opened. This behaviour is not POSIX compliant because rename is supposed to be atomic. It was also causing intermittent link failures when linking with a ThinLTO cache; the ThinLTO cache implementation expects all cache files to be openable. This patch addresses that problem by re-implementing rename using CreateFile and SetFileInformationByHandle. It is roughly a reimplementation of ReplaceFile with a better sharing policy as well as support for renaming in the case where the destination file does not exist. This implementation is still not fully POSIX. Specifically in the case where the destination file is open at the point when rename is called, there will be a short interval of time during which the destination file will not exist. It isn't clear whether it is possible to avoid this using the Windows API. Differential Revision: https://reviews.llvm.org/D38570 llvm-svn: 315079
* Fix off-by-one error in TarWriter.Rui Ueyama2017-09-271-19/+54
| | | | | | | | | | | | | | | | | | | | | | | | The tar format originally supported up to 99 byte filename. The two extensions are proposed later: Ustar or PAX. In the UStar extension, a pathanme is split at a '/' and its "prefix" and "suffix" are stored in different locations in the tar header. Since "prefix" can be up to 155 byte, it can represent up to 254 byte filename (but exact limit depends on the location of '/' character in a pathname.) Our TarWriter first attempt to use UStar extension and then fallback to PAX extension. But there's a bug in UStar header creation. "Suffix" part must be a NUL- terminated string, but we didn't handle it correctly. As a result, if your filename just 100 characters long, the last character was droppped. This patch fixes the issue. Differential Revision: https://reviews.llvm.org/D38149 llvm-svn: 314349
* Add section headers to SpecialCaseListsVlad Tsyrklevich2017-09-251-55/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Sanitizer blacklist entries currently apply to all sanitizers--there is no way to specify that an entry should only apply to a specific sanitizer. This is important for Control Flow Integrity since there are several different CFI modes that can be enabled at once. For maximum security, CFI blacklist entries should be scoped to only the specific CFI mode(s) that entry applies to. Adding section headers to SpecialCaseLists allows users to specify more information about list entries, like sanitizer names or other metadata, like so: [section1] fun:*fun1* [section2|section3] fun:*fun23* The section headers are regular expressions. For backwards compatbility, blacklist entries entered before a section header are put into the '[*]' section so that blacklists without sections retain the same behavior. SpecialCaseList has been modified to also accept a section name when matching against the blacklist. It has also been modified so the follow-up change to clang can define a derived class that allows matching sections by SectionMask instead of by string. Reviewers: pcc, kcc, eugenis, vsk Reviewed By: eugenis, vsk Subscribers: vitalybuka, llvm-commits Differential Revision: https://reviews.llvm.org/D37924 llvm-svn: 314170
* [AArch64] Add basic support for Qualcomm's Saphira CPU.Chad Rosier2017-09-252-0/+17
| | | | llvm-svn: 314105
* [Falkor] Add falkor CPU to host detectionBalaram Makam2017-09-221-0/+3
| | | | | | This returns "falkor" for Falkor CPU. llvm-svn: 313998
* Change encodeU/SLEB128 to pad to certain number of bytesSam Clegg2017-09-151-16/+17
| | | | | | | | | | | | | | | Previously the 'Padding' argument was the number of padding bytes to add. However most callers that use 'Padding' know how many overall bytes they need to write. With the previous code this would mean encoding the LEB once to find out how many bytes it would occupy and then using this to calulate the 'Padding' value. See: https://reviews.llvm.org/D36595 Differential Revision: https://reviews.llvm.org/D37494 llvm-svn: 313393
* [ARM] Add more CPUs to host detectionEli Friedman2017-09-131-0/+6
| | | | | | | | | This returns "cortex-a73" for second-generation Kryo; not precisely correct, but close enough. Differential Revision: https://reviews.llvm.org/D37724 llvm-svn: 313200
* [unittests] Fix up test after rL313156Vedant Kumar2017-09-131-2/+3
| | | | | Bot: http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/42421 llvm-svn: 313163
* Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko2017-09-131-12/+11
| | | | | | | | | | | | | | | | | | | | Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 llvm-svn: 313155
* [unittest/ReverseIteration] Unbreak when compiling with GCC.Davide Italiano2017-09-051-1/+6
| | | | llvm-svn: 312579
* [unittests] Add reverse iteration unit test for pointer-like keysMandeep Singh Grang2017-09-051-0/+50
| | | | | | | | | | | | Reviewers: dblaikie, efriedma, mehdi_amini Reviewed By: dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37241 llvm-svn: 312574
* [Error] Add an optional error message to cantFail.Lang Hames2017-08-291-2/+3
| | | | | | | | | | | cantFail is the moral equivalent of an assertion that the wrapped call must return a success value. This patch allows clients to include an associated error message (the same way they would for an assertion for llvm_unreachable). If the error message is not specified it will default to: "Failure value returned from cantFail wrapped call". llvm-svn: 312066
* [Support][CommandLine] Add cl::Option::setDefault()Evgeny Mankov2017-08-281-0/+35
| | | | | | | | | | | | | | | Add abstract virtual method setDefault() to class Option and implement it in its inheritors in order to be able to set all the options to its default values in user's code without actually knowing all these options. For instance: for (auto &OM : cl::getRegisteredOptions(*cl::TopLevelSubCommand)) { cl::Option *O = OM.second; O->setDefault(); } Reviewed by: rampitec, Eugene.Zelenko, kasaurov Differential Revision: http://reviews.llvm.org/D36877 llvm-svn: 311887
* Untabify.NAKAMURA Takumi2017-08-281-3/+3
| | | | llvm-svn: 311875
* [Error] Add a handleExpected utility.Lang Hames2017-08-281-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | handleExpected is similar to handleErrors, but takes an Expected<T> as its first input value and a fallback functor as its second, followed by an arbitary list of error handlers (equivalent to the handler list of handleErrors). If the first input value is a success value then it is returned from handleErrors unmodified. Otherwise the contained error(s) are passed to handleErrors, along with the handlers. If handleErrors returns success (indicating that all errors have been handled) then handleExpected runs the fallback functor and returns its result. If handleErrors returns a failure value then the failure value is returned and the fallback functor is never run. This simplifies the process of re-trying operations that return Expected values. Without this utility such retry logic is cumbersome as the internal Error must be explicitly extracted from the Expected value, inspected to see if its handleable and then consumed: enum FooStrategy { Aggressive, Conservative }; Expected<Foo> tryFoo(FooStrategy S); Expected<Foo> Result; (void)!!Result; // "Check" Result so that it can be safely overwritten. if (auto ValOrErr = tryFoo(Aggressive)) Result = std::move(ValOrErr); else { auto Err = ValOrErr.takeError(); if (Err.isA<HandleableError>()) { consumeError(std::move(Err)); Result = tryFoo(Conservative); } else return std::move(Err); } with handleExpected, this can be re-written as: auto Result = handleExpected( tryFoo(Aggressive), []() { return tryFoo(Conservative); }, [](HandleableError&) { /* discard to handle */ }); llvm-svn: 311870
* [unittests] Remove reverse iteration tests which use pointer-like keysMandeep Singh Grang2017-08-251-60/+4
| | | | | | | | | | | | | | Summary: The expected order of pointer-like keys is hash-function-dependent which in turn depends on the platform/environment. Need to come up with a better way to test reverse iteration of containers with pointer-like keys. Reviewers: dblaikie, mehdi_amini, efriedma, mgrang Reviewed By: mgrang Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37128 llvm-svn: 311741
* Fix two (three) more issues with unchecked Error.Stephen Hines2017-08-251-1/+1
| | | | | | | | | | | | | | | | | | | Summary: If assertions are disabled, but LLVM_ABI_BREAKING_CHANGES is enabled, this will cause an issue with an unchecked Success. Switching to consumeError() is the correct way to bypass the check. This patch also includes disabling 2 tests that can't work without assertions enabled, since llvm_unreachable() with NDEBUG won't crash. Reviewers: llvm-commits, lhames Reviewed By: lhames Subscribers: lhames, pirama Differential Revision: https://reviews.llvm.org/D36729 llvm-svn: 311739
* [ADT] Enable reverse iteration for DenseMapMandeep Singh Grang2017-08-242-0/+112
| | | | | | | | | | | | Reviewers: mehdi_amini, dexonsmith, dblaikie, davide, chandlerc, davidxl, echristo, efriedma Reviewed By: dblaikie Subscribers: rsmith, mgorny, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35043 llvm-svn: 311730
* [TargetParser][AArch64] Add support for RDM feature in the target parser.Chad Rosier2017-08-241-7/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D37081 llvm-svn: 311659
* [Support] Rewrite handleAllErrors in terms of cantFail.Lang Hames2017-08-241-2/+3
| | | | | | | | This just switches handleAllErrors from using custom assertions that all errors have been handled to using cantFail. This change involves moving some of the class and function definitions around though. llvm-svn: 311631
* [ARM][AArch64] Add Armv8.3-a unittestsSam Parker2017-08-221-4/+10
| | | | | | | | Add Armv8.3-A to the architecture to the TargetParser unittests. Differential Revision: https://reviews.llvm.org/D36748 llvm-svn: 311450
* [Support, Windows] Handle long paths with unix separatorsPirama Arumuga Nainar2017-08-211-0/+15
| | | | | | | | | | | | | | | | | | Summary: The function widenPath() for Windows also normalizes long path names by iterating over the path's components and calling append(). The assumption during the iteration that separators are not returned by the iterator doesn't hold because the iterators do return a separator when the path has a drive name. Handle this case by ignoring separators during iteration. Reviewers: rnk Subscribers: danalbert, srhines Differential Revision: https://reviews.llvm.org/D36752 llvm-svn: 311382
* [ARM][AArch64] Cortex-A75 and Cortex-A55 supportSam Parker2017-08-211-2/+34
| | | | | | | | | | | | | | | | | | This patch introduces support for Cortex-A75 and Cortex-A55, Arm's latest big.LITTLE A-class cores. They implement the ARMv8.2-A architecture, including the cryptography and RAS extensions, plus the optional dot product extension. They also implement the RCpc AArch64 extension from ARMv8.3-A. Cortex-A75: https://developer.arm.com/products/processors/cortex-a/cortex-a75 Cortex-A55: https://developer.arm.com/products/processors/cortex-a/cortex-a55 Differential Revision: https://reviews.llvm.org/D36667 llvm-svn: 311316
* [Support] env vars with empty values on windowsBen Dunbobbin2017-08-181-1/+9
| | | | | | | | | | | | | | | | An environment variable can be in one of three states: 1. undefined. 2. defined with a non-empty value. 3. defined but with an empty value. The windows implementation did not support case 3 (it was not handling errors). The Linux implementation is already correct. Differential Revision: https://reviews.llvm.org/D36394 llvm-svn: 311174
* [Support] PR33388 - Fix formatv_object move constructorBenoit Belley2017-08-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | formatv_object currently uses the implicitly defined move constructor, but it is buggy. In typical use-cases, the problem doesn't show-up because all calls to the move constructor are elided. Thus, the buggy constructors are never invoked. The issue especially shows-up when code is compiled using the -fno-elide-constructors compiler flag. For instance, this is useful when attempting to collect accurate code coverage statistics. The exact issue is the following: The Parameters data member is correctly moved, thus making the parameters occupy a new memory location in the target object. Unfortunately, the default copying of the Adapters blindly copies the vector of pointers, leaving each of these pointers referencing the parameters in the original object instead of the copied one. These pointers quickly become dangling when the original object is deleted. This quickly leads to crashes. The solution is to update the Adapters pointers when performing a move. The copy constructor isn't useful for format objects and can thus be deleted. This resolves PR33388. Differential Revision: https://reviews.llvm.org/D34463 llvm-svn: 310475
* [Support] Remove getPathFromOpenFD, it was unusedReid Kleckner2017-08-041-90/+0
| | | | | | | | | | | | | | Summary: It was added to support clang warnings about includes with case mismatches, but it ended up not being necessary. Reviewers: twoh, rafael Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D36328 llvm-svn: 310078
* [Support/GlobPattern] - Do not crash when pattern has characters with int ↵George Rimar2017-07-311-0/+9
| | | | | | | | | | | | | | | value < 0. Found it during work on LLD, it would crash on following linker script: SECTIONS { .foo : { *("*®") } } That happens because ® has int value -82. And chars are used as array index in code, and are signed by default. Differential revision: https://reviews.llvm.org/D35891 llvm-svn: 309549
* [TargetParser] Use enum classes for various ARM kind enums.Florian Hahn2017-07-271-143/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Using c++11 enum classes ensures that only valid enum values are used for ArchKind, ProfileKind, VersionKind and ISAKind. This removes the need for checks that the provided values map to a proper enum value, allows us to get rid of AK_LAST and prevents comparing values from different enums. It also removes a bunch of static_cast from unsigned to enum values and vice versa, at the cost of introducing static casts to access AArch64ARCHNames and ARMARCHNames by ArchKind. FPUKind and ArchExtKind are the only remaining old-style enum in TargetParser.h. I think it's beneficial to keep ArchExtKind as old-style enum, but FPUKind can be converted too, but this patch is quite big, so could do this in a follow-up patch. I could also split this patch up a bit, if people would prefer that. Reviewers: rengolin, javed.absar, chandlerc, rovka Reviewed By: rovka Subscribers: aemerson, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D35882 llvm-svn: 309287
* [YAMLTraits] Add filename support to yaml::InputAlex Bradbury2017-07-171-0/+16
| | | | | | | | | | | | | | | | | | | Summary: The current yaml::Input constructor takes a StringRef of data as its first parameter, discarding any filename information that may have been present when a YAML file was opened. Add an alterate yaml::Input constructor that takes a MemoryBufferRef, which can have a filename associated with it. This leads to clearer diagnostic messages. Sponsored By: DARPA, AFRL Reviewed By: arphaman Differential Revision: https://reviews.llvm.org/D35398 Patch by: Jonathan Anderson (trombonehero) llvm-svn: 308172
* Support: Add llvm::center_justify.Frederich Munch2017-07-131-0/+5
| | | | | | | | | | | | | | Summary: Completes the set. Reviewers: ruiu Reviewed By: ruiu Subscribers: ruiu, llvm-commits Differential Revision: https://reviews.llvm.org/D35278 llvm-svn: 307922
* [AArch64] Add an SVE target feature to the backend and TargetParser.Amara Emerson2017-07-131-2/+3
| | | | | | | The feature will be used properly once assembler/disassembler support begins to land. llvm-svn: 307917
* Allow clients to specify search order of DynamicLibraries.Frederich Munch2017-07-121-0/+10
| | | | | | | | | | | | | | Summary: Different JITs and other clients of LLVM may have different needs in how symbol resolution should occur. Reviewers: v.g.vassilev, lhames, karies Reviewed By: v.g.vassilev Subscribers: pcanal, llvm-commits Differential Revision: https://reviews.llvm.org/D33529 llvm-svn: 307849
* fix typos in comments; NFCHiroshi Inoue2017-07-111-1/+1
| | | | llvm-svn: 307626
* [Support] sys::getProcessTriple should return a macOS triple usingAlex Lorenz2017-07-071-0/+61
| | | | | | | | | | | | | | | the system's version of macOS sys::getProcessTriple returns LLVM_HOST_TRIPLE, whose system version might not be the actual version of the system on which the compiler running. This commit ensures that, for macOS, sys::getProcessTriple returns a triple with the system's macOS version. rdar://33177551 Differential Revision: https://reviews.llvm.org/D34446 llvm-svn: 307372
* MathExtras UnitTest: Assert that isPowerOf2(0) is false. NFC.Zvi Rackover2017-07-031-0/+2
| | | | | | | | | | | | | | | | | Summary: This is a follow-up on D34077. Elena observed that the correctness of the code relies on isPowerOf2(0) returning false. Adding a test to cover this corner-case. Reviewers: delena, davide, craig.topper Reviewed By: davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34939 llvm-svn: 307046
* Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTORRichard Smith2017-06-301-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | This is a short-term fix for PR33650 aimed to get the modules build bots green again. Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR macros to try to locally specialize a global template for a global type. That's not how C++ works. Instead, we now centrally define how to format vectors of fundamental types and of string (std::string and StringRef). We use flow formatting for the former cases, since that's the obvious right thing to do; in the latter case, it's less clear what the right choice is, but flow formatting is really bad for some cases (due to very long strings), so we pick block formatting. (Many of the cases that were using flow formatting for strings are improved by this change.) Other than the flow -> block formatting change for some vectors of strings, this should result in no functionality change. Differential Revision: https://reviews.llvm.org/D34907 Corresponding updates to clang, clang-tools-extra, and lld to follow. llvm-svn: 306878
* Recommit "[Support] Add RetryAfterSignal helper function"Pavel Labath2017-06-292-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | The difference from the previous version is the use of decltype, as the implementation of std::result_of in libc++ did not work correctly for variadic function like open(2). Original summary: This function retries an operation if it was interrupted by a signal (failed with EINTR). It's inspired by the TEMP_FAILURE_RETRY macro in glibc, but I've turned that into a template function. I've also added a fail-value argument, to enable the function to be used with e.g. fopen(3), which is documented to fail for any reason that open(2) can fail (which includes EINTR). The main user of this function will be lldb, but there were also a couple of uses within llvm that I could simplify using this function. Reviewers: zturner, silvas, joerg Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D33895 llvm-svn: 306671
* Make the size specification for cache_size_bytes case insensitive.Peter Collingbourne2017-06-231-1/+1
| | | | llvm-svn: 306129
* Add a ThinLTO cache policy for controlling the maximum cache size in bytes.Peter Collingbourne2017-06-231-4/+30
| | | | | | | | | | | | | | This is useful when an upper limit on the cache size needs to be controlled independently of the amount of the amount of free space. One use case is a machine with a large number of cache directories (e.g. a buildbot slave hosting a large number of independent build jobs). By imposing an upper size limit on each cache directory, users can more easily estimate the server's capacity. Differential Revision: https://reviews.llvm.org/D34547 llvm-svn: 306126
* Revert "[Support] Add RetryAfterSignal helper function" and subsequent fixPavel Labath2017-06-222-39/+0
| | | | | | | | | | | The fix in r306003 uncovered a pretty fundamental problem that libc++ implementation of std::result_of does not handle the prototype of open(2) correctly (presumably because it contains ...). This makes the whole function unusable in its current form, so I am also reverting the original commit (r305892), which introduced the function, at least until I figure out a way to solve the libc++ issue. llvm-svn: 306005
* [Support] Fix return type deduction in RetryAfterSignalPavel Labath2017-06-221-0/+5
| | | | | | | | | | | | | | | | | | The default value of the ResultT template argument (which was there only to avoid spelling out the long std::result_of template multiple times) was being overriden by function call template argument deduction. This manifested itself as a compiler error when calling the function as FILE *X = RetryAfterSignal(nullptr, fopen, ...) because the function would try to assign the result of fopen to nullptr_t, but a more insidious side effect was that RetryAfterSignal(-1, read, ...) would return "int" instead of "ssize_t", losing precision along the way. I fix this by having the function take the argument in a way that prevents argument deduction from kicking in and add a test that makes sure the return type is correct. llvm-svn: 306003
* [Support] Add RetryAfterSignal helper functionPavel Labath2017-06-212-0/+34
| | | | | | | | | | | | | | | | | | | | | Summary: This function retries an operation if it was interrupted by a signal (failed with EINTR). It's inspired by the TEMP_FAILURE_RETRY macro in glibc, but I've turned that into a template function. I've also added a fail-value argument, to enable the function to be used with e.g. fopen(3), which is documented to fail for any reason that open(2) can fail (which includes EINTR). The main user of this function will be lldb, but there were also a couple of uses within llvm that I could simplify using this function. Reviewers: zturner, silvas, joerg Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D33895 llvm-svn: 305892
OpenPOWER on IntegriCloud