summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* [Support] Test directory iterators and recursive directory iterators with ↵Juergen Ributzka2017-03-131-0/+78
| | | | | | | | | | | broken symlinks. This commit adds a unit test to the file system tests to verify the behavior of the directory iterator and recursive directory iterator with broken symlinks. This test is Unix only. llvm-svn: 297669
* Bring back r297624.Rafael Espindola2017-03-131-0/+8
| | | | | | The issues was just a missing REQUIRES in the test. llvm-svn: 297661
* Revert "Fix crash when multiple raw_fd_ostreams to stdout are created."Rafael Espindola2017-03-131-8/+0
| | | | | | | This reverts commit r297624. It was failing on the bots. llvm-svn: 297657
* Fix crash when multiple raw_fd_ostreams to stdout are created.Rafael Espindola2017-03-131-0/+8
| | | | | | | | | | | | | | | | | | | | | If raw_fd_ostream is constructed with the path of "-", it claims ownership of the stdout file descriptor. This means that it closes stdout when it is destroyed. If there are multiple users of raw_fd_ostream wrapped around stdout, then a crash can occur because of operations on a closed stream. An example of this would be running something like "clang -S -o - -MD -MF - test.cpp". Alternatively, using outs() (which creates a local version of raw_fd_stream to stdout) anywhere combined with such a stream usage would cause the crash. The fix duplicates the stdout file descriptor when used within raw_fd_ostream, so that only that particular descriptor is closed when the stream is destroyed. Patch by James Henderson! llvm-svn: 297624
* Reverting r297617 because it broke some bots:Aaron Ballman2017-03-131-182/+4
| | | | | | http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/49970 llvm-svn: 297618
* Add support for getting file system permissions and implement ↵Aaron Ballman2017-03-131-4/+182
| | | | | | | | sys::fs::permissions to set them. Patch by James Henderson. llvm-svn: 297617
* [unittest] Explicitly specify alignment when using BumpPtrAllocator.Jordan Rose2017-03-112-4/+5
| | | | | | | | | | | | | r297310 began inserting red zones around allocations under ASan, which perturbs the alignment of subsequent allocations. Deliberately specify this in two places where it matters. Fixes failures when these tests are run under ASan and UBSan together. Reviewed by Duncan Exon Smith. rdar://problem/30980047 llvm-svn: 297540
* Fix test failure when Home directory cannot be found.Zachary Turner2017-03-101-9/+8
| | | | llvm-svn: 297484
* Add llvm::sys::fs::real_path.Zachary Turner2017-03-101-0/+36
| | | | | | | | | | | | | | | | | | | | | LLVM already has real_path like functionality, but it is cumbersome to use and involves clean up after (e.g. you have to call openFileForRead, then close the resulting FD). Furthermore, on Windows it doesn't work for directories since opening a directory and opening a file require slightly different flags. So I add a simple function `real_path` which works for all paths on all platforms and has a simple to use interface. In doing so, I add the ability to opt in to resolving tilde expressions (e.g. ~/foo), which are normally handled by the shell. Differential Revision: https://reviews.llvm.org/D30668 llvm-svn: 297483
* [Support] Add llvm::sys::fs::remove_directories.Zachary Turner2017-03-081-0/+33
| | | | | | | | | | | | | | | | | | | | | We already have a function create_directories() which can create an entire tree, and remove() which can remove an empty directory, but we do not have remove_directories() which can remove an entire tree. This patch adds such a function. Because removing a directory tree can have dangerous consequences when the tree contains a directory symlink, the patch here updates the existing directory_iterator construct to optionally not follow symlinks (previously it would always follow symlinks). The delete algorithm uses this flag so that for symlinks, only the links are removed, and not the targets. On Windows this is implemented with SHFileOperation, which also does not recurse into symbolic links or junctions. Differential Revision: https://reviews.llvm.org/D30676 llvm-svn: 297314
* [Support] Remove unit test for fs::is_localJonas Hahnfeld2017-03-081-55/+0
| | | | | | | | | rL295768 introduced this test that fails if LLVM is built and tested on an NFS share. Delete the test as discussed on the corresponing commit thread. The only feasible solution would have been to introduce environment variables and to en/disable the test conditionally. llvm-svn: 297260
* [AArch64] Vulcan is now ThunderXT99Joel Jones2017-03-071-3/+4
| | | | | | | | | | | | | | | | | Broadcom Vulcan is now Cavium ThunderX2T99. LLVM Bugzilla: http://bugs.llvm.org/show_bug.cgi?id=32113 Minor fixes for the alignments of loops and functions for ThunderX T81/T83/T88 (better performance). Patch was tested with SpecCPU2006. Patch by Stefan Teleman Differential Revision: https://reviews.llvm.org/D30510 llvm-svn: 297190
* [Support] Move Stream library from MSF -> Support.Zachary Turner2017-03-022-0/+711
| | | | | | | | | | After several smaller patches to get most of the core improvements finished up, this patch is a straight move and header fixup of the source. Differential Revision: https://reviews.llvm.org/D30266 llvm-svn: 296810
* Process tilde in llvm::sys::path::nativeSerge Pavlov2017-03-011-0/+27
| | | | | | | | | | | | | Windows does not treat `~` as a reference to home directory, so the call to `llvm::sys::path::native` on, say, `~/somedir` produces `~\somedir`, which has different meaning than the original path. With this change tilde is expanded on Windows to user profile directory. Such behavior keeps original meaning of the path and is consistent with the algorithm of `llvm::sys::path::home_directory`. Differential Revision: https://reviews.llvm.org/D27527 llvm-svn: 296590
* Workaround MSVC bug when using TrailingObjects from a template.James Y Knight2017-02-281-0/+21
| | | | | | | | | | | | | MSVC appears to be getting confused as to whether OverloadToken is supposed to be public or not. This was discovered by code in Swift, and has been reported to microsoft by hughbe: https://connect.microsoft.com/VisualStudio/feedback/details/3116517 Differential Revision: https://reviews.llvm.org/D29880 llvm-svn: 296497
* [Support][Error] Add a 'cantFail' utility function for known-safe calls toLang Hames2017-02-271-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fallible functions. Some fallible functions (those returning Error or Expected<T>) may only fail for a subset of their inputs. For example, a "safe" square root function will succeed for all finite positive inputs: Expected<double> safeSqrt(double d) { if (d < 0 && !isnan(d) && !isinf(d)) return make_error<...>("Cannot sqrt -ve values, nans or infs"); return sqrt(d); } At a safe callsite for such a function, checking the error return value is redundant: if (auto ValOrErr = safeSqrt(42.0)) { // use *ValOrErr. } else llvm_unreachable("safeSqrt should always succeed for +ve values"); The cantFail function wraps this check and extracts the contained value, simplifying control flow: double Result = cantFail(safeSqrt(42.0)); This function should be used with care: it is a programmatic error to wrap a call with cantFail if it can in fact fail. For debug builds this will result in llvm_unreachable being called. For release builds the behavior is undefined. Use of this function is likely to be rare in library code, but more common for tool and unit-test code where inputs and mock functions may be known to be safe. llvm-svn: 296384
* [Support] XFAIL is_local for mipsSimon Dardis2017-02-221-0/+36
| | | | | | | is_local can't pass on some our buildbots as some of our buildbots use network shares for building and testing LLVM. llvm-svn: 295840
* [Support] Add a function to check if a file resides locally.Zachary Turner2017-02-211-0/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D30010 llvm-svn: 295768
* [AArch64] Add Cavium ThunderX supportJoel Jones2017-02-171-0/+24
| | | | | | | | | | | | | | This set of patches adds support for Cavium ThunderX ARM64 processors: * ThunderX * ThunderX T81 * ThunderX T83 * ThunderX T88 Patch by Stefan Teleman Differential Revision: https://reviews.llvm.org/D28891 llvm-svn: 295475
* [Support] Add formatv support for StringLiteralPavel Labath2017-02-141-0/+2
| | | | | | | | | | | | | | | Summary: This is achieved by generalizing the expression selecting the StringRef format_provider. Now, anything that can be converted to a StringRef will use it's formatter. Reviewers: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29898 llvm-svn: 295064
* [CMake] Fix pthread handling for out-of-tree buildsEric Fiselier2017-02-101-1/+1
| | | | | | | | | | | | | | | LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects to correctly link the threading library when needed. Unfortunately `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed and therefore can't be used when configuring out-of-tree builds. This causes such builds to fail since `pthread` isn't being correctly linked. This patch attempts to fix that problem by renaming and exporting `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` because It seemed likely to cause collisions with downstream users of `LLVMConfig.cmake`. llvm-svn: 294690
* [Support] Extend SLEB128 encoding support.Dan Gohman2017-02-101-14/+33
| | | | | | | | Add support for padded SLEB128 values, and support for writing SLEB128 values to buffers rather than to ostreams, similar to the existing ULEB128 support. llvm-svn: 294675
* [ARM] Add support for armv7ve triple in llvm (PR31358).George Burgess IV2017-02-091-17/+21
| | | | | | | | | | | | | | | Gcc supports target armv7ve which is armv7-a with virtualization extensions. This change adds support for this in llvm for gcc compatibility. Also remove redundant FeatureHWDiv, FeatureHWDivARM for a few models as this is specified automatically by FeatureVirtualization. Patch by Manoj Gupta. Differential Revision: https://reviews.llvm.org/D29472 llvm-svn: 294661
* [Support] Add FormatVariadic support for chrono typesPavel Labath2017-02-071-0/+31
| | | | | | | | | | | | | | | | Summary: The formatter has three knobs: - the user can choose which time unit to use for formatting (default: whatever is the unit of the input) - he can choose whether the unit gets displayed (default: yes) - he can affect the way the number itself is formatted via standard number formatting options (default:default) Reviewers: zturner, inglorion Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29481 llvm-svn: 294326
* [Support] Simplify triple check in Host CPU test. NFC.Ahmed Bougacha2017-02-041-13/+4
| | | | | | Cleanup the check added in r293990 using the Triple helpers. llvm-svn: 294073
* [Support] Accept macosx triple as 'darwin' in Host unittest. NFC.Ahmed Bougacha2017-02-031-0/+1
| | | | | | | If LLVM was configured with an x86_64-apple-macosx host triple, this test would fail, as the API works but the triple isn't in the whitelist. llvm-svn: 293990
* [ARM] const cast fix for ARMAttributeParser testSam Parker2017-02-011-2/+3
| | | | | | | GCC 4.8 produced a cast qualifier warning, so replaced with C++ style const cast. llvm-svn: 293764
* [ARM] Enable Cortex-M23 and Cortex-M33 support.Javed Absar2017-02-011-0/+4
| | | | | | | | | | | | | Add both cores to the target parser and TableGen. Test that eabi attributes are set correctly for both cores. Additionally, test the absence and presence of MOVT in Cortex-M23 and Cortex-M33, respectively. Committed on behalf of Sanne Wouda. Reviewers : rengolin, olista01. Differential Revision: https://reviews.llvm.org/D29073 llvm-svn: 293761
* Fix fs::set_current_path unit testPavel Labath2017-01-241-1/+5
| | | | | | | | The test fails when there is a symlink on the path because then the path returned by current_path will not match the one we have set. Instead of doing a string match check the unique id of the two files. llvm-svn: 292916
* [Support] Add sys::fs::set_current_path() (aka chdir)Pavel Labath2017-01-241-0/+19
| | | | | | | | | | | | | | | Summary: This adds a cross-platform way of setting the current working directory analogous to the existing current_path() function used for retrieving it. The function will be used in lldb. Reviewers: rafael, silvas, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29035 llvm-svn: 292907
* [ARM] Create objdump subtarget from build attrsSam Parker2017-01-182-0/+385
| | | | | | | | | | | Enable an ELFObjectFile to read the its arm build attributes to produce a target triple with a specific ARM architecture. llvm-objdump now uses this functionality to automatically produce a more accurate target. Differential Revision: https://reviews.llvm.org/D28769 llvm-svn: 292366
* Recommit r292214 "[Support/Compression] - Change zlib API to return Error ↵George Rimar2017-01-171-5/+12
| | | | | | | | | | | | | | | | | | instead of custom status" No any changes, will follow up with D28807 commit containing APLi change for clang to fix build issues happened. Original commit message: [Support/Compression] - Change zlib API to return Error instead of custom status. Previously API returned custom enum values. Patch changes it to return Error with string description. That should help users to report errors in universal way. Differential revision: https://reviews.llvm.org/D28684 llvm-svn: 292226
* Revert r292214 "[Support/Compression] - Change zlib API to return Error ↵George Rimar2017-01-171-12/+5
| | | | | | | | | instead of custom status." It broked clang: http://lab.llvm.org:8080/green//job/clang-stage1-cmake-RA-incremental_build/34218/consoleFull#46141505449ba4694-19c4-4d7e-bec5-911270d8a58c llvm-svn: 292217
* [Support/Compression] - Change zlib API to return Error instead of custom ↵George Rimar2017-01-171-5/+12
| | | | | | | | | | | | status. Previously API returned custom enum values. Patch changes it to return Error with string description. That should help users to report errors in universal way. Differential revision: https://reviews.llvm.org/D28684 llvm-svn: 292214
* Remove unused lambda captures. NFCMalcolm Parsons2017-01-132-2/+3
| | | | llvm-svn: 291916
* Revert r291903 and r291898. Reason: they break check-lld on the bots.Ivan Krasin2017-01-132-385/+0
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Revert [ARM] Fix ubig32_t read in ARMAttributeParser Now using support functions to read data instead of trying to perform casts. =========================================================== Revert [ARM] Enable objdump to construct triple for ARM Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Subscribers: llvm-commits, samparker, aemerson, mgorny Differential Revision: https://reviews.llvm.org/D28683 llvm-svn: 291911
* [ARM] Enable objdump to construct triple for ARMSam Parker2017-01-132-0/+385
| | | | | | | | | | | | | Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Differential Revision: https://reviews.llvm.org/D28281 llvm-svn: 291898
* Revert r291503, "Lift the 10-type limit for AlignedCharArrayUnion", and ↵NAKAMURA Takumi2017-01-131-18/+0
| | | | | | | | | | | | | followings. r291503, "Lift the 10-type limit for AlignedCharArrayUnion" r291514, "Fix MSVC build of AlignedCharArrayUnion" r291515, "Revert the attempt to optimize the constexpr functions. MSVC does not handle this yet" r291519, "Try once again to fix the MSVC build of AlignedCharArrayUnion" They has been failing on i686-linux. llvm-svn: 291875
* Use EXPECT_EQ instead of ASSERT_EQ in a unit test.Rui Ueyama2017-01-111-10/+10
| | | | llvm-svn: 291713
* Fix memory leak in a unit test.Rui Ueyama2017-01-101-1/+1
| | | | llvm-svn: 291595
* Lift the 10-type limit for AlignedCharArrayUnionSean Callanan2017-01-091-0/+18
| | | | | | | | | | This patch uses C++11 parameter packs and constexpr functions to allow AlignedCharArrayUnion to hold an arbitrary number of types. Differential Revision: https://reviews.llvm.org/D28429 llvm-svn: 291503
* TarWriter: Fix a bug in Ustar header.Rui Ueyama2017-01-092-1/+90
| | | | | | | | | | If we split a filename into `Name` and `Prefix`, `Prefix` is at most 145 bytes. We had a bug that didn't split a path correctly. This bug was pointed out by Rafael in the post commit review. This patch adds a unit test for TarWriter to verify the fix. llvm-svn: 291494
* Support: Add YAML I/O support for custom mappings.Peter Collingbourne2017-01-041-0/+62
| | | | | | | | This will be used to YAMLify parts of the module summary. Differential Revision: https://reviews.llvm.org/D28014 llvm-svn: 290935
* Fix unit test in NDEBUG buildEugene Leviant2016-12-271-0/+2
| | | | llvm-svn: 290604
* Allow setting multiple debug typesEugene Leviant2016-12-272-0/+33
| | | | | | Differential revision: https://reviews.llvm.org/D28109 llvm-svn: 290597
* Move GlobPattern class from LLD to llvm/Support.Rui Ueyama2016-12-202-1/+72
| | | | | | | | | | GlobPattern is a class to handle glob pattern matching. Currently only LLD is using that, but technically that feature is not specific to linkers, so in this patch I move that file to LLVM. Differential Revision: https://reviews.llvm.org/D27969 llvm-svn: 290212
* Simplify format member detection in FormatVariadicPavel Labath2016-12-151-39/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This replaces the format member search, which was quite complicated, with a more direct approach to detecting whether a class should be formatted using the format-member method. Instead we use a special type llvm::format_adapter, which every adapter must inherit from. Then the search can be simply implemented with the is_base_of type trait. Aside from the simplification, I like this way more because it makes it more explicit that you are supposed to use this type only for adapter-like formattings, and the other approach (format_provider overloads) should be used as a default (a mistake I made when first trying to use this library). The only slight change in behaviour here is that now choose the format-adapter branch even if the format member invocation will fail to compile (e.g. because it is a non-const member function and we are passing a const adapter), whereas previously we would have gone on to search for format_providers for the type. However, I think that is actually a good thing, as it probably means the programmer did something wrong. Reviewers: zturner, inglorion Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27679 llvm-svn: 289795
* Add support for Samsung Exynos M3 (NFC)Evandro Menezes2016-12-131-0/+8
| | | | llvm-svn: 289613
* Fix MSCV compilation broken by r289040Pavel Labath2016-12-081-4/+4
| | | | | | | I wanted to use the "not" keyword to make sure it does not get lost in between other checks. MSVC does not like that. llvm-svn: 289041
* Improve format member detection in llvm::formatvPavel Labath2016-12-081-2/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The existing detection of a format member function has a couple of deficiencies: - the member function does not get detected if one calls formatv with an lvalue, because the template parameter gets deduced as T&, which fails the is_class check. - it also did not work if the function was called with a const variable because the template parameter would get deduced as const T&, again failing the is_class check. This fixes the problem by stripping the references in the uses_format_member template, to make sure the type is correctly detected as class. It also provides specializations of the has_FormatMember template for const and non-const members of the types in order to enable declaring the format member as a "const" function. I have added tests that verify that formatv can be now called in these scenarios. As some scenarios could not be verified at runtime (e.g. making sure that calling a non-const format member on a const object does *not* compile), I have also added some static_asserts which test the behaviour of the template classes used internally by formatv(). Reviewers: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27525 llvm-svn: 289040
OpenPOWER on IntegriCloud