summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* StringPool: Cleanup typos in unittest commentsDavid Majnemer2014-12-151-2/+2
| | | | | | No functional change intended. llvm-svn: 224226
* ThreadLocal: Return a mutable pointer if templated with a non-const typeDavid Majnemer2014-12-151-2/+21
| | | | | | | It makes more sense for ThreadLocal<const T>::get to return a const T* and ThreadLocal<T>::get to return a T*. llvm-svn: 224225
* Move the resize file feature from mapped_file_region to the only user.Rafael Espindola2014-12-121-3/+6
| | | | | | This removes a duplicated stat on every file that llvm-ar looks at. llvm-svn: 224138
* Pass a FD to resise_file and add a testcase.Rafael Espindola2014-12-121-0/+10
| | | | | | I will add a real use in another commit. llvm-svn: 224136
* Remove unused feature. NFC.Rafael Espindola2014-12-121-3/+2
| | | | llvm-svn: 224135
* Remove a convoluted way of calling close by moving the call to the only caller.Rafael Espindola2014-12-111-12/+3
| | | | | | As a bonus we can actually check the return value. llvm-svn: 224046
* Remove dead code. NFC.Rafael Espindola2014-12-111-10/+7
| | | | llvm-svn: 224029
* Remove dead code. NFC.Rafael Espindola2014-12-042-21/+1
| | | | | | This interface was added 2 years ago but users never developed. llvm-svn: 223368
* More long path name support on Windows, this time in program execution.Paul Robinson2014-11-241-0/+50
| | | | | | | Allows long paths for the executable and redirected stdin/stdout/stderr. Addresses PR21563. llvm-svn: 222671
* Support: Add *cast_or_null<> for pointer wrappersDuncan P. N. Exon Smith2014-11-241-0/+96
| | | | | | | | | | | | | | | | | | | | Fill in omission of `cast_or_null<>` and `dyn_cast_or_null<>` for types that wrap pointers (e.g., smart pointers). Type traits need to be slightly stricter than for `cast<>` and `dyn_cast<>` to resolve ambiguities with simple types. There didn't seem to be any unit tests for pointer wrappers, so I tested `isa<>`, `cast<>`, and `dyn_cast<>` while I was in there. This only supports pointer wrappers with a conversion to `bool` to check for null. If in the future it's useful to support wrappers without such a conversion, it should be a straightforward incremental step to use the `simplify_type` machinery for the null check. In that case, the unit tests should be updated to remove the `operator bool()` from the `pointer_wrappers::PTy`. llvm-svn: 222644
* Fix a silly bug in StreamingMemoryObject.cpp.Rafael Espindola2014-11-212-0/+31
| | | | | | | The logic for detecting EOF was wrong and would fail if we ever requested more than 16k past the last read position. llvm-svn: 222505
* Remove support for undocumented SpecialCaseList entries.Alexey Samsonov2014-11-201-19/+1
| | | | | | | | | | | | | "global-init", "global-init-src" and "global-init-type" were originally used to blacklist entities in ASan init-order checker. However, they were never documented, and later were replaced by "=init" category. Old blacklist entries should be converted as follows: * global-init:foo -> global:foo=init * global-init-src:bar -> src:bar=init * global-init-type:baz -> type:baz=init llvm-svn: 222401
* Fixing some sign comparison warnings from MSVC; NFC.Aaron Ballman2014-11-131-3/+3
| | | | llvm-svn: 221887
* Drop a few unneeded ctor calls (missed code review comment).Paul Robinson2014-11-131-4/+4
| | | | llvm-svn: 221845
* Improve long path name support on Windows.Paul Robinson2014-11-131-2/+59
| | | | | | | | | | Windows normally limits the length of an absolute path name to 260 characters; directories can have lower limits. These limits increase to about 32K if you use absolute paths with the special '\\?\' prefix. Teach Support\Windows\Path.inc to use that prefix as needed. TODO: Other parts of Support could also learn to use this prefix. llvm-svn: 221841
* [CMake] LLVMSupport: Give system_libs PRIVATE scope when LLVMSupport is ↵NAKAMURA Takumi2014-11-071-0/+5
| | | | | | | | built as SHARED. Users of LLVMSupport won't inherit ${system_libs}. unittests/SupporTests is another user of libpthreads. Apply LLVM_SYSTEM_LIBS for him explicitly. llvm-svn: 221531
* [Support] Add MemoryBuffer::getFileSlice()Nick Kledzik2014-10-081-0/+50
| | | | | | | | | | mach-o supports "fat" files which are a header/table-of-contents followed by a concatenation of mach-o files built for different architectures. Currently, MemoryBuffer has no easy way to map a subrange (slice) of a file which lld will need to select a mach-o slice of a fat file. The new function provides an easy way to map a slice of a file into a MemoryBuffer. Test case included. llvm-svn: 219260
* [Support] Add type-safe alternative to llvm::format()Nick Kledzik2014-09-251-0/+37
| | | | | | | | | | | | | | | | | | | | | llvm::format() is somewhat unsafe. The compiler does not check that integer parameter size matches the %x or %d size and it does not complain when a StringRef is passed for a %s. And correctly using a StringRef with format() is ugly because you have to convert it to a std::string then call c_str(). The cases where llvm::format() is useful is controlling how numbers and strings are printed, especially when you want fixed width output. This patch adds some new formatting functions to raw_streams to format numbers and StringRefs in a type safe manner. Some examples: OS << format_hex(255, 6) => "0x00ff" OS << format_hex(255, 4) => "0xff" OS << format_decimal(0, 5) => " 0" OS << format_decimal(255, 5) => " 255" OS << right_justify(Str, 5) => " foo" OS << left_justify(Str, 5) => "foo " llvm-svn: 218463
* LineIterator: Provide a variant that keeps blank linesJustin Bogner2014-09-171-9/+87
| | | | | | | | It isn't always useful to skip blank lines, as evidenced by the somewhat awkward use of line_iterator in llvm-cov. This adds a knob to control whether or not to skip blanks. llvm-svn: 217960
* Fix identify_magic() with mach-o stub dylibs.Nick Kledzik2014-09-171-0/+3
| | | | | | The wrong value was returned and the unittest did not cover the stub dylib case. llvm-svn: 217933
* [Support] add decodeSLEB128()Nick Kledzik2014-09-151-0/+36
| | | | | | | | We already have routines to encode SLEB128 as well as encode/decode ULEB128. This last function fills out the matrix. I'll need this for some llvm-objdump work I am doing. llvm-svn: 217830
* Support: Use llvm::COFF::BigObjMagicRui Ueyama2014-09-111-1/+1
| | | | | | | Use llvm::COFF::BigObjMagic insetad of the string literal. Also checks the version number. llvm-svn: 217633
* Support: improve identify_magic to recognize COFF bigobjRui Ueyama2014-09-111-0/+3
| | | | | | | identify_magic recognized a COFF bigobj as an import library file. This patch fixes that. llvm-svn: 217627
* Misc cleanups to the FileSytem api.Rafael Espindola2014-09-112-8/+7
| | | | | | | | | | | | | | | | The main difference is the removal of std::error_code exists(const Twine &path, bool &result); It was an horribly redundant interface since a file not existing is also a valid error_code. Now we have an access function that returns just an error_code. This is the only function that has to be implemented for Unix and Windows. The functions can_write, exists and can_execute an now just wrappers. One still has to be very careful using these function to avoid introducing race conditions (Time of check to time of use). llvm-svn: 217625
* Use simpler version of sys::fs::exists. NFC.Rafael Espindola2014-09-111-3/+2
| | | | llvm-svn: 217618
* Try to unflake AllocatorTest.TestAlignmentPastSlabHans Wennborg2014-09-071-3/+4
| | | | llvm-svn: 217331
* BumpPtrAllocator: do the size check without moving any pointersHans Wennborg2014-09-071-0/+12
| | | | | | | | | | | | | Instead of aligning and moving the CurPtr forward, and then comparing with End, simply calculate how much space is needed, and compare that to how much is available. Hopefully this avoids any doubts about comparing addresses possibly derived from past the end of the slab array, overflowing, etc. Also add a test where aligning CurPtr would move it past End. llvm-svn: 217330
* Add writeFileWithSystemEncoding to LibLLVMSuppor.Rafael Espindola2014-09-031-0/+50
| | | | | | | | | | | | | | | | | | | | This patch adds to LLVMSupport the capability of writing files with international characters encoded in the current system encoding. This is relevant for Windows, where we can either use UTF16 or the current code page (the legacy Windows international characters). On UNIX, the file is always saved in UTF8. This will be used in a patch for clang to thoroughly support response files creation when calling other tools, addressing PR15171. On Windows, to correctly support internationalization, we need the ability to write response files both in UTF16 or the current code page, depending on the tool we will call. GCC for mingw, for instance, requires files to be encoded in the current code page. MSVC tools requires files to be encoded in UTF16. Patch by Rafael Auler! llvm-svn: 217068
* Ensure ErrorOr cannot implicitly invoke explicit ctors of the underlying type.David Blaikie2014-09-031-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | An unpleasant surprise while migrating unique_ptrs (see changes in lib/Object): ErrorOr<int*> was implicitly convertible to ErrorOr<std::unique_ptr<int>>. Keep the explicit conversions otherwise it's a pain to convert ErrorOr<int*> to ErrorOr<std::unique_ptr<int>>. I'm not sure if there should be more SFINAE on those explicit ctors (I could check if !is_convertible && is_constructible, but since the ctor has to be called explicitly I don't think there's any need to disable them when !is_constructible - they'll just fail anyway. It's the converting ctors that can create interesting ambiguities without proper SFINAE). I had to SFINAE the explicit ones because otherwise they'd be ambiguous with the implicit ones in an explicit context, so far as I could tell. The converting assignment operators seemed unnecessary (and similarly buggy/dangerous) - just rely on the converting ctors to convert to the right type for assignment instead. llvm-svn: 217048
* BumpPtrAllocator: use uintptr_t when aligning addresses to avoid undefined ↵Hans Wennborg2014-09-021-1/+1
| | | | | | | | | behaviour In theory, alignPtr() could push a pointer beyond the end of the current slab, making comparisons with that pointer undefined behaviour. Use an integer type to avoid this. llvm-svn: 216973
* unique_ptrify the result of SpecialCaseList::createDavid Blaikie2014-09-021-17/+18
| | | | llvm-svn: 216925
* Cleaning up static initializers in TimeValue.Chris Bieneman2014-08-291-6/+6
| | | | | | Code reviewed by Chandlerc llvm-svn: 216703
* Convert a few more cases of direct intialization of unique_ptrs from ↵David Blaikie2014-08-272-10/+10
| | | | | | | | MemoryBuffer::getMemBuffer to move initialization now that it returns by unique_ptr instead of raw pointer. Cleanup/improvements following r216583. llvm-svn: 216605
* Return a std::unique_ptr when creating a new MemoryBuffer.Rafael Espindola2014-08-273-11/+11
| | | | llvm-svn: 216583
* yaml::Stream doesn't need to take ownership of the buffer.Rafael Espindola2014-08-271-1/+1
| | | | | | In fact, most users were already using the StringRef version. llvm-svn: 216575
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-272-16/+16
| | | | | | just letting them be implicitly created. llvm-svn: 216525
* Fix Path unittests on Windows after raw_fd_ostream changesReid Kleckner2014-08-261-7/+7
| | | | llvm-svn: 216422
* Modernize raw_fd_ostream's constructor a bit.Rafael Espindola2014-08-251-6/+6
| | | | | | | | | | Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
* Fix PR17239 by changing the semantics of the RemainingArgsClass Option kindReid Kleckner2014-08-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | This patch contains the LLVM side of the fix of PR17239. This bug that happens because the /link (clang-cl.exe argument) is marked as "consume all remaining arguments". However, when inside a response file, /link should only consume all remaining arguments inside the response file where it is located, not the entire command line after expansion. My patch will change the semantics of the RemainingArgsClass kind to always consume only until the end of the response file when the option originally came from a response file. There are only two options in this class: dash dash (--) and /link. Reviewed By: rnk Differential Revision: http://reviews.llvm.org/D4899 Patch by Rafael Auler! llvm-svn: 216280
* [Support] Fix the overflow bug in ULEB128 decoding.Alex Lorenz2014-08-221-0/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D5029 llvm-svn: 216268
* Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using ↵David Blaikie2014-08-211-2/+3
| | | | | | std::unique_ptr llvm-svn: 216223
* BumpPtrAllocator: don't accept 0 for the alignment parameterHans Wennborg2014-08-191-14/+14
| | | | | | | | It seems unnecessary to have to use an extra branch to check for this special case. http://reviews.llvm.org/D4945 llvm-svn: 216036
* Convert an ownership comment with std::uinque_ptr.Rafael Espindola2014-08-171-2/+3
| | | | llvm-svn: 215855
* BumpPtrAllocator: remove 'no slabs allocated yet' checkHans Wennborg2014-08-171-1/+1
| | | | | | | | | | We already handle the no-slabs case when checking whether the current slab is large enough: if no slabs have been allocated, CurPtr and End are both 0. alignPtr(0), will still be 0, and so "if (Ptr + Size <= End)" fails. Differential Revision: http://reviews.llvm.org/D4943 llvm-svn: 215841
* Revert "[Support] Promote cl::StringSaver to a separate utility"Sean Silva2014-08-151-2/+9
| | | | | | | | | This reverts commit r215784 / 3f8a26f6fe16cc76c98ab21db2c600bd7defbbaa. LLD has 3 StringSaver's, one of which takes a lock when saving the string... Need to investigate more closely. llvm-svn: 215790
* [Support] Promote cl::StringSaver to a separate utilitySean Silva2014-08-151-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class is generally useful. In breaking it out, the primary change is that it has been made non-virtual. It seems like being abstract led to there being 3 different (2 in llvm + 1 in clang) concrete implementations which disagreed about the ownership of the saved strings (see the manual call to free() in the unittest StrDupSaver; yes this is different from the CommandLine.cpp StrDupSaver which owns the stored strings; which is different from Clang's StringSetSaver which just holds a reference to a std::set<std::string> which owns the strings). I've identified 2 other places in the codebase that are open-coding this pattern: memcpy(Alloc.Allocate<char>(strlen(S)+1), S, strlen(S)+1) I'll be switching them over. They are * llvm::sys::Process::GetArgumentVector * The StringAllocator member of YAMLIO's Input class This also will allow simplifying Clang's driver.cpp quite a bit. Let me know if there are any other places that could benefit from StringSaver. I'm also thinking of adding a saveStringRef member for getting a stable StringRef. llvm-svn: 215784
* Test commit, remove trailing whitespaceBenjamin Foster2014-08-131-1/+1
| | | | llvm-svn: 215556
* Asserting that the call to chdir succeeds in this test. Fixes some ↵Aaron Ballman2014-08-131-2/+2
| | | | | | -Wunused-result warnings. llvm-svn: 215539
* Fix expected windows result.Rafael Espindola2014-08-091-1/+1
| | | | llvm-svn: 215267
* Remove dead code. Fixes pr20544.Rafael Espindola2014-08-081-6/+6
| | | | llvm-svn: 215243
OpenPOWER on IntegriCloud