Commit Graph

172 Commits

Author SHA1 Message Date
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

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

To reduce churn, not touching namespaces spanning less than 10 lines.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
Adrian Prantl bb165fb04d Introduce a PCHContainerOperations interface (NFC).
A PCHContainerOperations abstract interface provides operations for
creating and unwrapping containers for serialized ASTs (precompiled
headers and clang modules). The default implementation is
RawPCHContainerOperations, which uses a flat file for the output.

The main application for this interface will be an
ObjectFilePCHContainerOperations implementation that uses LLVM to
wrap the module in an ELF/Mach-O/COFF container to store debug info
alongside the AST.

rdar://problem/20091852

llvm-svn: 240225
2015-06-20 18:53:08 +00:00
Daniel Jasper 0f29127636 Tooling: When applying a set of replacements, do deletions before
insertions. It is unlikely to be the intention to delete parts of newly
inserted code. To do so, changed sorting Replacements at the same offset
to have decreasing length.

llvm-svn: 239809
2015-06-16 10:22:10 +00:00
Manuel Klimek 94a89231f6 Allow replacements created from token ranges to specify language options.
The default language options will lead to incorrect replacements in C++
code, for example when trying to replace nested name specifiers ending
in "::".

llvm-svn: 238922
2015-06-03 13:10:41 +00:00
Benjamin Kramer 3204b152b5 Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types
If the type isn't trivially moveable emplace can skip a potentially
expensive move. It also saves a couple of characters.


Call sites were found with the ASTMatcher + some semi-automated cleanup.

memberCallExpr(
    argumentCountIs(1), callee(methodDecl(hasName("push_back"))),
    on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))),
    hasArgument(0, bindTemporaryExpr(
                       hasType(recordDecl(hasNonTrivialDestructor())),
                       has(constructExpr()))),
    unless(isInTemplateInstantiation()))

No functional change intended.

llvm-svn: 238601
2015-05-29 19:42:19 +00:00
Manuel Klimek b1223b1de5 Fix bug in Replacement's toString on Windows (missing flush).
Adapt function to LLVM coding style.

llvm-svn: 235286
2015-04-20 06:58:56 +00:00
David Blaikie ab8f7d5876 Improve const-ness
This allows callers to pass a char ** (such as the one coming from the
standard decreed main declaration - even though everyone usually puts
const on that themselves).

llvm-svn: 235150
2015-04-17 00:19:34 +00:00
Alexander Kornienko 34eb20725d Use 'override/final' instead of 'virtual' for overridden methods
Summary:
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
    -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: klimek, cfe-commits

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

llvm-svn: 234678
2015-04-11 02:00:23 +00:00
Manuel Klimek bea7dfbc5e Make the clang-fuzzer use the CompilerInstance directly.
Going through the driver is too slow.

llvm-svn: 233459
2015-03-28 00:42:36 +00:00
Benjamin Kramer 9e925c1d66 [tooling] Move ArgumentsAdjustingCompilations into an anonymous namespace.
NFC.

llvm-svn: 232947
2015-03-23 12:47:15 +00:00
Yaron Keren 92e1b62d45 Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str()
calls are not required. This patch removes a whole bunch of them, yet
there are lots more.

There are two use cases where str() is really needed:
1) To use one of StringRef member functions which is not available in
SmallString.
2) To convert to std::string, as StringRef implicitly converts while 
SmallString do not. We may wish to change this, but it may introduce
ambiguity.

llvm-svn: 232622
2015-03-18 10:17:07 +00:00
Benjamin Kramer 6a1457e6c1 Tooling: Hide implementation details
NFC.

llvm-svn: 231656
2015-03-09 15:03:26 +00:00
Chris Bieneman 0a9f607f7b Adopt new cl::HideUnrelatedOptions API added r226729.
Summary: cl::HideUnrelatedOptions allows tools to hide all options not part of a specific OptionCategory. This is the common use case for cl::getRegisteredOptions, which should be deprecated in the future because it exposes implementation details of command line parsing.

Reviewers: dexonsmith

Subscribers: klimek, cfe-commits

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

llvm-svn: 226741
2015-01-21 23:26:11 +00:00
Alexander Kornienko d1f1fa2636 Attempt to fix the build with XCode 5.0.2 (and probably 5.1.1).
llvm-svn: 226282
2015-01-16 15:57:15 +00:00
Alexander Kornienko 74e1c46a50 Make ArgumentsAdjuster an std::function.
Reviewers: klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 223248
2014-12-03 17:53:02 +00:00
Manuel Klimek d3aa1f4a63 Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName
Change to original: ifndef out tests in Windows due to /-separated
paths.

Summary:
Often one is only interested in matches within the main-file or matches
that are not within a system-header, for which this patch adds
isInMainFile and isInSystemFile. They take no arguments and narrow down
the matches.

The isInFileMatchingName is mainly thought for interactive
clang-query-sessions, to make a matcher more specific without restarting
the session with the files you are interested in for that moment. It
takes a string that will be used as regular-expression to match the
filename of where the matched node is expanded.

Patch by Hendrik von Prince.

llvm-svn: 222765
2014-11-25 17:01:06 +00:00
Aaron Ballman 6265102c17 Reverting r222646; the tests do not pass on Windows. Also reverts r222664, which was required for r222646 to compile with Visual Studio 2012.
llvm-svn: 222667
2014-11-24 17:39:44 +00:00
Manuel Klimek da50ff8e4a Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName
Summary:
Often one is only interested in matches within the main-file or matches
that are not within a system-header, for which this patch adds
isInMainFile and isInSystemFile. They take no arguments and narrow down
the matches.

The isInFileMatchingName is mainly thought for interactive
clang-query-sessions, to make a matcher more specific without restarting
the session with the files you are interested in for that moment. It
takes a string that will be used as regular-expression to match the
filename of where the matched node is expanded.

Patch by Hendrik von Prince.

llvm-svn: 222646
2014-11-24 09:10:56 +00:00
Alexander Kornienko c48a535a7c [Tooling] Restore current directory after processing each file.
Summary:
If we actually change directory before processing a file, we need to
restore it afterwards. This was broken in r216620.

Added a comment for the changes in r216620.

Reviewers: klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 221600
2014-11-10 15:42:31 +00:00
Alexander Kornienko 616860994d [clang-tidy] Move -extra-arg handling to CommonOptionsProvider
Summary:
Handle -extra-arg and -extra-arg-before options in the
CommonOptionsProvider so they can be used in all clang tools. Adjust arguments
in a CompilationDatabase wrapper instead of adding ArgumentsAdjuster to the
tool.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 221248
2014-11-04 08:51:24 +00:00
NAKAMURA Takumi 9f99a7a417 [CMake] Prune redundant libdeps.
llvm-svn: 220893
2014-10-30 01:37:44 +00:00
NAKAMURA Takumi 5fed305f87 [CMake] clangToolingCore requires clangLex.
llvm-svn: 220889
2014-10-30 00:43:44 +00:00
Daniel Jasper cb3e6188bc Refactor libTooling to reduce required dependencies.
This moves classes for storing and applying replacements to separate
files. These classes specifically are used by clang-format which doesn't
have any other dependencies on clangAST. Thereby, the size of
clang-format's binary can be cut roughly in half and its build time sped
up.

llvm-svn: 220867
2014-10-29 18:55:09 +00:00
Justin Bogner aab9792b6c Driver: Use pointee_iterator rather than iterating over unique_ptrs
There's probably never a good reason to iterate over unique_ptrs. This
lets us use range-for and say Job.foo instead of (*it)->foo in a few
places.

llvm-svn: 218938
2014-10-03 01:04:53 +00:00
Benjamin Kramer 90e0fd8f7f Clean up ClangTool's argument adjuster handling a bit with unique_ptr.
Make the dtor non-virtual while there. No functionality change.

llvm-svn: 218379
2014-09-24 11:47:42 +00:00
Benjamin Kramer efffbee024 Tooling: Ignore file names in tooling::deduplicate.
This was horribly broken due to how the sort predicate works. We would
report a conflict for files with a replacement in the same position but
different names if the length differed. Just ignore paths as this is often
what the user wants. Files can occur with different names (due to symlinks
or relative paths) and we don't ever want to do the same edit in one file
twice.

llvm-svn: 217439
2014-09-09 13:53:29 +00:00
David Blaikie c11bf80265 unique_ptrify JobList::Jobs
llvm-svn: 217168
2014-09-04 16:04:28 +00:00
Alexander Kornienko 9a45fac6f7 Query CompilationDatabase right before running each compilation.
Summary:
Query CompilationDatabase right before running each compilation. This allows
supporting compilation databases that change external state required for
successful compilation.

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 216620
2014-08-27 21:36:39 +00:00
David Blaikie 49cc3181a2 Overload SourceManager::overrideFileContents so that unconditionally passing ownership is explicitly done using unique_ptr.
Only those callers who are dynamically passing ownership should need the
3 argument form. Those accepting the default ("do pass ownership")
should do so explicitly with a unique_ptr now.

llvm-svn: 216614
2014-08-27 20:54:45 +00:00
Rafael Espindola d87f8d76e0 Update for LLVM api change.
llvm-svn: 216585
2014-08-27 20:03:29 +00:00
David Blaikie b29bb4528a Sure-up MemoryBuffer ownership in JSONCompilationDatabase's ctor.
llvm-svn: 215246
2014-08-08 22:01:06 +00:00
David Blaikie cdba84c0d3 CompilationDatabase: Sure-up ownership of compilation databases using std::unique_ptr
Diving into the memory leaks fixed by r213851 there was one case of a
memory leak of a CompilationDatabase due to not properly taking
ownership of the result of "CompilationDatabase::autoDetectFromSource".
Given that both implementations and callers have been using unique_ptr
to own CompilationDatabase objects - make this explicit in the API to
reduce the risk of further leaks.

llvm-svn: 215215
2014-08-08 16:06:15 +00:00
Alp Toker 0621cb2e7d Make clang's rewrite engine a core feature
The rewrite facility's footprint is small so it's not worth going to these
lengths to support disabling at configure time, particularly since key compiler
features now depend on it.

Meanwhile the Objective-C rewriters have been moved under the
ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still
potentially worth excluding from lightweight builds.

Tests are now passing with any combination of feature flags. The flags
historically haven't been tested by LLVM's build servers so caveat emptor.

llvm-svn: 213171
2014-07-16 16:48:33 +00:00
Rafael Espindola 2d2b420ab9 Update for llvm api change.
llvm-svn: 212408
2014-07-06 17:43:24 +00:00
Alp Toker f994cef836 Track IntrusiveRefCntPtr::get() changes from LLVM r212366
llvm-svn: 212369
2014-07-05 03:08:06 +00:00
Rafael Espindola 8a8e554adc Include system_error directly.
llvm-svn: 210802
2014-06-12 17:19:42 +00:00
Rafael Espindola c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Alp Toker 1d257e1d0a Remove the last remaining llvm/Config/config.h includes
This corrects long-standing misuses of LLVM's internal config.h.

In most cases the public llvm-config.h header was intended and we can now
remove the old hacks thanks to LLVM r210144.

The config.h header is private, won't be installed and should no longer be
included by clang or other modules.

llvm-svn: 210145
2014-06-04 03:28:55 +00:00
Rafael Espindola 8390a257ed Don't compare an error_code with nullptr.
llvm-svn: 209993
2014-06-01 16:16:02 +00:00
Craig Topper ccbc35edc2 [C++11] Use 'nullptr'. Tooling edition.
llvm-svn: 209192
2014-05-20 04:51:16 +00:00
Alp Toker 77273fc52a Tooling: use stderr, not stdout for missing command line messages
Matches other tooling output that use stderr.

llvm-svn: 208988
2014-05-16 13:45:29 +00:00
Alp Toker 1761f11801 Eliminate DefaultImageName from the Driver constructor
All callers were passing in "a.out" or garbage so a sensible default works fine
here as a cleanup.

This also brings about the possibility of adapting the value based on the
driver's compatibility mode in future.

The setting can still be changed via Driver::DefaultImageName as needed.

llvm-svn: 208926
2014-05-15 22:26:36 +00:00
Benjamin Kramer f3ca269839 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

llvm-svn: 208470
2014-05-10 16:31:55 +00:00
Arnaud A. de Grandmaison e1265143e2 PR19601: std::remove_if does not really remove the elements.
It moves them at the end of the range instead, so an extra erase is needed.

It is strange that this code works without the erase. On the other hand, removing the remove_if will make fail some tests.

llvm-svn: 207696
2014-04-30 19:59:22 +00:00
David Blaikie 103a2de0b4 Push unique_ptr ownership of ASTUnits further back into their factories.
llvm-svn: 207237
2014-04-25 17:01:33 +00:00
David Blaikie 39808ff901 Improve ownership of ASTUnits in libTooling by using std::unique_ptr.
llvm-svn: 207229
2014-04-25 14:49:37 +00:00
Chandler Carruth 57f5fbe3b2 [Modules] Update Clang's two files that use DEBUG(...) without defining
DEBUG_TYPE to do so. LLVM's Debug.h requires this as of r206822.

llvm-svn: 206823
2014-04-21 22:55:36 +00:00
Benjamin Kramer efb1eb981b Tooling: Move heavyweight vectors around instead of copying.
While there convert to range-based for loops. No functionality change.

llvm-svn: 204338
2014-03-20 12:48:36 +00:00
Craig Topper fb6b25b5e4 [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203999
2014-03-15 04:29:04 +00:00