summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
Commit message (Collapse)AuthorAgeFilesLines
* Make home_directory look in the password database in addition to $HOME.Zachary Turner2017-03-221-5/+11
| | | | | | | | | | | | | This is something of an edge case, but when the $HOME environment variable is not set, we can still look in the password database to get the current user's home directory. Added a test for this by getting the value of $HOME, then unsetting it, then calling home_directory() and verifying that it succeeds and that the value is the same as what we originally read from the environment. llvm-svn: 298513
* [Support] Fill the file_status struct with link count.Zachary Turner2017-03-202-5/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D31110 llvm-svn: 298326
* Add a function to MD5 a file's contents.Zachary Turner2017-03-202-7/+42
| | | | | | | | | | | | | | | In doing so, clean up the MD5 interface a little. Most existing users only care about the lower 8 bytes of an MD5, but for some users that care about the upper and lower, there wasn't a good interface. Furthermore, consumers of the MD5 checksum were required to handle endianness details on their own, so it seems reasonable to abstract this into a nicer interface that just gives you the right value. Differential Revision: https://reviews.llvm.org/D31105 llvm-svn: 298322
* Support, LTO: When pruning a directory, ignore files matching a prefix.Peter Collingbourne2017-03-201-2/+5
| | | | | | | | | | This is a safeguard against data loss if the user specifies a directory that is not a cache directory. Teach the existing cache pruning clients to create files with appropriate names. Differential Revision: https://reviews.llvm.org/D31109 llvm-svn: 298271
* Use MutableArrayRef for APFloat::convertToIntegerSimon Pilgrim2017-03-201-29/+34
| | | | | | As discussed on D31074, use MutableArrayRef for destination integer buffers to help assert before stack overflows happen. llvm-svn: 298253
* Strip trailing whitespaceSimon Pilgrim2017-03-201-5/+5
| | | | llvm-svn: 298247
* [APInt] Don't initialize VAL to 0 in APInt constructors. Push it down to the ↵Craig Topper2017-03-201-2/+5
| | | | | | | | | | initSlowCase and other init methods. I'm not sure if zeroing VAL before writing pVal is really necessary, but at least one other place did it in code. But by taking the store out of line, this reduces the opt binary by about 20k on my local x86-64 build. llvm-svn: 298233
* [LockFileManager] Reduce lock timeoutBruno Cardoso Lopes2017-03-181-3/+3
| | | | | | | | | | Go back to behavior pre-r231309 and reduce the timeout from 8 to ~1.5 min now that we have (a) PCMCache mechanism (r298165) and (b) timeout that doesn't cause a failure, but actually build the module (r298175). rdar://problem/30297862 llvm-svn: 298176
* Fix linux build.Zachary Turner2017-03-161-1/+2
| | | | llvm-svn: 298007
* [Support] Support both Windows and Posix paths on both platforms.Zachary Turner2017-03-162-224/+203
| | | | | | | | | | | | | | | | | | Previously which path syntax we supported dependend on what platform we were compiling LLVM on. While this is normally desirable, there are situations where we need to be able to handle a path that we know was generated on a remote host. Remote debugging, for example, or parsing debug info. 99% of the code in LLVM for handling paths was platform agnostic and literally just a few branches were gated behind pre-processor checks, so this changes those sites to use runtime checks instead, and adds a flag to every path API that allows one to override the host native syntax. Differential Revision: https://reviews.llvm.org/D30858 llvm-svn: 298004
* [Support] Add support for getting file system permissions on Windows and ↵James Henderson2017-03-163-8/+58
| | | | | | | | | | | | | | | | | | implement sys::fs::set/getPermissions to work with them This change adds support for functions to set and get file permissions, in a similar manner to the C++17 permissions() function in <filesystem>. The setter uses chmod on Unix systems and SetFileAttributes on Windows, setting the permissions as passed in. The getter simply uses the existing status() function. Prior to this change, status() would always return an unknown value for the permissions on a Windows file, making it impossible to test the new function on Windows. I have therefore added support for this as well. On Linux, prior to this change, the permissions included the file type, which should actually be accessed via a different member of the file_status class. Note that on Windows, only the *_write permission bits have any affect - if any are set, the file is writable, and if not, the file is read-only. This is in common with what MSDN describes for their behaviour of std::filesystem::permissions(), and also what boost::filesystem does. The motivation behind this change is so that we can easily test behaviour on read-only files in LLVM unit tests, but I am sure that others may find it useful in some situations. Reviewers: zturner, amccarth, aaron.ballman Differential Revision: https://reviews.llvm.org/D30736 llvm-svn: 297945
* Fix pessimising moves.Peter Collingbourne2017-03-161-2/+2
| | | | llvm-svn: 297928
* Support: Add a cache pruning policy parser.Peter Collingbourne2017-03-161-0/+68
| | | | | | | | | The idea is that the policy string fully specifies the policy and is portable between clients. Differential Revision: https://reviews.llvm.org/D31020 llvm-svn: 297927
* Support: Simplify the CachePruning API. NFCI.Peter Collingbourne2017-03-151-8/+14
| | | | | | | | | Change the function that implements the pruning into a free function that takes the policy as a struct argument. Differential Revision: https://reviews.llvm.org/D31009 llvm-svn: 297907
* [pdb] Write the module info and symbol record streams.Zachary Turner2017-03-151-0/+9
| | | | | | | | | | | Previously we did not have support for writing detailed module information for each module, as well as the symbol records. This patch adds support for this, and in doing so enables the ability to construct minimal PDBs from just a few lines of YAML. A test is added to illustrate this functionality. llvm-svn: 297900
* [YAML] When outputting, provide the ability to write default values.Zachary Turner2017-03-151-12/+5
| | | | | | | | | Previously, if you attempted to write a key/value pair and the value was equal to the key's default value, we would not output the value. Sometimes it is useful to be able to see this value in the output anyway. llvm-svn: 297864
* [Support][CommandLine] Make it possible to get error messages from ↵Eric Liu2017-03-151-27/+24
| | | | | | | | | | | | | | | | | | | ParseCommandLineOptions when ignoring errors. Summary: Previously, ParseCommandLineOptions returns false and ignores error messages when IgnoreErrors. It would be useful to also return error messages if users decide to check parsing result instead of having the program exit on error. Reviewers: chandlerc, mehdi_amini, rnk Reviewed By: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30893 llvm-svn: 297810
* Make FileOutputBuffer fail early if you pass a directory.Rui Ueyama2017-03-131-0/+2
| | | | | | | | | | Previously, it created a temporary directory and then failed when FileOutputBuffer tried to rename that file to the destination file (which is actually a directory name). Differential Revision: https://reviews.llvm.org/D30912 llvm-svn: 297679
* Bring back r297624.Rafael Espindola2017-03-131-1/+1
| | | | | | 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-1/+1
| | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | 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-133-81/+31
| | | | | | 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-133-31/+81
| | | | | | | | sys::fs::permissions to set them. Patch by James Henderson. llvm-svn: 297617
* [Support] Don't return an error if realPath fails.Zachary Turner2017-03-101-3/+2
| | | | | | | | | | | In openFileForRead, we would not previously return an error if real_path resolution failed. After a recent patch, we started propagating this error up. This caused a failure in clang when trying to call openFileForRead("nul"). This patch restores the previous behavior of not propagating this error up. llvm-svn: 297488
* Add llvm::sys::fs::real_path.Zachary Turner2017-03-102-16/+161
| | | | | | | | | | | | | | | | | | | | | 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
* [APInt] Add APInt::insertBits() method to insert an APInt into a larger APIntSimon Pilgrim2017-03-101-0/+59
| | | | | | | | | | | | We currently have to insert bits via a temporary variable of the same size as the target with various shift/mask stages, resulting in further temporary variables, all of which require the allocation of memory for large APInts (MaskSizeInBits > 64). This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::insertBits() helper method which avoids the temporary memory allocation and masks/inserts the raw bits directly into the target. Differential Revision: https://reviews.llvm.org/D30780 llvm-svn: 297458
* Fixed typos in comments. NFCI.Simon Pilgrim2017-03-091-6/+6
| | | | llvm-svn: 297379
* fix build on CygwinNuno Lopes2017-03-091-0/+3
| | | | llvm-svn: 297378
* [Support] Add llvm::sys::fs::remove_directories.Zachary Turner2017-03-083-5/+75
| | | | | | | | | | | | | | | | | | | | | 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
* Resubmit FileSystem changes.Zachary Turner2017-03-081-0/+12
| | | | | | | | | | This was originall reverted due to some test failures in ModuleCache and TestCompDirSymlink. These issues have all been resolved and the code now passes all tests. Differential Revision: https://reviews.llvm.org/D30698 llvm-svn: 297300
* Recommit: [globalisel] Change LLT constructor string into an LLT-based ↵Daniel Sanders2017-03-072-0/+48
| | | | | | | | | | | | | | | | | | | | object that knows how to generate it. Summary: This will allow future patches to inspect the details of the LLT. The implementation is now split between the Support and CodeGen libraries to allow TableGen to use this class without introducing layering concerns. Thanks to Ahmed Bougacha for finding a reasonable way to avoid the layering issue and providing the version of this patch without that problem. The problem with the previous commit appears to have been that TableGen was including CodeGen/LowLevelType.h instead of Support/LowLevelTypeImpl.h. Reviewers: t.p.northover, qcolombet, rovka, aditya_nandakumar, ab, javed.absar Subscribers: arsenm, nhaehnle, mgorny, dberris, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D30046 llvm-svn: 297241
* Fix C2712 build error on WindowsKonstantin Zhuravlyov2017-03-071-6/+12
| | | | | | | | Move the __try/__except block outside of the set_thread_name function to avoid a conflict with object unwinding due to the use of the llvm::Storage. Differential Revision: https://reviews.llvm.org/D30707 llvm-svn: 297192
* Revert r297177: Change LLT constructor string into an LLT-based object ...Daniel Sanders2017-03-072-48/+0
| | | | | | | | | | More module problems. This time it only showed up in the stage 2 compile of clang-x86_64-linux-selfhost-modules-2 but not the stage 1 compile. Somehow, this change causes the build to need Attributes.gen before it's been generated. llvm-svn: 297188
* [globalisel] Change LLT constructor string into an LLT-based object that ↵Daniel Sanders2017-03-072-0/+48
| | | | | | | | | | | | | | | | | | knows how to generate it. Summary: This will allow future patches to inspect the details of the LLT. The implementation is now split between the Support and CodeGen libraries to allow TableGen to use this class without introducing layering concerns. Thanks to Ahmed Bougacha for finding a reasonable way to avoid the layering issue and providing the version of this patch without that problem. Reviewers: t.p.northover, qcolombet, rovka, aditya_nandakumar, ab, javed.absar Subscribers: arsenm, nhaehnle, mgorny, dberris, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D30046 llvm-svn: 297177
* [fs] Make sure to check S_ISLNK() in fillStatus.Zachary Turner2017-03-071-0/+2
| | | | llvm-svn: 297167
* [Support] Add the option to not follow symlinks on stat.Zachary Turner2017-03-073-21/+12
| | | | llvm-svn: 297154
* [APInt] Add rvalue reference support to and, or, xor operations to allow ↵Craig Topper2017-03-071-25/+0
| | | | | | | | | | | | | | | | their memory allocation to be reused when possible This extends an earlier change that did similar for add and sub operations. With this first patch we lose the fastpath for the single word case as operator&= and friends don't support it. This can be added there if we think that's important. I had to change some functions in the APInt class since the operator overloads were moved out of the class and can't be used inside the class now. The getBitsSet change collides with another outstanding patch to implement it with setBits. But I didn't want to make this patch dependent on that series. I've also removed the Or, And, Xor functions which were rarely or never used. I already commited two changes to remove the only uses of Or that existed. Differential Revision: https://reviews.llvm.org/D30612 llvm-svn: 297121
* Use LLVM for all stat-related functionality.Zachary Turner2017-03-071-0/+7
| | | | | | | | | | This deletes LLDB's FileType enumeration and replaces all users, and all calls to functions that check whether a file exists etc with corresponding calls to LLVM. Differential Revision: https://reviews.llvm.org/D30624 llvm-svn: 297116
* [APInt] Add setLowBits/setHighBits methods to APInt.Craig Topper2017-03-071-29/+23
| | | | | | | | | | | | | | | | | | | | | Summary: There are quite a few places in the code base that do something like the following to set the high or low bits in an APInt. KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - 1); For BitWidths larger than 64 this creates a short lived APInt with malloced storage. I think it might even call malloc twice. Its better to just provide methods that can set the necessary bits without the temporary APInt. I'll update usages that benefit in a separate patch. Reviewers: majnemer, MatzeB, davide, RKSimon, hans Reviewed By: hans Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30525 llvm-svn: 297111
* Try to fix thread name truncation on non-Windows.Zachary Turner2017-03-043-7/+16
| | | | llvm-svn: 296976
* Improve the Threading code on NetBSDKamil Rytarowski2017-03-041-5/+2
| | | | | | | | Do not include <sys/user.h> on NetBSD. It's dead file and will be removed. No need to include <sys/sysctl.h> in this code context on NetBSD. llvm-svn: 296973
* Truncate thread names if they're too long.Zachary Turner2017-03-042-3/+29
| | | | llvm-svn: 296972
* DebugCounter: Initialize skip to 0, not -1Daniel Berlin2017-03-041-2/+2
| | | | llvm-svn: 296971
* Silence a warning, NFCKrzysztof Parzyszek2017-03-031-0/+1
| | | | llvm-svn: 296917
* Detect the existence of pthread_{s,g}etname_np in libpthread on LinuxKrzysztof Parzyszek2017-03-031-0/+4
| | | | | | Older Linux distributions may not have those functions. llvm-svn: 296915
* Fix Threading path when LLVM_ENABLE_THREADS=0.Zachary Turner2017-03-031-1/+1
| | | | llvm-svn: 296914
* Add missing #includes for FreeBSD.Zachary Turner2017-03-031-4/+9
| | | | llvm-svn: 296902
* Try again to appease the FreeBSD bot.Zachary Turner2017-03-031-7/+2
| | | | | | | The actual logic was wrong, not just the type conversion. This should get it correct. llvm-svn: 296899
* Try to appease the FreeBSD bots.Zachary Turner2017-03-031-2/+2
| | | | | | | | pthread_self() returns a pthread_t, but we were setting it to an int. It seems the cast to int when calling sysctl is still the correct thing to do, though. llvm-svn: 296892
* Don't bring in llvm/Support/thread.h in Threading.cppZachary Turner2017-03-031-2/+8
| | | | | | | | | | | | Doing so defines the type llvm::thread. On FreeBSD, we need to call a macro which references its own ::thread type, which causes an ambiguity due to ADL when inside of the llvm namespace. Since we don't even need this unless LLVM_ENABLE_THREADS == 1, we don't even need this type anyway, as it is always equal to std::thread, so we can just use that directly. llvm-svn: 296891
OpenPOWER on IntegriCloud