Commit Graph

1837 Commits

Author SHA1 Message Date
Ariel J. Bernal 3f08aae84f cpp11-migrate segfaults transforming map<string,int>::iterator
cpp11-migrate segfaults when -use-auto tries to resolve initializing 
expression resulting in an expression with cleanups.

- Skip expressions with cleanups from the initializer
- Added test case

Fixes PR15550

llvm-svn: 178167
2013-03-27 18:49:31 +00:00
John Thompson d977c1e6c5 Fixed path in file comment. Fixed #include order.
llvm-svn: 178164
2013-03-27 18:34:38 +00:00
John Thompson f5db45bc16 Revised to use MemoryBuffer. Removed redundant llvm:: qualifiers. Removed unnecessary c_str() calls. Reformatted with clang-format.
llvm-svn: 178104
2013-03-27 01:02:46 +00:00
John Thompson 81450dfff9 Revised per review comments to rename test files and rearrange input files.
llvm-svn: 178047
2013-03-26 18:17:28 +00:00
Edwin Vane 3cb833d45b Docs describing limitations of the cpp11-migrate Loop Convert Transform
Sam Panzer, author of loop convert, provided a list of limitations of the tool
to be documented. (Thanks Sam!)

The transform's limitations are now documented in the existing user doc.
Included are examples of the cases where the tool may change semantics.

Author: Jack Yang <jack.yang@intel.com>
llvm-svn: 178034
2013-03-26 16:44:29 +00:00
John Thompson 333ec6ceb7 Added simple regression test for modularize.
llvm-svn: 177960
2013-03-26 01:18:28 +00:00
John Thompson a2de1088b7 Revised to use file list path as reference path, or path provide by new -prefix option. Revised to use LLVM option parser.
llvm-svn: 177959
2013-03-26 01:17:48 +00:00
Edwin Vane a9bf2fd9d1 Adding a failing test case for cpp11-migrate's Loop Convert Transform
Related to PR15589.

llvm-svn: 177891
2013-03-25 19:24:24 +00:00
Edwin Vane 37a5137adc Adding clang-headers as dependency of cpp11-migrate
Fix build dependency. Now can say 'make cpp11-migrate' (with cmake anyway) from
a clean build and result will be usable.

Author: Ariel J Bernal <ariel.j.bernal@intel.com>
llvm-svn: 177871
2013-03-25 15:19:43 +00:00
Daniel Jasper 83c10c9d38 Remove clang-format tests from tools/extra.
These will be re-added to clang/test.

llvm-svn: 177852
2013-03-25 09:14:14 +00:00
Daniel Jasper ff367af17b Fix Makefile.
llvm-svn: 177507
2013-03-20 10:02:35 +00:00
Daniel Jasper 168ee99ffa Remove clang-format from clang-tools-extra.
llvm-svn: 177504
2013-03-20 09:52:50 +00:00
Edwin Vane c383960be9 Don't replace macro usage if macro body has NULL
In case of macro body expansion, check to see if the macro is named NULL and
don't replace inside the macro body. This fixes the case when NULL appears
inside the macro body and the transform replaces the usage of the macro with
nullptr. This is an easy fix for the problem for now and we should analyze the
macro body to see if it expands to only NullToPointer in the future for a more
robust solution that takes care of user defined macros that behaves like NULL.

Other changes:
- Moved complex macro tests to macros.cpp
- Added new test cases.
- Added checks to make sure that the macro bodies are not modified by the tool.

Fixes: PR15396

Author: Tareq A Siraj <tareq.a.siraj@intel.com>
llvm-svn: 177422
2013-03-19 18:47:03 +00:00
Edwin Vane 2032fb973b Don't include outer-most explicit cast in nullptr replacement
The outer-most explicit cast is now left alone by the Use-Nullptr transform to
maintain the type of the expression and avoid introducing ambiguities.

Fixes PR15395.

Author: Ariel J Bernal <ariel.j.bernal@intel.com>
llvm-svn: 177179
2013-03-15 20:18:08 +00:00
Edwin Vane 52c326ec78 Prevent nullptr_t-typed exprs from being replaced
The Use-Nullptr transform was replacing nullptr_t-typed expressions because in
the AST such expressions have an implicit NullToPointer cast around them. Now
the transform ignores these expressions.

Fixes PR15414.

llvm-svn: 177168
2013-03-15 18:10:07 +00:00
Edwin Vane ead1696fa6 Adding a new code owners file for clang-tools-extra.
Populated file with known existing owners.

llvm-svn: 177083
2013-03-14 16:56:31 +00:00
John Thompson ce601e21d0 Added future directions comment and a couple of fixme's.
llvm-svn: 176998
2013-03-14 01:41:29 +00:00
John Thompson 1f67ccb3fd Review feedback change per Edwin: Move non-public members to end of classes.
llvm-svn: 176883
2013-03-12 18:51:47 +00:00
Sean Silva a7aedfa5db [docs] Clarify wording.
"This documentation" could be construed as the entire c-t-e docs
(despite being under a doxygen heading; people read "locally"
sometimes), which gives a bad impression.

llvm-svn: 176849
2013-03-12 02:40:05 +00:00
John Thompson 4f8ba659d9 Initial check in of Doug's modularize tool for checking header readiness for modules, plus some changes per review feedback: Removed system headers, changed to use stream output, added file name in message.
llvm-svn: 176847
2013-03-12 02:07:30 +00:00
Edwin Vane bdcd1350c1 Adding -final-syntax-check to cpp11-migrate user docs
llvm-svn: 176758
2013-03-09 03:38:20 +00:00
Edwin Vane e4e7c24efc Splitting cpp11-migrate transform docs into sub-pages
Each transform belongs in its own sub-page now. Minor refactoring to reflect
new heading levels.

llvm-svn: 176757
2013-03-09 03:33:50 +00:00
Edwin Vane 3b9f08d6d0 Adding user documentation for UseAuto transform
Reviewers: silvas, gribozavr
llvm-svn: 176735
2013-03-08 23:26:00 +00:00
Edwin Vane cadde90983 Removing 'modindex' from clang-tools-extra doc index
There are no python modules in clang-tools-extra so a link to this
auto-generated page, which currently isn't generated anyway, is not necessary.

llvm-svn: 176713
2013-03-08 19:20:07 +00:00
Edwin Vane fac739a357 Fixing Doxygen warnings in cpp11-migrate
Turned on doxygen warnings and fixed the resulting problems.

llvm-svn: 176712
2013-03-08 19:12:12 +00:00
Edwin Vane c016c0da12 Turned no_xform into a pass from expected failure.
Since no_xform is not a bug to be fixed, made the test pass using the 'not'
utility and removed XFAIL.

llvm-svn: 176709
2013-03-08 18:39:07 +00:00
Edwin Vane 3606f5508b Extend loop variable naming checks
The loop convert tests for conflicting names have been extended to check for
macro names, types, and language keywords including language extensions. Tests
have also been added.

Fixes PR15322

Author: Jack Yang <jack.yang@intel.com>
Reviewer: gribozavr, klimek, revane
llvm-svn: 176690
2013-03-08 14:15:18 +00:00
Edwin Vane 4f05d7143f Have LoopConvert use 'auto &&' where necessary
For iterators where the dereference operator returns by value, LoopConvert
should use 'auto &&' in the range-based for loop expression.

If the dereference operator returns an rvalue reference, this is deemed too
strange and the for loop is not converted.

Moved test case from iterator_failing.cpp to iterator.cpp and added extra
tests.

Fixes PR15437.

Reviewer: gribozavr
llvm-svn: 176631
2013-03-07 16:22:05 +00:00
Chandler Carruth 074a3568fc Switch from autogenerating tests to using the preprocessor.
NOTE: You may need to run 'make clean' or 'ninja -t clean' etc!!! This
      is due to really nasty bug/interactions between
      CMake/configure/make/Ninja/LIT...

This commit tries to back out the support for generating test cases as
part of the build system due to the issues I brought up in post-commit
review:

1) It adds a *lot* of complexity and fragility to the build system. See
   the number of commits required to try to get all the bots happy.
2) It isn't really necessary -- we can already run scripts to generate
   things with the RUN lines of a test.
3) It makes the tests somewhat harder to debug as they cross between
   more domains.
4) In almost all cases it isn't really needed or it can be done directly
   using the preprocessor.

I should have been more proactive reviewing this, and I'm really sorry
about the churn here. =/ To help keep track of what commits are going
where, this backs out most of the non-test-changes from these revisions:
  r176397
  r176373
  r176293
  r176184
  r175744
  r175624
  r175545
  r175544

There were several trivial or cleanup changes to the lit files or other
files. Some of these looked ok, but I didn't try to tease them apart...
Edwin, if you know what to look for, please carry on with the cleanups
there, and sorry for hosing stuff here but I'm not much of a Python
person, and so I was erring on the side of cautiously backing out the
change.

I've tried to preserve the test changes everywhere I could, but review
is appreciated here in case I missed some.

I then re-wrote the tests to use the preprocessor rather than python to
expand to the various bits of code. The nicest part of this is that now
all the files are just C++ code. They edit and behave like C++ code,
etc. RUN lines with different -D flags are used to run the same test
over multiple different configurations, and includes bracketed in
special defines are used to flesh out a collection of standard interface
stubs to test interactions between pieces. These probably aren't perfect
yet, but I think its an improvement (at least in terms of build system
complexity) and will hopefully be a useful demonstration of the
technique I prefer for these types of tests.

llvm-svn: 176627
2013-03-07 10:09:47 +00:00
Stefanus Du Toit 49fe6388b6 Test case for PR-15414 - nullptr_t functions
The use-null-ptr transform will transform calls to functions that return a
nullptr_t. Even if the function were to only return a null pointer and do
nothing else, this replacement would still be undesired as the behavior and
signature of the function could change in the future.

This adds an XFAILed test case to demonstrate the issue.

Reviewed by: Edwin Vane, Tareq Siraj

llvm-svn: 176553
2013-03-06 15:32:20 +00:00
Edwin Vane 105963d17c Fixed Use-Nullptr when replacing return(0)
Before fix, the paren expression was being replaced resulting in returnnullptr.
ParenExpr and implicit casts now ignored so we get return(nullptr) instead.

Added new test cases.

Fixes PR15398

Author: Ariel Bernal <ariel.j.bernal@intel.com>
llvm-svn: 176551
2013-03-06 14:51:34 +00:00
Dmitri Gribenko f68a5280cb Added summary option to cpp11-migrate tool
Added a summary option that enables output to stdout counting the number of
changes each transform has accepted, rejected or deferred.

Patch by Ariel Bernal.

llvm-svn: 176465
2013-03-05 00:12:33 +00:00
Edwin Vane 529e3c7c57 Adding failing LoopConvert testcase
LoopConvert isn't properly handling iterators whose dereference operator
returns by value. This test case demonstrates the failure.

See PR15437.

llvm-svn: 176437
2013-03-04 16:56:04 +00:00
Edwin Vane 2f43085b46 Properly identify 'this' as range-based for container
The Loop-Convert transform was mistransforming loops using 'this' implicitly.
Fixed and added tests.

Fixes PR15411.

llvm-svn: 176436
2013-03-04 16:35:04 +00:00
Sean Silva 206bc114f8 .gitignore: ignore docs/_build
That is where the documentation gets built to.

I'm pretty much clueless about SVN; I would appreciate if someone more
knowledgeable about SVN made the equivalent change.

llvm-svn: 176417
2013-03-03 15:15:12 +00:00
Benjamin Kramer 65d2d14f32 Make gen_my_std.h.py compatible with python 2.5 too.
llvm-svn: 176409
2013-03-02 15:52:55 +00:00
Benjamin Kramer 336ec56081 Make the UseAuto test case generator compatible with python 2.5.
llvm-svn: 176406
2013-03-02 09:24:42 +00:00
Edwin Vane a98217a2b6 Avoid parallelism problems generating lit.site.cfgs
extra/test/cpp11-migrate/Makefile was using the same tmp file for generating
lit.site.cfg for two different directories. Parallelism caused conflicts so now
using differently named temp files.

llvm-svn: 176379
2013-03-01 21:21:37 +00:00
Stefanus Du Toit e9779bbef0 cpp11-migrate: Reduce the number of parsing passes.
Previously we would check the syntax of the file before we transform
it, but that's redundant since it'll be checked as part of the
transformation. Remove that check completely.

We also had an unconditional syntax check after transforming. This
is only really useful to debug cpp11-migrate, since users will end
up compiling the transformed source anyways, and the transformations
*should* never introduce a failure. Made this an option, accessible
via "-final-syntax-check".

Resolves PR 15380.

llvm-svn: 176376
2013-03-01 20:53:43 +00:00
Edwin Vane b1bb4c2dbb Fix recursive make in clang-tools-extra
Autoconf make (all) now properly recurses from tools/extra/Makefile into
tools/extra/test/Makefile and tools/extra/test/cpp11-migrate/Makefile. The
'all' target is responsible for creating lit config files and autogenerating
tests. Subsequent 'check-all' targets will properly work.

Re-enabling UseAuto/iterator.cpp test.

General clean-up of clang-tools-extra makefiles; removing dead targets and
removing duplicated pieces of llvm/Makefile.rules.

llvm-svn: 176373
2013-03-01 19:50:52 +00:00
Stefanus Du Toit 169949724e cpp11-migrate: Factor out duplicate code in UseNullPtr
This moves the actual replacement code into a separate
function. There is still a bit of code duplication to
go from macros to expansion areas, but that code will
need to be fixed anyways to resolve bugs around macro
replacement.

Reviewed by: Tareq Siraj, Edwin Vane

llvm-svn: 176372
2013-03-01 19:47:09 +00:00
Edwin Vane 4b80752550 Don't use 'exit' in lit script
Some buildbots use a shell that doesn't know 'exit'. So instead of using XFAIL
for UseAuto/iterator.cpp (since this problem doesn't exist for cmake) leave the
'grep' command and turn off the others.

llvm-svn: 176295
2013-02-28 20:11:25 +00:00
Edwin Vane ca5a85fad4 Turning off UseAuto/iterator.cpp test until recursive make issue fixed
The way 'make check-all' causes configuration files to be generated results in
the cpp11-migrate/Makefile not being triggered to generated any files. These
files are necessary for UseAuto/iterator.cpp to run. Turning off this test
until the problem is fixed properly.

llvm-svn: 176293
2013-02-28 19:55:53 +00:00
Dmitri Gribenko f38da0dc75 Add doxygen support for the tools in clang-tools-extra
Patch by Ariel Bernal.

llvm-svn: 176267
2013-02-28 16:46:40 +00:00
Edwin Vane 266b625ca9 Introducing Use-Auto transform for cpp11-migrate
The new Use-Auto transform replaces the type specifier for variable
declarations with the special C++11 'auto' type specifier. For now, the
replacement is done only for variables that are iterators of any of the
std containers and only if the type used is one of those explicitly
allowed by the standard (i.e. not an implementation-specific type).

Reviewers: gribozavr, silvas, klimek
llvm-svn: 176266
2013-02-28 16:29:24 +00:00
Dmitri Gribenko 620cb4a459 Fix documentation comment in LoopConvert
Patch by Ariel Bernal

llvm-svn: 176191
2013-02-27 17:34:57 +00:00
Edwin Vane 24b4bb06ed Custom lit.site.cfg configuration for cpp11-migrate
To afford hand-written tests access to any auto-generated headers, a
lit.site.cfg is now created for cpp11-migrate's test directory providing a new
config.substition. Tests can refer to %gen_root in the LIT script.

Removed use of --param clang_site_config. Not necessary when running
tests using the build system.

llvm-svn: 176184
2013-02-27 13:09:24 +00:00
Edwin Vane 30f7004d7c Add user documentation for cpp11-migrate
Adding an RST document for cpp11-migrate. This user documentation explains
command line options, transformations, risk level and how it applies to
loop convert, and code examples of transformations.

There is a TODO task under "Risk" for "Loop Convert" to find code examples
that produce incorrect transformations that change semantics. The definition
of risk in loop convert and instances where the confidence level is lowered
will need to be looked at more carefully.

Information for all new features (including verbose output, auto transform)
will be added in a later change.

Author: Jack Yang <jack.wang@intel.com>
Reviewer: grigozavr
llvm-svn: 176046
2013-02-25 20:37:03 +00:00
Daniel Dunbar 5752aa26f9 [docs] Rename Makefile.
llvm-svn: 175930
2013-02-22 23:44:49 +00:00
Edwin Vane 12db04f820 Fixing a "multiple rules generate X" warning from ninja
CMake's Ninja generator was not detecting that test/lit.site.cfg.in and
test/subdir/../lit.site.cfg.in were really the same file. Ninja noticed this
and complained as both appeared as targets (for the missing file rule). Now
canonicalizing the path to ensure the paths presented to CMake are identical
and the duplication is now fixed.

llvm-svn: 175744
2013-02-21 15:12:01 +00:00
Edwin Vane ea8b062a56 Tweaks and fixes to cpp11-migrate generated tests
* Fixed a comment typo
* Changed 'autogen' to 'generated-tests'
* Made the clean target not fail if the 'generated-tests' directory
  doesn't already exist.

llvm-svn: 175624
2013-02-20 14:35:53 +00:00
Edwin Vane 963a7b411e Adding files left out of commit r175544.
llvm-svn: 175545
2013-02-19 19:14:45 +00:00
Edwin Vane 8b526f22c6 Add support for auto-generating LIT tests by the build
autoconf and CMake flavours both updated to auto-generate files for use
in cpp11-migrate's LIT tests.

Auto-generated files are placed in the build directory under
test/cpp11-migrate/autogen. The directory structure past this point
mirrors the structure in the source directory under test/cpp11-migrate.
A lit.site.cfg is generated in test/cpp11-migrate/autogen to describe
the new test suite. When LIT runs, it runs the standard testsuite and
now also the auto-generated testsuite.

llvm-svn: 175544
2013-02-19 19:08:10 +00:00
Edwin Vane 4ad00b46fb Fix -use-nullptr problems with assert()
If a cast expression (NullToPointer) is detected in a function-like macro
parameter, we should use the spelling location instead of the expansion
location. Using SourceManager::getFileLoc() fixes this problem.

Also added testcases for this bug.

Fixes: PR15279
Author: Tareq A Siraj <tareq.a.siraj@intel.com>
Reviewer: klimek
llvm-svn: 175399
2013-02-17 16:45:54 +00:00
Edwin Vane dd4743d18a Propagate changes through no-op transforms
Currently, changes made by previous transforms are not kept if a transform
doesn't make any changes itself to a given file. Now file states are propagated
properly through transforms that don't make changes.

Fixes: PR15281
Author: Jack Yang <jack.yang@intel.com>
Reviewer: klimek
llvm-svn: 175288
2013-02-15 19:38:28 +00:00
Edwin Vane 7f999078bf Initial docs directory
Adding a new docs directory, with files auto-generated by sphinx-quickstart,
for user documentation for the various tools in the clang-tools-extra
repository.

Author: Jack Yang <jack.yang@intel.com>
Reviewers: gribozavr, silvas
llvm-svn: 175118
2013-02-14 01:34:59 +00:00
Manuel Klimek f92b666da9 Adapt test to new clang-format behavior.
llvm-svn: 174738
2013-02-08 20:04:33 +00:00
Edwin Vane 37fea69391 Fix for combined loop and nullptr convert tests
The rewriter was previously reading the content buffer from the file itself.
Since we are now keeping the content in memory and writing to the file only
once, the rewriter's buffer (from the file) was not in sync with the
RefactoringTool's buffer. Adding an overrideFileContents call (similar to how
Clang-format handles for this) will resolve this issue.

Author: Jack Yang <jack.yang@intel.com>
Reviewers: gribozavr, klimek
llvm-svn: 174643
2013-02-07 18:49:23 +00:00
Daniel Jasper d1a6659263 Remove superseeded option.
The -invert-pointer-binding option will be superseeded by my next
cfe-commit. Instead of explicitly overwriting this flag, clang-format
can then be configured to auto-detect certain style-options based on the
input file.

llvm-svn: 174503
2013-02-06 14:22:17 +00:00
Manuel Klimek 5e5e1c3b80 Add xml:space='preserve' in order to correctly preserve whitespace.
llvm-svn: 174502
2013-02-06 12:40:01 +00:00
Manuel Klimek 1882ad9905 Kick JSON output for XML output.
Apparently the owners of the tools we want to integrate with (eclipse in
this case) don't have JSON parsers.

The output now is:
<replacements>
<replacement offset='2' length='3'>  </replacement>
...
</replacements>

Kicking JSON for now - it's easy enough to get back in when we need it.

FIXME: once we find this useful enough, we might want to add it as
free-standing functions to tooling.

llvm-svn: 174497
2013-02-06 09:42:05 +00:00
Manuel Klimek 65bdeae121 Adds JSON output for replacements, to simplify tools integration.
Using -output-replacements will now output the replacements instead
of the changed code. This allows easier integration with tools that
need full control over what changed.

The format is an array of objects with the members "offset" (number),
"length" (number) and "replacement_text" (string), for example:

[
  {
    "offset": 42,
    "length": 5,
    "replacement_text": "  "
  },
  {
    "offset": 105,
    "length": 4,
    "replacement_text": ""
  }
]

llvm-svn: 174382
2013-02-05 15:52:21 +00:00
Manuel Klimek 8c651f0974 Implements support for specifying multiple ranges.
This is backwards compatible with earlier integrations.
Also adds a basic test and a test for the ranges integration.

You can now run:
clang-format -offset=42 -length=15 -offset=150 -length=22
To re-format the ranges (42, +15) and (150, +22).

llvm-svn: 174378
2013-02-05 15:25:34 +00:00
Daniel Jasper 21cdc848f4 Don't touch unchanged file for in-place edit.
This fixes llvm.org/PR15087.

llvm-svn: 173919
2013-01-30 09:52:38 +00:00
NAKAMURA Takumi 6fb75e08e5 test/remove-cstr-calls/basic.cpp: Disable again on mingw. It behaves unstable.
llvm-svn: 173562
2013-01-26 06:39:48 +00:00
NAKAMURA Takumi fc37344916 Drop "REQUIRES:shell" in tests. They can run on win32.
llvm-svn: 173415
2013-01-25 04:33:40 +00:00
Edwin Vane 44c3145938 Add use-nullptr transform to cpp11-migrate
This transform converts the usage of null pointer constants (e.g. NULL, 0,
etc.) in legacy C++ code and converts them to use the new C++11 nullptr
keyword.
- Added use-nullptr transform.
- Added C++11 support to the final syntax check. Used ArgumentAdjuster class to
  add -std=c++11 option to the command line options.
- Added tests for use-nullptr transform.
- Added tests that exercises both loop-convert and use-nullptr in the source
  file.

TODO: There's a known bug when using both -loop-convert and -use-nullptr at the
      same time.

Author: Tareq A Siraj <tareq.a.siraj@intel.com>
Reviewers: klimek, gribozavr
llvm-svn: 173178
2013-01-22 18:31:49 +00:00
Chris Lattner 28b00bffd2 these need the bitcode reader as well.
llvm-svn: 172908
2013-01-19 18:45:35 +00:00
Chandler Carruth 06e24e34a9 Re-sort the #include lines which have gotten out of order.
llvm-svn: 172895
2013-01-19 09:10:38 +00:00
NAKAMURA Takumi 40ac112c91 Introduce llvm::sys::PrintStackTraceOnErrorSignal()
llvm-svn: 172821
2013-01-18 14:31:00 +00:00
Dmitri Gribenko 3de75d7c7c Fix a -Wdocumentation warning (empty paragraph passed to '\brief' command)
llvm-svn: 172661
2013-01-16 22:10:09 +00:00
Edwin Vane 862fec8835 Write transform results to disk only once
Instead of writing the result of each transform to disk for every
transform, write the results to buffers in memory and pass those buffers
to the next transform as input. Only write the buffers to disk if the
final syntax check passes.

Reviewers: klimek
llvm-svn: 172657
2013-01-16 21:11:50 +00:00
Daniel Jasper 9f4a1c6184 Add temporary option to invert the */& binding in a specific style.
This is temporarily necessary until styles are configurable through files
as it seems to be a contentious issue.

llvm-svn: 172546
2013-01-15 18:56:19 +00:00
Alexander Kornienko 02fd3ad24b Test source file name in diagnostics
llvm-svn: 172434
2013-01-14 17:01:57 +00:00
Daniel Jasper 51ce63cd98 Add support for Chromium style.
llvm-svn: 172432
2013-01-14 16:26:38 +00:00
Edwin Vane d44cbf7d09 Adding a .gitignore to tools-extra
Reviewers: klimek

llvm-svn: 172414
2013-01-14 14:20:19 +00:00
Alexander Kornienko 92bb086fba Added a test for clang-format diagnostics.
llvm-svn: 172407
2013-01-14 13:57:05 +00:00
Alexander Kornienko 79f49456fa Fix: correct file name in diagnostics.
llvm-svn: 172405
2013-01-14 13:40:44 +00:00
Edwin Vane bfbd10b329 Update users of RefactoringTool
RefactoringTool::run() no longer writes changes to disk automatically. Updating users of RefactoringTool to explicitly perform the write.
    
Reviewers: klimek

llvm-svn: 172218
2013-01-11 17:04:09 +00:00
Nico Weber e5d643d21c Remove FIXME fixed by djasper in r172066.
llvm-svn: 172097
2013-01-10 19:48:53 +00:00
Alexander Kornienko 92465285ab Format what you can when errors are found
llvm-svn: 172075
2013-01-10 15:19:44 +00:00
Edwin Vane 86c63d94bb Removing loop-convert tool
cpp11-migrate now contains the loop convert transform code and tests.
Cleaning up the old code/tests and updating build system files as
necessary.

Reviewers: klimek
llvm-svn: 172074
2013-01-10 15:19:11 +00:00
Alexander Kornienko 5b64279192 Improved clang-format integration support for diagnostic messages output
llvm-svn: 172072
2013-01-10 15:06:57 +00:00
Daniel Jasper 494394d817 Let clang-format binary use same LangOpts as test.
llvm-svn: 172066
2013-01-10 13:09:09 +00:00
Alex Rosenberg eb8360003b Add .arcconfig for Arcanist support for Phabricator
llvm-svn: 172043
2013-01-10 04:12:08 +00:00
Alex Rosenberg 0b18a095cf Fix comment
llvm-svn: 172042
2013-01-10 04:12:06 +00:00
Daniel Jasper abf4cce40f Simplify reversed for-loop.
llvm-svn: 171998
2013-01-09 20:46:42 +00:00
Daniel Jasper 46e432fb8a Initial version of diff/patch-reformat tool.
Use at your own risk :-).

llvm-svn: 171994
2013-01-09 20:20:11 +00:00
Manuel Klimek 3a449891ba Implements the features requested in PR14679.
- adds '-h' as an alias for '-help'.
- adds an optional <file> argument
- adds an option -i to in-place edit the given file
- adds a help text to explain what the tool does

llvm-svn: 171858
2013-01-08 15:19:57 +00:00
Edwin Vane 31896624da Transferred loop-convert tests to cpp11-migrate
- Turned off -count-only tests as they aren't supported in cpp11-migrate
  yet.
- Updated tests to use new binary name and options to access
  loop-convert transform.
- Fixed header guards to not use restricted names.

Reviewers: klimek, gribozavr
llvm-svn: 171852
2013-01-08 14:36:29 +00:00
Nico Weber 48e75f7e48 Enabled ObjC2 in clang-format for @package. Matches r171766.
llvm-svn: 171767
2013-01-07 19:08:19 +00:00
Nico Weber d9a440d21f Set LangOpts.ObjC1 to 1 in clang-format.
This matches the test change done in clang at r171742. Without this,
clang-format would strip '@' characters and format e.g. '@interface' as
'interface'.

llvm-svn: 171743
2013-01-07 15:21:13 +00:00
Daniel Jasper f7b48b6342 Make clang-format binary understand C++11.
llvm-svn: 171736
2013-01-07 14:52:14 +00:00
Chandler Carruth 08116a7df3 Add a namespace qualifier to the befriending statement for
RecusiveASTVisitor. With Clang and modern GCCs this was found through
the injected class name of the base class but older GCCs don't properly
implement the injected class name rules.

llvm-svn: 171593
2013-01-05 02:57:54 +00:00
Edwin Vane dde168b8b5 Port loop-convert into cpp11-migrate
Took existing code from loop-convert tool and made it into a cpp11-migrate
transform. Pattern now set for having transform code in subdirectories. Related
changes:
- Makefile and CMakeLists.txt updated to support source files in
  subdirectories.
- At least one transform must be specified. syntax-only tests removed to
  reflect this.
- TODO: port over loop-convert tests.

Reviewers: klimek, silvas
llvm-svn: 171481
2013-01-04 18:25:18 +00:00
Daniel Jasper f0273f8e15 Handle segfaults in clang-format vim-integration.
A segfault used to clear the entire buffer. With this change, a message
to report a bug is displayed instead.

This should solve most cases similar to llvm.org/PR14774.

llvm-svn: 171480
2013-01-04 18:24:12 +00:00
Chandler Carruth 54e147a933 Fix the sorting of the #include lines in these tools.
This is done with the script in llvm/utils/sort_includes.py

llvm-svn: 171365
2013-01-02 10:29:31 +00:00
NAKAMURA Takumi 43632a26a5 Update the copyright coredits -- Happy new year 2013!
llvm-svn: 171342
2013-01-01 10:00:19 +00:00
Chandler Carruth 5826f96e51 Teach the extras repository to actually install the clang-format tool.
We should also install the clang-format.py script somewhere that makes
since for a Vim integration script. I don't know where that is though,
so just installing the binary for now. This is enough to let me use the
script from a checkout combined with the installed (and thus less likely
to crash or be slow) clang-format binary.

llvm-svn: 171164
2012-12-27 17:48:37 +00:00
Edwin Vane 9e3c9de527 Use renamed CommonOptionsParser member functions
GetCompilations() and GetSourcePathLists() were renamed to match LLVM style.

Reviewed By: Alexander Kornienko

llvm-svn: 170230
2012-12-14 18:59:24 +00:00
Edwin Vane 3d97cc4c57 Add cpp11-migrate to autoconf build
llvm-svn: 169986
2012-12-12 16:08:10 +00:00
Edwin Vane 9bd2e1bacc Initial commit for cpp11-migrate tool
- Added directory structures and build system files for the new tool.
- Extremely basic implementation of tool performs only an initial syntax check.
- Basic tests ensure syntax test works as expected.

llvm-svn: 169983
2012-12-12 14:30:57 +00:00
Daniel Jasper 79e68bcf0e Basic clang-format vim-integration.
File contains installation and usage instructions.

llvm-svn: 169421
2012-12-05 21:06:08 +00:00
Daniel Jasper 95b089e287 Fix make build (hopefully).
llvm-svn: 169371
2012-12-05 10:22:07 +00:00
Daniel Jasper ff1491322e First version of a command line clang-format tool.
Reads a single source range (offset, length) as well as the style guide
as parameters and then reformats everything it receives from stdin.

llvm-svn: 169364
2012-12-05 09:01:09 +00:00
Chandler Carruth 9b1773b517 Update the #include lines of the extra tools.
llvm-svn: 169239
2012-12-04 09:21:50 +00:00
Edwin Vane 0254657c2d Test commit: reformat comment.
llvm-svn: 169126
2012-12-03 14:32:13 +00:00
Manuel Klimek 61a928720a Following the example from loop-convert tests, simplifying the remove-cstr-calls lit script.
Patch by Edwin Vane.

llvm-svn: 167390
2012-11-05 18:28:45 +00:00
NAKAMURA Takumi 9a37b94c95 Remove a trailing blank line, test commit.
llvm-svn: 165621
2012-10-10 14:06:15 +00:00
David Blaikie 149bf5d8a8 Fix typo in a comment in lit.cfg
Matches the same typo fix in clang's lit.cfg that this was copy/pasted from.

(original fix to clang's lit.cfg in r163696)

llvm-svn: 163718
2012-09-12 16:29:37 +00:00
David Blaikie d7086fb347 Make lit.cfg like the other lit.cfgs so it can be run standalone.
Relies on matching lit change in r163171.

llvm-svn: 163172
2012-09-04 22:23:37 +00:00
Ted Kremenek 8f6943c2e6 Update Makefiles to reflect split of clangRewrite.a into two libraries.
llvm-svn: 163056
2012-09-01 07:44:41 +00:00
David Blaikie 50174dc642 Add loop-convert to the Make build.
Hey, now the loop-convert tests pass too.

llvm-svn: 163015
2012-08-31 19:46:47 +00:00
David Blaikie efae14e96c Fix tests to be more robust (to older versions of grep, lesser lit-like test runners, etc)
Seems I had a problem with my version of grep, when run by lit, not supporting
the \s escape. This seems to fix it for me & I'll be getting the buildbots to
run these tests too to keep an eye on them (actually loop-convert tests still
fail when run via a make build, so that'll be addressed in a future commit). I
could use [[:space:]] to generalize over other whitespace but that seemed
unnecessarily verbose when the flexibility wasn't actually required by the
current text of the tests.

Also I just simplified a lot of the loop-convert tests (removing the
unecessary temp file deletion at the start, removing the unnecessary && for
FileCheck, etc).

The remove-cstr-calls/basic.cpp changes were necessitated by an out of tree
lit-like test runner that's a bit less fantastic about escaping. They were
modeled on existing tooling test cases in Clang, with thanks to Manuel Klimek
for the pointers.

llvm-svn: 163009
2012-08-31 17:49:33 +00:00
Sam Panzer 4cf99cfdc7 loop-convert, a C++11 for loop modernizer
A new Clang-based tool which converts for loops to use the range-based
syntax new to C++11. Three kinds of loops can be converted:
 - Loops over statically allocated arrays
 - Loops over containers, using iterators
 - Loops over array-like containers, using operator[] and at()

Each transformation is assigned a confidence level by the tool. The
minimum require confidence level to actually apply the transformation
can be specified on the command line, but the default level should be
fine for most code.

Like other tools based on RefactoringTool, it is easiest to use this
tool with a compilation database.

llvm-svn: 162627
2012-08-24 23:46:42 +00:00
Sam Panzer 8e0df501fa Reverted to correct commit this time.
llvm-svn: 162624
2012-08-24 23:29:33 +00:00
Sam Panzer 6d471a12db Reverted incorect partial commit of loop migrator. git-svn strikes again
llvm-svn: 162618
2012-08-24 23:02:27 +00:00
Sam Panzer 72676f419a Slight refactoring
llvm-svn: 162612
2012-08-24 22:10:18 +00:00
Sam Panzer 78184d9d74 Fixes according to code review comments
llvm-svn: 162611
2012-08-24 22:10:15 +00:00
Sam Panzer 4483b0c56d For Loop Conversion
Loop Converter Skeleton - array-step-1

Added a check to loop increments - array-step-2b

Added a check on the loop's condition expression - array-step-2c

Finished array matcher - array-step-2

Retrieved matched nodes - array-step-3

Analysis for array loop indices - array-step-4

Added checking for naming and variable scope

Added confidence level and count-only command line args

Added aliased variable elision

Added support for iterator-based loops

Added support for single-iterator loops which call end() repeatedly

Added support for converting array-like containers

llvm-svn: 162610
2012-08-24 22:10:10 +00:00
Daniel Jasper 98e00797cd Change AST matcher names to conform with the new naming.
llvm-svn: 162539
2012-08-24 05:39:51 +00:00
Marshall Clow 2a6415ec04 Make Mr. Pedantic happy by fixing banner to be exactly 80 columns
llvm-svn: 162287
2012-08-21 16:29:41 +00:00
Marshall Clow 22626c3d7e Fixed some renaming detritus in the comments, and an unused variable warning. Thanks to David Blaikie and Manuel Klimek for the comments
llvm-svn: 162031
2012-08-16 17:47:06 +00:00
Marshall Clow 2920ef43ef Rename directory from 'toolTemplate' to 'tool-template'
llvm-svn: 161887
2012-08-14 18:59:24 +00:00
Marshall Clow e16a45b3bc Added a tool template to make creating new tools simpler
llvm-svn: 161886
2012-08-14 18:53:39 +00:00
Chandler Carruth 27a6c1ed91 Use parallel dirs here, there shouldn't be cross-tool dependencies
anyways. Also place it after the config makefile inclusion which seems
the more canonical location.

llvm-svn: 161613
2012-08-09 20:47:32 +00:00
Chandler Carruth 6d8bf5bcd2 Fix the order of the link arguments for this tool. I think there is
something fishy with the rest of the order too, but this at least lets
it build for me.

llvm-svn: 161550
2012-08-09 00:12:21 +00:00
Chandler Carruth 4b9cf6d61a Fix up the makefiles in the tools repo, and add a top-level makefile
suitable for building as part of the LLVM/Clang build.

llvm-svn: 161538
2012-08-08 23:34:47 +00:00
Chandler Carruth 33453d06c4 Add a copy of the LLVM license here so that even a stand-alone checkout
includes the proper license text.

llvm-svn: 161514
2012-08-08 18:30:15 +00:00
Chandler Carruth 661d7ff913 Replace the stub README with a proper one based on Clang's.
Also test the commit hooks for the new repository.

llvm-svn: 161506
2012-08-08 18:16:41 +00:00
Marshall Clow d39041f2fc Added code to let the user specify a compilation database on the command line
llvm-svn: 161432
2012-08-07 17:58:49 +00:00
Chandler Carruth 118232f2b4 Add a root CMakeLists.txt and fix up all the test build stuff.
With this we can build and test the remove-cstr-calls tool which should
serve as a good example of how to add tools and their tests to the
repository.

llvm-svn: 161404
2012-08-07 08:33:04 +00:00
Chandler Carruth c5062dc91a Copy some of the testing infrastructure from the primary Clang repository into
the new tools repo to preserve history. I'll subsequently be editting these
down to work w/ the tooling test suites.

llvm-svn: 161402
2012-08-07 07:09:14 +00:00
Chandler Carruth 4bf700f1de Copy the existing regression test for remove-cstr-calls from the tooling branch
to preserve its history. It's not yet functional.

llvm-svn: 161401
2012-08-07 07:07:42 +00:00
Chandler Carruth bb5c56f26c Fix compilation with mainline AST matchers.
llvm-svn: 161399
2012-08-07 06:59:48 +00:00
Chandler Carruth 1d0717443f Put it in the correct place within the repository.
llvm-svn: 161398
2012-08-07 06:17:58 +00:00
Chandler Carruth eb06a2e518 Initial check-in of a skeleton of the future clang-tools-extra repository.
llvm-svn: 161378
2012-08-07 00:36:25 +00:00