Commit Graph

2839 Commits

Author SHA1 Message Date
Rafael Espindola
9be4884731 Merge TempDir and system_temp_directory.
We had two functions for finding the temp or cache directory. Each had a
different set of smarts about OS specific APIs.

With this patch system_temp_directory becomes the only way to do it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216460 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 14:47:52 +00:00
Dylan Noblesmith
ae65d0e330 Revert "Support/APFloat: unique_ptr-ify temp arrays"
This reverts commit rr216359.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216429 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 02:03:33 +00:00
Dylan Noblesmith
27dc1b8446 Revert "Support/Path: remove raw delete"
This reverts commit r216360.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216428 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 02:03:30 +00:00
Rafael Espindola
c33fe1b296 Fix bug in llvm::sys::argumentsFitWithinSystemLimits().
This patch fixes a subtle bug in the UNIX implementation of
llvm::sys::argumentsFitWithinSystemLimits() regarding the misuse of a static
variable. This bug causes our cached number that stores the system command line
maximum length to be halved after each call to the function. With a sufficient
number of calls to this function, it will eventually report any given command
line string to be over system limits.

Patch by Rafael Auler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216415 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 22:53:21 +00:00
Rafael Espindola
749c73842d Refactor argument serialization logic when executing process. NFC.
This patch refactors the argument serialization logic used in the Execute
function, used to launch new Windows processes. There is a critical step that
joins char** arguments into a single string, building the command line used to
launch the new process, and the readability of this code is improved if this
part is refactored in its own helper function.

Patch by Rafael Auler!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216411 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 22:15:06 +00:00
Rafael Espindola
8c96862847 Modernize raw_fd_ostream's constructor a bit.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216393 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 18:16:47 +00:00
Dylan Noblesmith
0acfd7f0a4 Support/Path: remove raw delete
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216360 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 00:58:13 +00:00
Dylan Noblesmith
0901b15d01 Support/APFloat: unique_ptr-ify temp arrays
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216359 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 00:58:10 +00:00
Dylan Noblesmith
389f13012f Support: add llvm::unique_lock
Based on the STL class of the same name, it guards a mutex
while also allowing it to be unlocked conditionally before
destruction.

This eliminates the last naked usages of mutexes in LLVM and
clang.

It also uncovered and fixed a bug in callExternalFunction()
when compiled without USE_LIBFFI, where the mutex would never
be unlocked if the end of the function was reached.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216338 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 23:07:14 +00:00
Dylan Noblesmith
d930a30833 Support: make LLVM Mutexes STL-compatible
Use lock/unlock() convention instead of acquire/release().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216336 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 22:49:22 +00:00
Dylan Noblesmith
7e3e4311c5 Support/Unix: use ScopedLock wherever possible
Only one function remains a bit too complicated
for a simple mutex guard. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 22:49:17 +00:00
Reid Kleckner
2e1bf78ad6 Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 19:29:17 +00:00
David Blaikie
95ca0fb247 Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216223 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-21 20:44:56 +00:00
Craig Topper
e88b796285 Remove custom implementations of max/min in StringRef that was originally added to work an old gcc bug. I believe its been fixed by now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216156 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-21 04:31:10 +00:00
Alexey Samsonov
242320399f Fix undefined behavior (left shift by 64 bits) in ScaledNumber::toString().
This bug is reported by UBSan.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216116 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-20 18:30:07 +00:00
Craig Topper
78832c6e7d Fix an off by 1 bug that prevented SmallPtrSet from using all of its 'small' capacity. Then fix the early return in the move constructor that prevented 'small' moves from clearing the NumElements in the moved from object. The directed test missed this because it was always testing large moves due to the off by 1 bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216044 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-20 04:41:36 +00:00
Rafael Espindola
548f2b6e8f Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 18:44:46 +00:00
Rafael Espindola
b5a6adc30a Convert an ownership comment with std::uinque_ptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215855 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-17 22:20:33 +00:00
Sean Silva
855d60236a Revert "[Support] Promote cl::StringSaver to a separate utility"
This reverts commit r215784 / 3f8a26f6fe.

LLD has 3 StringSaver's, one of which takes a lock when saving the
string... Need to investigate more closely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 23:39:01 +00:00
Sean Silva
3f8a26f6fe [Support] Promote cl::StringSaver to a separate utility
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215784 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 23:18:33 +00:00
Rafael Espindola
1c9caced63 Delete support for AuroraUX.
auroraux.org is not resolving.

I will add this to the release notes as soon as I figure out where to put the
3.6 release notes :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215645 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-14 15:15:09 +00:00
Benjamin Kramer
00e08fcaa0 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:26:38 +00:00
Saleem Abdulrasool
f96cd1aeb5 ADT: remove MinGW32 and Cygwin OSType enum
Remove the MinGW32 and Cygwin types from the OSType enumeration.  These values
are represented via environments of Windows.  It is a source of confusion and
needlessly clutters the code.  The cost of doing this is that we must sink the
check for them into the normalization code path along with the spelling.

Addresses PR20592.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215303 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-09 23:12:20 +00:00
Eric Christopher
895fcbe7a1 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215266 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-09 00:26:27 +00:00
Rafael Espindola
cea3043216 Fix the windows build.
Sorry for the noise.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215249 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 22:09:31 +00:00
Eric Christopher
2f58085b57 Reword comment slightly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215248 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 22:09:00 +00:00
Rafael Espindola
d6039e045f Remove dead code. Fixes pr20544.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215243 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 21:35:52 +00:00
Rafael Espindola
a7c6b3a57a Convert from Windows to Unix paths in sys::path::native.
Part of pr20544. Test to follow in a second.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215241 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 21:29:34 +00:00
Rafael Espindola
82acfbfe86 Fix bug 20125 - clang-format segfaults on bad config.
The problem was in unchecked dyn_cast inside of Input::createHNodes.
Patch by Roman Kashitsyn!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215205 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 13:58:00 +00:00
Richard Smith
c00ae93432 Remove Support/IncludeFile.h and its only user. This is actively harmful, since
it breaks the modules builds (where CallGraph.h can be quite reasonably
transitively included by an unimported portion of a module, and CallGraph.cpp
not linked in), and appears to have been entirely redundant since PR780 was
fixed back in 2008.

If this breaks anything, please revert; I have only tested this with a single
configuration, and it's possible that this is still somehow fixing something
(though I doubt it, since no other similar file uses this mechanism any more).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215142 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 20:41:17 +00:00
Yaron Keren
6d48faf334 getNewMemBuffer memsets the buffer to zeros,
the caller don't have to initialize it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214994 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-06 20:59:09 +00:00
Justin Bogner
981eb59138 Path: Stop claiming path::const_iterator is bidirectional
path::const_iterator claims that it's a bidirectional iterator, but it
doesn't satisfy all of the contracts for a bidirectional iterator.
For example, n3376 24.2.5 p6 says "If a and b are both dereferenceable,
then a == b if and only if *a and *b are bound to the same object",
but this doesn't work with how we stash and recreate Components.

This means that our use of reverse_iterator on this type is invalid
and leads to many of the valgrind errors we're hitting, as explained
by Tilmann Scheller here:

    http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140728/228654.html

Instead, we admit that path::const_iterator is only an input_iterator,
and implement a second input_iterator for path::reverse_iterator (by
changing const_iterator::operator-- to reverse_iterator::operator++).
All of the uses of this just traverse once over the path in one
direction or the other anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214737 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 17:36:41 +00:00
NAKAMURA Takumi
499befab31 MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.
On Cygwin, getpagesize() returns 64k(AllocationGranularity).

In r214580, the size of X86GenInstrInfo.inc became 1499136.

FIXME: We should reorganize again getPageSize() on Win32.
MapFile allocates address along AllocationGranularity but view is mapped by physical page.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214681 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 01:43:37 +00:00
Rafael Espindola
9aa0b5e11e Remove some calls to std::move.
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get
a reference to it.

Thanks to David Blaikie for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214516 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 14:31:55 +00:00
Rafael Espindola
a5e6ff6f7e Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213963 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-25 19:06:39 +00:00
Hans Wennborg
dee5e2cf7f Windows: Don't wildcard expand /? or -?
Even if there's a file called c:\a, we want /? to be preserved as
an option, not expanded to a filename.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213894 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 21:09:45 +00:00
Tim Northover
8b6257629a AArch64: remove "arm64_be" support in favour of "aarch64_be".
There really is no arm64_be: it was a useful fiction to test big-endian support
while both backends existed in parallel, but now the only platform that uses
the name (iOS) doesn't have a big-endian variant, let alone one called
"arm64_be".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213748 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 12:58:11 +00:00
Tim Northover
9231148e69 AArch64: remove arm64 triple enumerator.
Having both Triple::arm64 and Triple::aarch64 is extremely confusing, and
invites bugs where only one is checked. In reality, the only legitimate
difference between the two (arm64 usually means iOS) is also present in the OS
part of the triple and that's what should be checked.

We still parse the "arm64" triple, just canonicalise it to Triple::aarch64, so
there aren't any LLVM-side test changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213743 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 12:32:47 +00:00
David Blaikie
ec31a302b7 Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ".reset()"
It's also possible to just write "= nullptr", but there's some question
of whether that's as readable, so I leave it up to authors to pick which
they prefer for now. If we want to discuss standardizing on one or the
other, we can do that at some point in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213438 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-19 01:05:11 +00:00
Daniel Sanders
a11bf68f6c Add MIPS Technologies to the vendors in llvm::Triple.
This is a prerequisite for checking for 'mti' and 'img' in a consistent way in
clang. Previously 'img' could use Triple::getVendor() but 'mti' could only use
Triple::getVendorName().



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213381 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-18 14:28:19 +00:00
Renato Golin
03ac7db89d Refactor ARM subarchitecture parsing
Re-commit of a patch to rework the triple parsing on ARM to a more sane
model.

Patch by Gabor Ballabas.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213367 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-18 12:00:48 +00:00
Alp Toker
3cf9f37312 Drop the udis86 wrapper from llvm::sys
This optional dependency on the udis86 library was added some time back to aid
JIT development, but doesn't make much sense to link into LLVM binaries these
days.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213300 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 20:05:29 +00:00
Hans Wennborg
c636a42d4a Typo: exists -> exits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213290 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 18:33:44 +00:00
Yi Kong
ad591b341b Fix the prefix for arm64 triple
Triple.cpp still returns "arm64" as prefix for arm64 triple, causing Clang not
being able to select the correct GCCBuiltin IR.

This patch changes the value to correct prefix "aarch64". Regression test will
be added in the coming patch.

Differential Revision: http://reviews.llvm.org/D4516


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213240 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 09:43:27 +00:00
Hans Wennborg
b464ec0536 Perform wildcard expansion in Process::GetArgumentVector on Windows (PR17098)
On Windows, wildcard expansion isn't performed by the shell, but left to the
program itself. The common way to do this is to link with setargv.obj, which
performs the expansion on argc/argv before main is entered. However, we don't
use argv in Clang on Windows, but instead call GetCommandLineW so we can handle
unicode arguments. This means we have to do wildcard expansion ourselves.

A test case will be added on the Clang side.

Differential Revision: http://reviews.llvm.org/D4529

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213114 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 00:52:11 +00:00
Alp Toker
9988c292f1 Fix a -Wunused-local-typedefs warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 22:46:45 +00:00
Justin Bogner
497ba6c273 Support: Use a range-based for
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212973 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 19:24:13 +00:00
Argyrios Kyrtzidis
41a6ddb277 Move the API and implementation of clang::driver::getARMCPUForMArch() to llvm::Triple::getARMCPUForArch().
Suggested by Eric Christopher.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212846 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 21:44:54 +00:00
Alp Toker
1736df6ae0 Simplify the raw_svector_ostream tweak from r212816
The memcpy() and overlap helps didn't help much with timings, so clean up the change.

The difference at this point is that we now leave growth of the storage buffer
up to SmallVector's implementation:

 -   OS.reserve(OS.capacity() * 2);
 +   OS.reserve(OS.size() + 64);

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212837 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 18:23:08 +00:00
Alp Toker
81bc6fb854 raw_svector_ostream: grow and reserve atomically
Including the scratch buffer size in the initial reservation eliminates the
subsequent malloc+move operation and offers a healthier constant growth with
less memory wastage.

When doing this, take care to avoid invalidating the source buffer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212816 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 14:02:04 +00:00