Commit Graph

164 Commits

Author SHA1 Message Date
Edwin Vane 9924de1b28 Generate input files from within unit test
It is preferable for a unit test to be responsible for creating its own input
data instead of relying on checked-in data files. Now the IncludeExcludeTest
for cpp11-migrate does this.

- Removed old data files.
- Updated build system and lit files to remove references to old data files.

llvm-svn: 181029
2013-05-03 16:30:55 +00:00
Edwin Vane c049c92933 Add support to read include/exclude paths from file
Files containing the list of paths to be included and excluded can now be
specified through -include-from=<filename> and -exclude-from=<filename> command
line options in cpp11-migrate.

Added support for data files for cpp11-migrate unittests. The Cpp11MigrateTests
executable just requires a DATADIR environment variable to be set which
specifies the directory where data files are stored. This is handled
automatically when using LIT.

Author: Jack Yang <jack.yang@intel.com>, Edwin Vane <edwin.vane@intel.com>
llvm-svn: 180939
2013-05-02 19:02:02 +00:00
Ariel J. Bernal ea64c97fa9 Allow autotools to build and install cpp11-migrate
This patch fixes bug15793
cpp11-migrate was built but not installed (make install)
in the autotools build.

llvm-svn: 180721
2013-04-29 18:23:45 +00:00
Eric Christopher 6cddedca72 The option is spelled -use-auto, not -loop-convert.
llvm-svn: 180016
2013-04-22 14:39:46 +00:00
John Thompson a44f85abd4 Fixed outdate comment, and comment typo.
llvm-svn: 179568
2013-04-15 22:32:28 +00:00
Edwin Vane 83a38b5c15 Adding support for -include/-exclude to cpp11-migrate
This commit adds initial support for the -include/-exclude options which are
both currently marked as hidden. This support is the first step toward
supporting transformations in headers included from source files.

Added unittests to test include/exclude support.

Author: Jack Yang <jack.yang@intel.com>
llvm-svn: 179528
2013-04-15 14:50:35 +00:00
Edwin Vane 8ef7fa1e07 Adding the AddOverride transform for cpp11-migrate
This transform adds the override specifier to methods that overrides virtual
methods from a base class that don't already have this specifier.

Author: Philip Dunstan <phil@phildunstan.com>
llvm-svn: 179127
2013-04-09 20:49:49 +00:00
Ariel J. Bernal 464957e2d6 Fix UseNullptr fails to replace c-style explicit cast in a return statement
This happens whenever there is a c-style explicit cast to nullptr not
surrounded by parentheses following a return statement.

- Added a white space before nullptr if the character before is alphanumeric
  when replacing the null pointer expression.
- Simplified visitor
- Addes tests

llvm-svn: 179103
2013-04-09 16:54:56 +00:00
Ariel J. Bernal 005daf1bc6 Fix UseNullptr fails to replace explict casts surrounded by another implicit
cast

UseNullptr previously matched the implicit cast to const pointer as well as
the explicit cast within that has an implicit cast to nullptr as a descendant.

-Refactored UseNullptr to avoid special-casing certain kinds of cast sequences
-Added test cases.

llvm-svn: 178907
2013-04-05 20:32:36 +00:00
Edwin Vane bf4a842861 Committing change left out of r178900
llvm-svn: 178902
2013-04-05 19:25:15 +00:00
Edwin Vane 6b191b0195 Fix symbol dependency errors introduced with libmigrateCore
With cpp11-migrate core functionality moved to a separate library (for enabling
unit tests) this library contained code that referenced symbols that are still
in the main binary. On some platforms, the shared library build broke as a
result. This revision fixes the dependency problem and is safe for the eventual
lib-ification of the transforms as well.

llvm-svn: 178901
2013-04-05 19:18:13 +00:00
Edwin Vane 97a10e9f04 Updating cpp11-migrate unit tests
With the lib-ification of cpp11-migrate, real unit tests can be written.
Replacing dummy tests with some simple tests for the Transform public
interface.

llvm-svn: 178900
2013-04-05 19:17:36 +00:00
Edwin Vane 8581648838 lib-ified core cpp11-migrate functionality to support unit tests
Summary:
Transform.* and Transforms.* moved to form a new library: libmigrateCore.
#includes updated to point to new header locations.

To support autoconf build, Cpp11Migrate.cpp moved to new subdirectory 'tool'
which also contains build files for creating final binary.

CMake and autoconf updated to build the new library and link it with
cpp11-migrate and with cpp11-migrate unit tests.

Dummy unit tests replaced with simple, but real, tests for Transform's public
interface.

TODO: Lib-ifying the transforms to further simplify build of cpp11-migrate.
llvm-svn: 178785
2013-04-04 20:19:58 +00:00
Edwin Vane c0b7be60f8 Unit test support for Clang extra tools
Added support to CMake and autoconf for unit tests in clang-tools-extra. A
dummy test exists for now until more meaningful tests can be written.

llvm-svn: 178661
2013-04-03 15:11:08 +00:00
Edwin Vane eeed39a583 Use 'auto' with 'new' expressions
For variable declarations initialized with new expressions, use 'auto' for the
type specifier.

The 'auto' replacement happens only when the type of the VarDecl exactly
matches the type of the initializer and the VarDecl is *not* CV-qualified. The
only case that is currently handled is if the pointer type of the VarDecl is
itself CV qualified.

Some improvements need to be made to Clang's TypeLoc information in order for
other CV qualifier cases to be successfully handled. See the new test suite
new_cv_failing.cpp for examples of usages that could be handled with such an
improvement.

Function pointers are, for now, not transformed until the identifier info can
be extracted.

Reviewer: klimek
llvm-svn: 178575
2013-04-02 20:43:57 +00:00
Ariel J. Bernal f78debd7d2 Refactor Usenullptr matcher to avoid duplication
Previously UseNullptr matched separately implicit and explicit casts to nullptr,
now it matches casts that either are implict casts to nullptr or have an
implicit cast to nullptr within.

Also fixes PR15572 since the same macro replacement logic is applied to implicit
and explicit casts.

llvm-svn: 178494
2013-04-01 20:09:29 +00:00
Edwin Vane 61af48ce4e Improve loop convert's variable aliasing
Loop convert's variable name aliasing may cause issues if the variable is
declared as a value (copy). The converted loop will declare the variable as a
reference which may inadvertently cause modifications to the container if it
were used and modified as a temporary copy.

This is fixed by preserving the reference or value qualifiers of the aliased
variable. That is, if the variable was declared as a value the loop variable
will also be declared as a value and similarly for references.

Fixes: PR15600
Author: Jack Yang <jack.yang@intel.com>
llvm-svn: 178485
2013-04-01 18:15:06 +00:00
John Thompson 52d9886500 modularize - Fixed broken array use (asserted in tests). Renamed KindType enum.
llvm-svn: 178259
2013-03-28 18:38:43 +00:00
Tareq A. Siraj c2aa348dd0 Allow users to specify NULL like macros to be replaced
-use-nullptr only replaced macro named NULL and ignored any user defined
macros that behaved like NULL. This patch introduces -user-null-macros
command line option to let users specify their custom NULL like macros.

- Added a -user-null-macros command line option that takes a
  comma-separated list of user-defined macros to be replaced when using
  the -use-nullptr transform.
- Added documentation.
- Updated testcase to reflect current behavior.
- Whitespace fixes.

Reviewers: revane, klimek, gribozavr
llvm-svn: 178243
2013-03-28 16:06:59 +00:00
Tareq A. Siraj c7b27081d9 Test commit: Remove whitespace.
llvm-svn: 178241
2013-03-28 15:48:49 +00:00
Michael Gottesman 4b24921965 Revert "modularize - Fixed poor array usage."
This has broken buildbots for a few hours.

llvm-svn: 178223
2013-03-28 06:07:15 +00:00
John Thompson 3b1ee2b87f modularize - Updated futures comment.
llvm-svn: 178216
2013-03-28 02:46:25 +00:00
John Thompson 9663d8c46d modularize - Fixed poor array usage.
llvm-svn: 178214
2013-03-28 02:44:31 +00:00
David Blaikie c66c07d444 Fix a default on covered switch found by -Wcovered-switch-default
Introduced in r178207

llvm-svn: 178212
2013-03-28 02:30:37 +00:00
John Thompson 4e4d9b3abf modularize - revised to group duplicate symbols together in the error output.
llvm-svn: 178207
2013-03-28 01:20:19 +00:00
John Thompson ea6c8dbf71 Broke out header file list reading into separate function. Moved options to front. Removed some trailing spaces.
llvm-svn: 178182
2013-03-27 21:23:21 +00:00
John Thompson fd8ca38ad5 Added informational comment about using -x c++.
llvm-svn: 178172
2013-03-27 19:31:22 +00:00
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