summaryrefslogtreecommitdiff
path: root/unittests
Commit message (Collapse)AuthorAge
* Introduce line editor library.Peter Collingbourne2014-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | This library will be used by clang-query. I can imagine LLDB becoming another client of this library, so I think LLVM is a sensible place for it to live. It wraps libedit, and adds tab completion support. The code is loosely based on the line editor bits in LLDB, with a few improvements: - Polymorphism for retrieving the list of tab completions, based on the concept pattern from the new pass manager. - Tab completion doesn't corrupt terminal output if the input covers multiple lines. Unfortunately this can only be done in a truly horrible way, as far as I can tell. But since the alternative is to implement our own line editor (which I don't think LLVM should be in the business of doing, at least for now) I think it may be acceptable. - Includes a fallback for the case where the user doesn't have libedit installed. Note that this uses C stdio, mainly because libedit also uses C stdio. Differential Revision: http://llvm-reviews.chandlerc.com/D2200 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200595 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce llvm::sys::path::home_directory.Peter Collingbourne2014-01-31
| | | | | | | | | This will be used by the line editor library to derive a default path to the history file. Differential Revision: http://llvm-reviews.chandlerc.com/D2199 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200594 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up whitespaceDuncan P. N. Exon Smith2014-01-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200579 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for DW_FORM_flag and DW_FORM_flag_present to the DIE hashingEric Christopher2014-01-31
| | | | | | | | algorithm. Sink the 'A' + Attribute hash into each form so we don't have to check valid forms before deciding whether or not we're going to hash which will let the default be to return without doing anything. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200571 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix name of nested type in comment to match code.Eric Christopher2014-01-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200570 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove C++11ism from r200407.Jordan Rose2014-01-29
| | | | | | Oops! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200412 91177308-0d34-0410-b5e6-96231b3b80d8
* [CommandLine] Aliases require an value if their target requires a value.Jordan Rose2014-01-29
| | | | | | | | | This can still be overridden by explicitly setting a value requirement on the alias option, but by default it should be the same. PR18649 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200407 91177308-0d34-0410-b5e6-96231b3b80d8
* Add BumpPtrAllocator::allocateCopy() utilitiesNick Kledzik2014-01-28
| | | | | | | Makes it easy to use BumpPtrAllocator to make a copy of StringRef strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200331 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll back the ConstStringRef change for nowAlp Toker2014-01-27
| | | | | | | | | | | There are a couple of interesting things here that we want to check over (particularly the expecting asserts in StringRef) and get right for general use in ADT so hold back on this one. For clang we have a workable templated solution to use in the meanwhile. This reverts commit r200187. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200194 91177308-0d34-0410-b5e6-96231b3b80d8
* StringRef: Extend constexpr capabilities and introduce ConstStringRefAlp Toker2014-01-27
| | | | | | | | | | | | | | | | | | | (1) Add llvm_expect(), an asserting macro that can be evaluated as a constexpr expression as well as a runtime assert or compiler hint in release builds. This technique can be used to construct functions that are both unevaluated and compiled depending on usage. (2) Update StringRef using llvm_expect() to preserve runtime assertions while extending the same checks to static asserts in C++11 builds that support the feature. (3) Introduce ConstStringRef, a strong subclass of StringRef that references compile-time constant strings. It's convertible to, but not from, ordinary StringRef and thus can be used to add compile-time safety to various interfaces in LLVM and clang that only accept fixed inputs such as diagnostic format strings that tend to get misused. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200187 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix known typosAlp Toker2014-01-24
| | | | | | | Sweep the codebase for common typos. Includes some changes to visible function names that were misspelt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200018 91177308-0d34-0410-b5e6-96231b3b80d8
* Bug 18228 - Fix accepting bitcasts between vectors of pointers with aMatt Arsenault2014-01-22
| | | | | | | | | | | | | different number of elements. Bitcasts were passing with vectors of pointers with different number of elements since the number of elements was checking SrcTy->getVectorNumElements() == SrcTy->getVectorNumElements() which isn't helpful. The addrspacecast was also wrong, but that case at least is caught by the verifier. Refactor bitcast and addrspacecast handling in castIsValid to be more readable and fix this problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199821 91177308-0d34-0410-b5e6-96231b3b80d8
* [APInt] Fix nearestLogBase2 to return correct answers for very large APInt ↵Michael Gottesman2014-01-19
| | | | | | | | and APInt with a bitwidth of 1. I also improved the comments, added some more tests, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199610 91177308-0d34-0410-b5e6-96231b3b80d8
* [APInt] Fixed bug where APInt(UINT32_MAX, 0) would blow up when being ↵Michael Gottesman2014-01-19
| | | | | | | | | | | | | | constructed. This was due to arithmetic overflow in the getNumBits() computation. Now we cast BitWidth to a uint64_t so that does not occur during the computation. After the computation is complete, the uint64_t is truncated when the function returns. I know that this is not something that is likely to happen, but it *IS* a valid input and we should not blow up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199609 91177308-0d34-0410-b5e6-96231b3b80d8
* [PM] Make the verifier work independently of any pass manager.Chandler Carruth2014-01-19
| | | | | | | | | | | | | | | | | | | | | | | This makes the 'verifyFunction' and 'verifyModule' functions totally independent operations on the LLVM IR. It also cleans up their API a bit by lifting the abort behavior into their clients and just using an optional raw_ostream parameter to control printing. The implementation of the verifier is now just an InstVisitor with no multiple inheritance. It also is significantly more const-correct, and hides the const violations internally. The two layers that force us to break const correctness are building a DomTree and dispatching through the InstVisitor. A new VerifierPass is used to implement the legacy pass manager interface in terms of the other pieces. The error messages produced may be slightly different now, and we may have slightly different short circuiting behavior with different usage models of the verifier, but generally everything works equivalently and this unblocks wiring the verifier up to the new pass manager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199569 91177308-0d34-0410-b5e6-96231b3b80d8
* Use LLVM_EXPLICIT instead of a function pointer as bool.Rafael Espindola2014-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199437 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r194218 with fix:Bill Wendling2014-01-16
| | | | | | | | | | | | Move copying of global initializers below the cloning of functions. The BlockAddress doesn't have access to the correct basic blocks until the functions have been cloned. This causes the BlockAddress to point to the old values. Just wait until the functions have been cloned before copying the initializers. PR13163 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199354 91177308-0d34-0410-b5e6-96231b3b80d8
* Update getLazyBitcodeModule to use ErrorOr for error handling.Rafael Espindola2014-01-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199125 91177308-0d34-0410-b5e6-96231b3b80d8
* [PM] Split DominatorTree into a concrete analysis result object whichChandler Carruth2014-01-13
| | | | | | | | | | | | | | | | | | | | | | | can be used by both the new pass manager and the old. This removes it from any of the virtual mess of the pass interfaces and lets it derive cleanly from the DominatorTreeBase<> template. In turn, tons of boilerplate interface can be nuked and it turns into a very straightforward extension of the base DominatorTree interface. The old analysis pass is now a simple wrapper. The names and style of this split should match the split between CallGraph and CallGraphWrapperPass. All of the users of DominatorTree have been updated to match using many of the same tricks as with CallGraph. The goal is that the common type remains the resulting DominatorTree rather than the pass. This will make subsequent work toward the new pass manager significantly easier. Also in numerous places things became cleaner because I switched from re-running the pass (!!! mid way through some other passes run!!!) to directly recomputing the domtree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199104 91177308-0d34-0410-b5e6-96231b3b80d8
* [cleanup] Move the Dominators.h and Verifier.h headers into the IRChandler Carruth2014-01-13
| | | | | | | | | | | | | | | | | | directory. These passes are already defined in the IR library, and it doesn't make any sense to have the headers in Analysis. Long term, I think there is going to be a much better way to divide these matters. The dominators code should be fully separated into the abstract graph algorithm and have that put in Support where it becomes obvious that evn Clang's CFGBlock's can use it. Then the verifier can manually construct dominance information from the Support-driven interface while the Analysis library can provide a pass which both caches, reconstructs, and supports a nice update API. But those are very long term, and so I don't want to leave the really confusing structure until that day arrives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199082 91177308-0d34-0410-b5e6-96231b3b80d8
* [PM] Rename the IR printing pass header to a more generic and correctChandler Carruth2014-01-12
| | | | | | | | name to match the source file which I got earlier. Update the include sites. Also modernize the comments in the header to use the more recommended doxygen style. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199041 91177308-0d34-0410-b5e6-96231b3b80d8
* [PM] Add names to passes under the new pass manager, and a debug outputChandler Carruth2014-01-11
| | | | | | | | | | mode that can be used to debug the execution of everything. No support for analyses here, that will come later. This already helps show parts of the opt commandline integration that isn't working. Tests of that will start using it as the bugs are fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199004 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove remove_all. A compiler has no need for recursively deleting a directory.Rafael Espindola2014-01-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198955 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a unit test for the copy constructor.Rafael Espindola2014-01-09
| | | | | | | | I would not normally add tests like these, but the copy constructor is not used at all in our codebase with c++11, so having this tests might prevent breaking the c++03 build again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198886 91177308-0d34-0410-b5e6-96231b3b80d8
* Use getError and remove the error_code operator.Rafael Espindola2014-01-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198799 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the LLVM IR asm writer header files into the IR directory, as theyChandler Carruth2014-01-07
| | | | | | | | | | | | | | | | | are part of the core IR library in order to support dumping and other basic functionality. Rename the 'Assembly' include directory to 'AsmParser' to match the library name and the only functionality left their -- printing has been in the core IR library for quite some time. Update all of the #includes to match. All of this started because I wanted to have the layering in good shape before I started adding support for printing LLVM IR using the new pass infrastructure, and commandline support for the new pass infrastructure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198688 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth2014-01-07
| | | | | | | | | | subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198685 91177308-0d34-0410-b5e6-96231b3b80d8
* Add in a unittest for the one-use pattern matcher.Chandler Carruth2014-01-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198552 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support to the pattern match library for matching NSW and NUWChandler Carruth2014-01-05
| | | | | | | | | | | instructions. I needed this for a quick experiment I was making, and while I've no idea if that will ever get committed, I didn't want to throw away the pattern match code and for anyone else to have to write it again. I've added unittests to make sure this works correctly. In fun news, this also uncovered the IRBuilder bug. Doh! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198541 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in IRBuilder that's been there for who knows how long. ItChandler Carruth2014-01-05
| | | | | | | | failed to correctly propagate the NUW and NSW flags to the constant folder for two instructions. I've added a unittest to cover flag propagation for the rest of the instructions and constant expressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198538 91177308-0d34-0410-b5e6-96231b3b80d8
* Use a shorter name for the IRBuilder member. This will help the testsChandler Carruth2014-01-05
| | | | | | I'm adding next be a lot more readable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198534 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify the PatternMatch unittest by giving it a module, function, andChandler Carruth2014-01-05
| | | | | | | | | basic block to hold instructions, and managing all of their lifetimes in a fixture. This makes it easy to sink the expectations into the test cases themselves which also makes things a bit more explicit and clearer IMO. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198532 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix break introduced in r198377 due to using a local type as a template ↵David Blaikie2014-01-03
| | | | | | parameter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198379 91177308-0d34-0410-b5e6-96231b3b80d8
* Test coverage for non-default-constructible elements in a StringMapDavid Blaikie2014-01-02
| | | | | | | | | This functionality was enabled by r198374. Here's a test to ensure it works and we don't regress it. Based on a patch by Maciej Piechotka. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198377 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove StringMapEntryInitializer support.David Blaikie2014-01-02
| | | | | | | It was never specialized so let's just remove that unused configurability and always do the default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198374 91177308-0d34-0410-b5e6-96231b3b80d8
* Make llvm::Regex non-copyable but movable.David Blaikie2014-01-02
| | | | | | Based on a patch by Maciej Piechotka. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198334 91177308-0d34-0410-b5e6-96231b3b80d8
* Use LLVM_STATIC_ASSERT rather than a hand-rolled implementation.David Blaikie2014-01-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198330 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename 'assert' to something less loaded in CompileAssertHasTypeAlp Toker2014-01-01
| | | | | | Suggested by Aaron Ballman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198288 91177308-0d34-0410-b5e6-96231b3b80d8
* Silence g++ 4.9 build issue in unit testsAlp Toker2014-01-01
| | | | | | Stopgap measure until we can just use static_assert(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198273 91177308-0d34-0410-b5e6-96231b3b80d8
* Port r198087 and r198089 (strip dead code by default) from make to cmake.Nico Weber2013-12-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198198 91177308-0d34-0410-b5e6-96231b3b80d8
* Attempt to fix JIT unit tests after r198087.Nico Weber2013-12-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198089 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a simple line-by-line iterator type into the Support library.Chandler Carruth2013-12-27
| | | | | | | | | | | | | | | | | | | This is an iterator which you can build around a MemoryBuffer. It will iterate through the non-empty, non-comment lines of the buffer as a forward iterator. It should be small and reasonably fast (although it could be made much faster if anyone cares, I don't really...). This will be used to more simply support the text-based sample profile file format, and is largely based on the original patch by Diego. I've re-worked the style of it and separated it from the work of producing a MemoryBuffer from a file which both simplifies the interface and makes it easier to test. The style of the API follows the C++ standard naming conventions to fit in better with iterators in general, much like the Path and FileSystem interfaces follow standard-based naming conventions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198068 91177308-0d34-0410-b5e6-96231b3b80d8
* unittests/Support/ProcessTest.cpp: Don't use "windows.h". Use <windows.h> ↵NAKAMURA Takumi2013-12-25
| | | | | | instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198011 91177308-0d34-0410-b5e6-96231b3b80d8
* Makefile.unittest: cleanup may fail. Add '-' in the action.NAKAMURA Takumi2013-12-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197777 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sys::ThreadLocal<> zero-initialized on non-thread builds (PR18205)Hans Wennborg2013-12-19
| | | | | | | | | | | | | According to the docs, ThreadLocal<>::get() should return NULL if no object has been set. This patch makes that the case also for non-thread builds and adds a very basic unit test to check it. (This was causing PR18205 because PrettyStackTraceHead didn't get zero- initialized and we'd crash trying to read past the end of that list. We didn't notice this so much on Linux since we'd crash after printing all the entries, but on Mac we print into a SmallString, and would crash before printing that.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197718 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce clean-ups in llvm/unittests/Makefile.unittest, to sweep stray *Tests.NAKAMURA Takumi2013-12-19
| | | | | | | | | Stray *Tests might stay after reverting. FIXME: Could we apply this feature to clang/unittests? FIXME: Implement this feature to CMake. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197661 91177308-0d34-0410-b5e6-96231b3b80d8
* No point in having a "#if 0"ed unittest.Rafael Espindola2013-12-19
| | | | | | | It is also not clear what the value of the test was. The API is used from existing tools and can (and is) tested with lit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197654 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a buffer overrun detected by AddressSanitizer.Anna Zaks2013-12-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197647 91177308-0d34-0410-b5e6-96231b3b80d8
* ArchiveFileDescriptorTests: Fix CMake build. Each unit test is expected to ↵NAKAMURA Takumi2013-12-19
| | | | | | have suffix "*Tests" for lit gtest runner to seek one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197636 91177308-0d34-0410-b5e6-96231b3b80d8
* ArchiveFileDescriptorTests: Resurrect part of r197600, but make it ↵NAKAMURA Takumi2013-12-19
| | | | | | | | invalidated, to appease buildbots. Please revert this several hours later ;) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197635 91177308-0d34-0410-b5e6-96231b3b80d8