Commit Graph

518 Commits

Author SHA1 Message Date
Richard Trieu
510cadb1c2 Revert r227148 & r227154 which added a test which infinitely loops.
r227148 added test CommandLineTest.HideUnrelatedOptionsMulti which repeatedly
outputs two following lines:

-tool: CommandLine Error: Option 'test-option-1' registered more than once!
-tool: CommandLine Error: Option 'test-option-2' registered more than once!

r227154 depends on changes from r227148


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227167 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-27 03:03:47 +00:00
Eric Christopher
ec89182585 Fix unsigned/signed comparison warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-27 01:01:39 +00:00
Chris Bieneman
57d5adfe15 One more fix to the new API to fix const-correctness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227154 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-27 00:42:00 +00:00
Chris Bieneman
f96362358f Pete Cooper suggested the new API should use ArrayRef instead of SmallVectorImpl. Also adding a test case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227148 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-26 22:50:47 +00:00
Reid Kleckner
91ccead42a Add a UTF8 to UTF16 conversion wrapper for use in the pdb dumper
This can also be used instead of the WindowsSupport.h ConvertUTF8ToUTF16
helpers, but that will require massaging some character types. The
Windows support routines want wchar_t output, but wchar_t is often 32
bits on non-Windows OSs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227122 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-26 19:51:00 +00:00
Zachary Turner
019c097d1b Teach raw_ostream to support hex formatting without a prefix '0x'.
Previously using format_hex() would always print a 0x prior to the
hex characters.  This allows this to be optional, so that one can
choose to print (e.g.) 255 as either 0xFF or just FF.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227108 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-26 18:21:33 +00:00
Chris Bieneman
e0c2d280a2 Putting all the standard tool options into a "Generic" category.
Summary:
This puts all the options that CommandLine.cpp implements into a category so that the APIs to hide options can not hide based on the generic category instead of string matching a partial list of argument strings.

This patch is pretty simple and straight forward but it does impact the -help output of all tools using cl::opt. Specifically the options implemented in CommandLine.cpp (help, help-list, help-hidden, help-list-hidden, print-options, print-all-options, version) are all grouped together into an Option category, and these options are never hidden by the cl::HideUnrelatedOptions API.

Reviewers: dexonsmith, chandlerc, majnemer

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227093 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-26 16:56:00 +00:00
Chris Bieneman
f04568139a Adding a new cl::HideUnrelatedOptions API to allow clang to migrate off cl::getRegisteredOptions.
Summary: cl::getRegisteredOptions really exposes some of the innards of how command line parsing is implemented. Exposing new APIs that allow us to disentangle client code from implementation details will allow us to make more extensive changes to command line parsing.

Reviewers: chandlerc, dexonsmith, beanz

Reviewed By: dexonsmith

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226729 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21 22:45:52 +00:00
Chandler Carruth
0a506e2f95 Suppress the newly added Clang warning for the inaccessible base in this
test. Do that after we suppress the warnings for unknown pragmas as this
warning flag is quite new in Clang and so old Clang's would warn all the
time on this file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226444 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 10:43:00 +00:00
Chandler Carruth
1b279144ec [cleanup] Re-sort all the #include lines in LLVM using
utils/sort_includes.py.

I clearly haven't done this in a while, so more changed than usual. This
even uncovered a missing include from the InstrProf library that I've
added. No functionality changed here, just mechanical cleanup of the
include order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225974 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 11:23:27 +00:00
Dmitri Gribenko
750f3160df ConvertUTFTest: fix misleading empty line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225580 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-10 05:03:29 +00:00
David Majnemer
3acb2035ba StringPool: Cleanup typos in unittest comments
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224226 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 01:04:49 +00:00
David Majnemer
1f59bf4441 ThreadLocal: Return a mutable pointer if templated with a non-const type
It makes more sense for ThreadLocal<const T>::get to return a const T*
and ThreadLocal<T>::get to return a T*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224225 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 01:04:45 +00:00
Rafael Espindola
7f4b22e7de Move the resize file feature from mapped_file_region to the only user.
This removes a duplicated stat on every file that llvm-ar looks at.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224138 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 18:13:23 +00:00
Rafael Espindola
e1136e38a7 Pass a FD to resise_file and add a testcase.
I will add a real use in another commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224136 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 17:55:12 +00:00
Rafael Espindola
7291e0706e Remove unused feature. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 17:35:34 +00:00
Rafael Espindola
0be06cf360 Remove a convoluted way of calling close by moving the call to the only caller.
As a bonus we can actually check the return value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224046 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 20:12:55 +00:00
Rafael Espindola
de15d01f9d Remove dead code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224029 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 17:17:26 +00:00
Rafael Espindola
3f598f77bd Remove dead code. NFC.
This interface was added 2 years ago but users never developed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223368 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 16:59:36 +00:00
Paul Robinson
2dc4746332 More long path name support on Windows, this time in program execution.
Allows long paths for the executable and redirected stdin/stdout/stderr.
Addresses PR21563.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222671 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-24 18:05:29 +00:00
Duncan P. N. Exon Smith
5deb1bf97f Support: Add *cast_or_null<> for pointer wrappers
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`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222644 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-24 03:13:02 +00:00
Rafael Espindola
ed46a2c2aa Fix a silly bug in StreamingMemoryObject.cpp.
The logic for detecting EOF was wrong and would fail if we ever requested
more than 16k past the last read position.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222505 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-21 05:15:41 +00:00
Alexey Samsonov
88dc43f69e Remove support for undocumented SpecialCaseList entries.
"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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 01:27:19 +00:00
Aaron Ballman
5f34bd9a4c Fixing some sign comparison warnings from MSVC; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221887 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 13:39:49 +00:00
Paul Robinson
4848765635 Drop a few unneeded ctor calls (missed code review comment).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221845 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:36:34 +00:00
Paul Robinson
038e20451d Improve long path name support on Windows.
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221841 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:12:14 +00:00
NAKAMURA Takumi
93f761eced [CMake] LLVMSupport: Give system_libs PRIVATE scope when LLVMSupport is 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221531 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-07 16:08:19 +00:00
Nick Kledzik
52688c3aff [Support] Add MemoryBuffer::getFileSlice()
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219260 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 00:22:18 +00:00
Nick Kledzik
e93da60ac4 [Support] Add type-safe alternative to llvm::format()
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  "



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218463 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-25 20:30:58 +00:00
Justin Bogner
0a277ea23d LineIterator: Provide a variant that keeps blank lines
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217960 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-17 15:43:01 +00:00
Nick Kledzik
290c772b6c Fix identify_magic() with mach-o stub dylibs.
The wrong value was returned and the unittest did not cover the stub dylib case.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217933 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-17 00:53:44 +00:00
Nick Kledzik
9885a59108 [Support] add decodeSLEB128()
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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217830 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 21:51:49 +00:00
Rui Ueyama
cf9142d479 Support: Use llvm::COFF::BigObjMagic
Use llvm::COFF::BigObjMagic insetad of the string literal.
Also checks the version number.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217633 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 22:34:32 +00:00
Rui Ueyama
330c819d83 Support: improve identify_magic to recognize COFF bigobj
identify_magic recognized a COFF bigobj as an import library file.
This patch fixes that.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217627 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 21:09:57 +00:00
Rafael Espindola
8d230cd536 Misc cleanups to the FileSytem api.
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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 20:30:02 +00:00
Rafael Espindola
11e375565a Use simpler version of sys::fs::exists. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217618 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 19:11:02 +00:00
Hans Wennborg
3f09227292 Try to unflake AllocatorTest.TestAlignmentPastSlab
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217331 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 05:14:29 +00:00
Hans Wennborg
4f240010fd BumpPtrAllocator: do the size check without moving any pointers
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217330 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 04:24:31 +00:00
Rafael Espindola
52fa0d066a Add writeFileWithSystemEncoding to LibLLVMSuppor.
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217068 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 20:02:00 +00:00
David Blaikie
38a4f3bbec Ensure ErrorOr cannot implicitly invoke explicit ctors of the underlying type.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217048 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 17:31:25 +00:00
Hans Wennborg
d52e9a143f BumpPtrAllocator: use uintptr_t when aligning addresses to avoid undefined 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216973 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 21:51:35 +00:00
David Blaikie
7b96c4919a unique_ptrify the result of SpecialCaseList::create
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216925 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 18:13:54 +00:00
Chris Bieneman
77bf4f97bf Cleaning up static initializers in TimeValue.
Code reviewed by Chandlerc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216703 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-29 01:05:12 +00:00
David Blaikie
819242a446 Convert a few more cases of direct intialization of unique_ptrs from MemoryBuffer::getMemBuffer to move initialization now that it returns by unique_ptr instead of raw pointer.
Cleanup/improvements following r216583.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216605 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 20:14:18 +00:00
Rafael Espindola
1a7f705fba Return a std::unique_ptr when creating a new MemoryBuffer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216583 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 20:03:13 +00:00
Rafael Espindola
34806d20dd yaml::Stream doesn't need to take ownership of the buffer.
In fact, most users were already using the StringRef version.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216575 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 19:03:22 +00:00
Craig Topper
3512034554 Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216525 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 05:25:25 +00:00
Reid Kleckner
64bb4a64e7 Fix Path unittests on Windows after raw_fd_ostream changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216422 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 00:24:23 +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
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