Commit Graph

48 Commits

Author SHA1 Message Date
Benjamin Kramer
896353d663 [Option] Plug a leak when move-assigning an InputArgList.
The class has a non-trivial dtor so we have to clean up before we move
in new members. Remove misleading comment as a default move assignment
operator will never be synthesized for this class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240417 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-23 15:28:10 +00:00
Alexander Kornienko
cd52a7a381 Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)
Apparently, the style needs to be agreed upon first.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240390 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-23 09:49:53 +00:00
Logan Chien
3755f9f48c Code cleanup: Remove std::move() around xvalue (NFC)
Remove std::move() around xvalue so that copy elision is eligible.
In case that copy elision is not appliable, the c++ standard also
guarantees the move semantics on xvalue.  Thus, it is not necessary
to wrap Args with std::move.

This also silence a warning since r240345.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240355 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 23:16:02 +00:00
David Blaikie
0c17f95006 Modify ParseArgs to return the InputArgList by value - there's no need for dynamic allocation/ownership here
The one caller that does anything other than keep this variable on the
stack is the single use of DerivedArgList in Clang, which is a bit more
interesting but can probably be cleaned up/simplified a bit further
(have DerivedArgList take ownership of the InputArgList rather than
needing to reference its Args indirectly) which I'll try to after this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 22:06:37 +00:00
David Blaikie
caca524562 Devirtualize ArgList's dtor now that -Wvirtual-dtor and C++11 allow a better way to describe this situation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240238 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-21 06:51:35 +00:00
David Blaikie
006bce7764 ArrayRef-ify ParseArgs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240233 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-21 06:31:53 +00:00
Alexander Kornienko
cf0db29df2 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
  -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
  llvm/lib/


Thanks to Eugene Kosov for the original patch!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240137 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19 15:57:42 +00:00
Hans Wennborg
375079a549 Option parsing: properly handle flag aliases for joined options (PR23394)
A joined option always needs to have an argument, even if it's an empty one.

Clang would previously assert when trying to use --extra-warnings, which is
a flag alias for -W, which is a joined option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236434 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-04 18:00:13 +00:00
Yaron Keren
6e92e7b09a Remove more superfluous .str() and replace std::string concatenation with Twine.
Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 15:42:36 +00:00
Filipe Cabecinhas
e3f2e6fcfe Make getLastArgNoClaim work for up to 4 arguments.
Summary:
This is needed for http://reviews.llvm.org/D8507
I have no idea what stand-alone tests could be done, if needed.

Reviewers: Bigcheese, craig.topper, samsonov

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232859 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 23:32:58 +00:00
Yaron Keren
0401f798d1 Teach Twine to support SmallString.
Enable removing .str() member calls for these frequent cases. 

 http://reviews.llvm.org/D6372



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232465 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 09:51:17 +00:00
David Blaikie
7610ba7d24 Fix uses of reserved identifiers starting with an underscore followed by an uppercase letter
This covers essentially all of llvm's headers and libs. One or two weird
cases I wasn't sure were worth/appropriate to fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232394 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 18:06:57 +00:00
David Blaikie
394b3ac916 Remove explicit no-op dtor in favor of the implicit dtor so as not to disable/deprecate the copy operations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231113 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-03 19:53:02 +00:00
Benjamin Kramer
1a50a12b43 Prefer SmallVector::append/insert over push_back loops.
Same functionality, but hoists the vector growth out of the loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229500 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17 15:29:18 +00:00
Zachary Turner
c371307e60 Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects.
This allows IDEs to recognize the entire set of header files for
each of the core LLVM projects.

Differential Revision: http://reviews.llvm.org/D7526
Reviewed By: Chris Bieneman

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 03:28:02 +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
Ehsan Akhgari
97688c4ee3 Add an overload of getLastArgNoClaim taking two OptSpecifiers.
Summary: This will be used in clang.

Test Plan: Will be tested on the clang side.

Reviewers: hansw

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217702 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-12 19:42:53 +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
Nick Kledzik
4a8a0f2132 [Option] Support MultiArg in --help
Currently, if you use a MultiArg<> option, then printing out the help/usage
message will cause an assert.  This fixes getOptionHelpName() to work with
MultiArg Options.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215770 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 21:35:07 +00:00
Tim Northover
7fba8d794f Generic: add range-adapter for option parsing.
I want to use it in lld, but while I'm here I'll update LLVM uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212615 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-09 13:03:37 +00:00
Alp Toker
8dd8d5c2b2 Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 22:52:05 +00:00
Alp Toker
2559070422 Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 00:00:48 +00:00
Justin Bogner
14d8c9e550 ArgList: use MakeArgList overloads in subclasses and clean up some calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211340 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 04:36:29 +00:00
Benjamin Kramer
aad181f644 Options: Use erase_if to remove Args from the list.
While there make getOption return a const reference so we don't have to put it
on the stack when calling methods on it. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209088 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-18 15:14:13 +00:00
David Blaikie
1df9ce8da5 Protect the ArgList dtor
It could even be made non-virtual if it weren't for bad compiler
warnings.

This demonstrates that ArgList objects aren't destroyed polymorphically
and possibly that they aren't even used polymorphically. If that's the
case, it might be possible to refactor the two ArgList types more
separately and simplify the Arg ownership model. *continues
experimenting*

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206727 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-20 23:59:00 +00:00
David Blaikie
7117d739d6 Use unique_ptr to handle ownership of synthesized args in DerivedArgList
This might be able to be simplified further by using Arg as a value type
in a linked list (to maintain pointer validity), but here's something
simple to start with.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206724 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-20 22:37:46 +00:00
Craig Topper
0b6cb7104b [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206252 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15 06:32:26 +00:00
David Blaikie
445cfd70b9 Avoid buffer copies when a Twine already is a StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196301 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03 18:18:28 +00:00
Jakub Staszak
42f2a6b41e Use startswith_lower() where possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194007 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-04 19:22:50 +00:00
Eli Friedman
add560eee4 Fix another mistake in r190442.
Sorry about that; I'll try to be more careful about DEBUG mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190449 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 23:22:56 +00:00
Eli Friedman
63a9660a41 Remove unused functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190442 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 22:42:31 +00:00
Rui Ueyama
2957273b88 Option parsing: support case-insensitive option matching.
Re-submitting r189416 with fix for Windows build on where strcasecmp is not defined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189501 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-28 20:04:31 +00:00
Rui Ueyama
1997734e37 Revert "Option parsing: support case-insensitive option matching." as it broke Windows buildbot.
This reverts r189416.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-28 00:02:06 +00:00
Rui Ueyama
055f4e99ff Option parsing: support case-insensitive option matching.
Link.exe's command line options are case-insensitive. This patch
adds a new attribute to OptTable to let the option parser to compare
options, ignoring case.

Command lines are generally case-insensitive on Windows. CL.exe is an
exception. So this new attribute should be useful for other commands
running on Windows.

Differential Revision: http://llvm-reviews.chandlerc.com/D1485

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189416 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-27 23:47:01 +00:00
Hans Wennborg
b06ccefc91 Options: explicit handling of --
Clients of the option parsing library should handle it explicitly
using a KIND_REMAINING_ARGS option.

Clang and lld have been updated in r188316 and r188318, respectively.

Also fix -Wsign-compare warning in the option parsing test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188323 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13 22:23:05 +00:00
Hans Wennborg
af9e355755 Options: Add new option kind that consumes remaining arguments
This adds KIND_REMAINING_ARGS, a class of options that consume
all remaining arguments on the command line.

This will be used to support /link in clang-cl, which is used
to forward all remaining arguments to the linker.

It also allows us to remove the hard-coded handling of "--",
allowing clients (clang and lld) to implement that functionality
themselves with this new option class.

Differential Revision: http://llvm-reviews.chandlerc.com/D1387

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188314 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13 21:09:50 +00:00
NAKAMURA Takumi
27770f46aa Option/CMakeLists.txt: Don't use target_link_libraries. LLVMBuild knows dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187777 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-06 05:56:32 +00:00
Hans Wennborg
6bf104b165 Option parsing: recognize the special -- token
Everything that comes after -- should be treated as a filename. This
enables passing in filenames that would otherwise be conflated with
command-line options.

This is especially important for clang-cl which supports options
starting with /, which are easily conflatable with Unix-style
path names.

Differential Revision: http://llvm-reviews.chandlerc.com/D1274

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187675 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-02 21:20:27 +00:00
Hans Wennborg
9dd8c0cffe Option parsing: add support for alias arguments.
This makes option aliases more powerful by enabling them to
pass along arguments to the option they're aliasing.

For example, if we have a joined option "-foo=", we can now
specify a flag option "-bar" to be an alias of that, with the
argument "baz".

This is especially useful for the cl.exe compatible clang driver,
where many options are aliases. For example, this patch enables
us to alias "/Ox" to "-O3" (-O is a joined option), and "/WX" to
"-Werror" (again, -W is a joined option).

Differential Revision: http://llvm-reviews.chandlerc.com/D1245

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187537 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-31 22:44:41 +00:00
Richard Trieu
3f60fb8610 Silence gcc warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186879 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-22 21:29:28 +00:00
Hans Wennborg
6c7e78746e Option parsing: allow aliases in groups
Option aliases in option groups were previously disallowed by an assert.
As far as I can tell, there was no technical reason for this, and I would
like to be able to put cl.exe compatible options in their own group for Clang,
so let's change the assert.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186838 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-22 16:18:13 +00:00
Reid Kleckner
a2549d3827 [Option] Add inclusion and exclusion flags to option parsing
Summary:
This allows the clang driver to put MSVC compatible options in the same
enumerator space as its normal options but exclude them from normal
option parsing.

Also changes the standard ParseArgs() method to consider unknown
arguments with a leading slash as being inputs rather than flags.

High level discussion for clang-cl is here:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-June/030404.html

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1049

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186703 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-19 18:04:57 +00:00
Reid Kleckner
f73f809756 Revert "[Option] Store arg strings in a set backed by a BumpPtrAllocator"
This broke clang's crash-report.c test, and I haven't been able to
figure it out yet.

This reverts commit r186319.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186329 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 16:40:52 +00:00
Reid Kleckner
95695c8bb3 [Option] Store arg strings in a set backed by a BumpPtrAllocator
No functionality change.

This is preparing to move response file parsing into lib/Option so it
can be shared between clang and lld.  This change isn't just a
micro-optimization.  Clang's driver uses a std::set<std::string> to
unique arguments while parsing response files, so this matches that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186319 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 13:46:24 +00:00
Reid Kleckner
b0a9ffaeb0 Fix a crash bug in dumping options with groups
Option groups don't have prefixes.  Option dumping is basically dead
code unless there is something wrong with the option table, so this
isn't an important crasher.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185031 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26 22:43:37 +00:00
Reid Kleckner
1ee21dc1e1 Merge changes to clang's Driver code into LLVM's Option library
This is in preparation for switching the clang driver over to using LLVM's
Option library.  Richard Smith introduced most of these changes to the clang
driver in r167638.

Reviewers: espindola on IRC

Differential Revision: http://llvm-reviews.chandlerc.com/D970

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183925 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-13 18:12:12 +00:00
Chandler Carruth
58a2cbef4a Resort the #include lines in include/... and lib/... with the
utils/sort_includes.py script.

Most of these are updating the new R600 target and fixing up a few
regressions that have creeped in since the last time I sorted the
includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171362 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 10:22:59 +00:00
Michael J. Spencer
96a564f2be Copy clang/Driver/<Option parsing stuff> to llvm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169344 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 00:29:32 +00:00