summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* [Support] Add a free toString function for ErrorVedant Kumar2016-05-031-0/+19
| | | | | | | | | | toString() consumes an Error and returns a string representation of its contents. This commit also adds a message() method to ErrorInfoBase for convenience. Differential Revision: http://reviews.llvm.org/D19883 llvm-svn: 268465
* Use gcc's rules for parsing gcc-style response filesNico Weber2016-04-261-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | In gcc, \ escapes every character in response files. It is true that this makes it harder to mention Windows files in rsp files, but not doing this means clang disagrees with gcc, and also disagrees with the shell (on non-Windows) which rsp file quoting is supposed to match. clang isn't free to choose what to do here. In general, the idea for response files is to take bits of your command line and write them to a file unchanged, and have things work the same way. Since the command line would've been interpreted by the shell, things in the rsp file need to be subject to the same shell quoting rules. People who want to put Windows-style paths in their response files either need to do any of: * escape their backslashes * or use clang-cl which uses cl.exe/cmd.exe quoting rules * pass --rsp-quoting=windows to clang to tell it to use cl.exe/cmd.exe quoting rules for response files. Fixes PR27464. http://reviews.llvm.org/D19417 llvm-svn: 267556
* [Support] Fix latent bugs in Expected and ExitOnError that were preventing themLang Hames2016-04-251-0/+14
| | | | | | from working with reference types. llvm-svn: 267448
* Unbreak building unit tests on Windows after r266595.Nico Weber2016-04-181-0/+1
| | | | llvm-svn: 266614
* [NFC] Header cleanupMehdi Amini2016-04-184-3/+1
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining ↵Duncan P. N. Exon Smith2016-04-055-29/+15
| | | | | | | | | | 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/ llvm-svn: 265459
* Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; ↵Eugene Zelenko2016-04-055-15/+29
| | | | | | | | | | | | other minor fixes. Some Include What You Use suggestions were used too. Use anonymous namespaces in source files. Differential revision: http://reviews.llvm.org/D18778 llvm-svn: 265454
* [Support] Add a checked flag to Expected<T>, require checks before access orLang Hames2016-04-051-4/+46
| | | | | | | | | | destruction. This makes the Expected<T> class behave like Error, even when in success mode. Expected<T> values must be checked to see whether they contain an error prior to being dereferenced, assigned to, or destructed. llvm-svn: 265446
* [Support] Fix an invalid character escaping in string literal (unittest).Etienne Bergeron2016-04-051-1/+1
| | | | | | | | | | | | | | | | | | Summary: A character within a string literal is not escaped correctly. In this case, there is no semantic change because the invalid character turn out to be NUL anyway. note: "\0x12" is equivalent to {0, 'x', '1', '2'} and not { 12 }. This issue was found by clang-tidy. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18747 llvm-svn: 265376
* Add support for computing SHA1 in LLVMMehdi Amini2016-04-012-0/+73
| | | | | | | | | | | | | | | | Provide a class to generate a SHA1 from a sequence of bytes, and a convenience raw_ostream adaptor. This will be used to provide a "build-id" by hashing the Module block when writing bitcode. ThinLTO will use this information for incremental build. Reapply r265094 which was reverted in r265102 because it broke MSVC bots (constexpr is not supported). http://reviews.llvm.org/D16325 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265107
* Revert "Add support for computing SHA1 in LLVM"Mehdi Amini2016-04-012-73/+0
| | | | | | | | This reverts commit r265096, r265095, and r265094. Windows build is broken, and the validation does not pass. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265102
* Add support for computing SHA1 in LLVMMehdi Amini2016-04-012-0/+73
| | | | | | | | | | | Provide a class to generate a SHA1 from a sequence of bytes, and a convenience raw_ostream adaptor. This will be used to provide a "build-id" by hashing the Module block when writing bitcode. ThinLTO will use this information for incremental build. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265094
* Support: Implement StreamingMemoryObject::getPointerDuncan P. N. Exon Smith2016-03-271-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation is fairly obvious. This is preparation for using some blobs in bitcode. For clarity (and perhaps future-proofing?), I moved the call to JumpToBit in BitstreamCursor::readRecord ahead of calling MemoryObject::getPointer, since JumpToBit can theoretically (a) read bytes, which (b) invalidates the blob pointer. This isn't strictly necessary the two memory objects we have: - The return of RawMemoryObject::getPointer is valid until the memory object is destroyed. - StreamingMemoryObject::getPointer is valid until the next chunk is read from the stream. Since the JumpToBit call is only going ahead to a word boundary, we'll never load another chunk. However, reordering makes it clear by inspection that the blob returned by BitstreamCursor::readRecord will be valid. I added some tests for StreamingMemoryObject::getPointer and BitstreamCursor::readRecord. llvm-svn: 264549
* Support: Move StreamingMemoryObject{,Test}.cpp, NFCDuncan P. N. Exon Smith2016-03-272-10/+13
| | | | | | | | Change the filename to indicate this is a test, rename the tests, move them into an anonymous namespace, and rename some variables. All to match our usual style before making further changes. llvm-svn: 264548
* [Support] Switch to RAII helper for error-as-out-parameter idiom.Lang Hames2016-03-251-4/+24
| | | | | | As discussed on the llvm-commits thread for r264467. llvm-svn: 264479
* [Support] Add Error::errorForOutParameter helper.Lang Hames2016-03-251-0/+6
| | | | | | | | This helper method creates a pre-checked Error suitable for use as an out parameter in a constructor. This avoids the need to have the constructor check a known-good error before assigning to it. llvm-svn: 264467
* Try to fix ODR violation of ErrorInfo::IDReid Kleckner2016-03-241-3/+10
| | | | | | This implements my suggestion to Lang. llvm-svn: 264360
* ErrorTest.cpp: Move instantiations out of anonymous namespace. gcc didn't ↵NAKAMURA Takumi2016-03-241-4/+3
| | | | | | complain. llvm-svn: 264297
* Define ErrorInfo::ID explicitly.NAKAMURA Takumi2016-03-241-0/+4
| | | | llvm-svn: 264293
* ErrorTest.cpp: Fix an expression, possibly typo.NAKAMURA Takumi2016-03-241-1/+1
| | | | llvm-svn: 264290
* [Support] Add conversions between Expected<T> and ErrorOr<T>.Lang Hames2016-03-241-1/+24
| | | | | | More utilities to help with std::error_code -> Error transitions. llvm-svn: 264238
* [Support] Make all Errors convertible to std::error_code.Lang Hames2016-03-231-0/+9
| | | | | | | | | | | | This is a temporary crutch to enable code that currently uses std::error_code to be incrementally moved over to Error. Requiring all Error instances be convertible enables clients to call errorToErrorCode on any error (not just ECErrors created by conversion *from* an error_code). This patch also moves code for Error from ErrorHandling.cpp into a new Error.cpp file. llvm-svn: 264221
* [Support] Refactor Error unit tests to avoid duplicating work.Lang Hames2016-03-181-294/+229
| | | | | | Suggested by Dave Blaikie in review for r263749. Thanks Dave! llvm-svn: 263768
* [Support] Add ExitOnError utility to support tools that use the exit-on-errorLang Hames2016-03-171-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | idiom. Most LLVM tool code exits immediately when an error is encountered and prints an error message to stderr. The ExitOnError class supports this by providing two call operators - one for Errors, and one for Expected<T>s. Calls to code that can return Errors (or Expected<T>s) can use these calls to bail out on error, and otherwise continue as if the operation had succeeded. E.g. Error foo(); Expected<int> bar(); int main(int argc, char *argv[]) { ExitOnError ExitOnErr; ExitOnErr.setBanner(std::string("Error in ") + argv[0] + ":"); // Exit if foo returns an error. No need to manually check error return. ExitOnErr(foo()); // Exit if bar returns an error, otherwise unwrap the contained int and // continue. int X = ExitOnErr(bar()); // ... return 0; } llvm-svn: 263749
* [Support] Make Error::isA<T>() works on success values.Lang Hames2016-03-171-0/+3
| | | | llvm-svn: 263745
* [Support] Update Error unit test to remove implementation specific behaviour.Lang Hames2016-03-161-2/+1
| | | | llvm-svn: 263610
* [Support] Add the 'Error' class for structured error handling.Lang Hames2016-03-162-0/+459
| | | | | | | | | | | | | | | | | This patch introduces the Error classs for lightweight, structured, recoverable error handling. It includes utilities for creating, manipulating and handling errors. The scheme is similar to exceptions, in that errors are described with user-defined types. Unlike exceptions however, errors are represented as ordinary return types in the API (similar to the way std::error_code is used). For usage notes see the LLVM programmer's manual, and the Error.h header. Usage examples can be found in unittests/Support/ErrorTest.cpp. Many thanks to David Blaikie, Mehdi Amini, Kevin Enderby and others on the llvm-dev and llvm-commits lists for lots of discussion and review. llvm-svn: 263609
* MathExtrasTest.cpp: Use EXPECT_DOUBLE_EQ here, instead of EXPECT_FLOAT_EQ.NAKAMURA Takumi2016-03-141-1/+1
| | | | llvm-svn: 263508
* More UTF string conversion wrappersMarianne Mailhot-Sarrasin2016-03-111-1/+36
| | | | | | | | | | | Added new string conversion wrappers that convert between `std::string` (of UTF-8 bytes) and `std::wstring`, which is particularly useful for Win32 interop. Also fixed a missing string conversion for `getenv` on Win32, using these new wrappers. The motivation behind this is to provide the support functions required for LLDB to work properly on Windows with non-ASCII data; however, the functions are not LLDB specific. Patch by cameron314 Differential Revision: http://reviews.llvm.org/D17549 llvm-svn: 263247
* unitests: add some ARM TargetParser testsSaleem Abdulrasool2016-03-062-0/+52
| | | | | | | | | The ARM TargetParser would construct invalid StringRefs. This would cause asserts to trigger. Add some tests in LLVM to ensure that we dont regress on this in the future. Although there is a test for this in clang, this ensures that the changes would get caught in the same repository. llvm-svn: 262790
* Refactor duplicated code for linking with pthread.Rafael Espindola2016-03-011-3/+1
| | | | llvm-svn: 262344
* [Support] Add a fancy helper function to get a static name for a type.Chandler Carruth2016-02-252-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | This extracts the type name from __PRETTY_FUNCTION__ for compilers that support it (I've opted Clang, GCC, and ICC into this as I've tested that they work) and from __FUNCSIG__ which is very similar on MSVC. The routine falls back gracefully on a stub "UNKNOWN_TYPE" string with compilers or formats it doesn't understand. This should be enough for a lot of common cases in LLVM where the real goal is just to log or print a type name as a debugging aid, and save a ton of boilerplate in the process. Notably, I'm planning to use this to remove all the getName() boiler plate from the new pass manager. The design and implementation is based on a bunch of advice and discussion with Richard Smith and experimenting with most versions of Clang and GCC. David Majnemer also provided excellent advice on how best to do this with MSVC. Richard also checked that ICC does something reasonable and I'll watch the build bots for other compilers. It'd be great if someone could contribute logic for xlC and/or other toolchains. Differential Revision: http://reviews.llvm.org/D17565 llvm-svn: 261819
* Fix a -Wsign-compare in Support Path unittestsReid Kleckner2016-02-101-1/+1
| | | | llvm-svn: 260418
* Silence some MSVC warnings about zero extending unsigned to void*Reid Kleckner2016-02-101-4/+4
| | | | llvm-svn: 260413
* Use std::forward to make ErrorOr<T> constructible from a value that has a ↵Nick Lewycky2016-02-091-1/+41
| | | | | | user-defined conversion to T. No functionality change intended. llvm-svn: 260196
* Remove TrailingObjects::operator delete. It's still suffering fromRichard Smith2016-02-091-2/+2
| | | | | | | | | compiler-specific issues. Instead, repeat an 'operator delete' definition in each derived class that is actually deleted, and give up on the static type safety of an error when sized delete is accidentally used on a type derived from TrailingObjects. llvm-svn: 260190
* Re-commit r259942 (reverted in r260053) with a different workaround for the ↵Richard Smith2016-02-091-0/+2
| | | | | | | | | | | | | | | MSVC bug. This fixes undefined behavior in C++14 due to the size of the object being deleted being different from sizeof(dynamic type) when it is allocated with trailing objects. MSVC seems to have several bugs around using-declarations changing the access of a member inherited from a base class, so use forwarding functions instead of using-declarations to make TrailingObjects::operator delete accessible where desired. llvm-svn: 260180
* Revert 259942, r259943, r259948.Nico Weber2016-02-071-2/+0
| | | | | | | | | | | | | | | | The Windows bots have been failing for the last two days, with: FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe -c LLVMContextImpl.cpp D:\buildslave\clang-x64-ninja-win7\llvm\lib\IR\LLVMContextImpl.cpp(137) : error C2248: 'llvm::TrailingObjects<llvm::AttributeSetImpl, llvm::IndexAttrPair>::operator delete' : cannot access private member declared in class 'llvm::AttributeSetImpl' TrailingObjects.h(298) : see declaration of 'llvm::TrailingObjects<llvm::AttributeSetImpl, llvm::IndexAttrPair>::operator delete' AttributeImpl.h(213) : see declaration of 'llvm::AttributeSetImpl' llvm-svn: 260053
* More workarounds for undefined behavior exposed when compiling in C++14 withRichard Smith2016-02-051-0/+2
| | | | | | | | -fsized-deallocation. Disable sized deallocation for all objects derived from TrailingObjects, as we expect the storage allocated for these objects to be larger than the size of their dynamic type. llvm-svn: 259942
* [unittests] Move TargetRegistry test from Support to MCReid Kleckner2016-02-032-44/+0
| | | | | | | This removes the dependency from SupportTests to all of the LLVM backends, and makes it link faster. llvm-svn: 259705
* Silence -Wsign-conversion issue in ProgramTest.cppReid Kleckner2016-02-031-3/+3
| | | | | | | | Unfortunately, ProgramInfo::ProcessId is signed on Unix and unsigned on Windows, breaking the standard fix of using '0U' in the gtest expectation. llvm-svn: 259704
* Fixed compilation issue.Elena Demikhovsky2016-01-281-1/+1
| | | | llvm-svn: 259087
* Fix identify_magic() to check that a file that starts with MH_MAGIC isKevin Enderby2016-01-261-11/+19
| | | | | | | | | | | | at least as big as the mach header to be identified as a Mach-O file and make sure smaller files are not identified as a Mach-O files but as unknown files. Also fix identify_magic() so it looks at all 4 bytes of the filetype field when determining the type of the Mach-O file. Then fix the macho-invalid-header test case to check that it is an unknown file and make sure it does not get the error for object_error::parse_failed. And also update the unit tests. llvm-svn: 258883
* Remove autoconf supportChris Bieneman2016-01-261-15/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; ↵Eugene Zelenko2016-01-261-4/+4
| | | | | | | | other minor fixes. Differential revision: reviews.llvm.org/D16568 llvm-svn: 258831
* Add a test showing we can write a vector of floats.Rafael Espindola2016-01-251-0/+21
| | | | llvm-svn: 258701
* Add ArrayRef support to EndianStream.Rafael Espindola2016-01-221-0/+30
| | | | | | | | | | Using an array instead of ArrayRef would allow type inference, but (short of using C99) one would still need to write typedef uint16_t VT[]; LE.write(VT{0x1234, 0x5678}); llvm-svn: 258535
* Update to use new name alignTo().Rui Ueyama2016-01-142-15/+14
| | | | llvm-svn: 257804
* [Support] Add saturating multiply-add support functionNathan Slingerland2016-01-121-0/+54
| | | | | | | | | | | | Summary: Add SaturatingMultiplyAdd convenience function template since A + (X * Y) comes up frequently when doing weighted arithmetic. Reviewers: davidxl, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15385 llvm-svn: 257532
* Add != to YAMLParser's basic_collection_iterator.Jordan Rose2016-01-061-0/+72
| | | | | | | | | ...and mark it as merely an input_iterator rather than a forward_iterator, since it is destructive. And then rewrite == to take advantage of that. Patch by Alex Denisov! llvm-svn: 256913
OpenPOWER on IntegriCloud