Commit Graph

237 Commits

Author SHA1 Message Date
Tareq A. Siraj 3a2476a342 cpp11-migrate: Write header replacements to disk
Header replacements are now written to disk in YAML format for an external tool
to merge. A unique file will be created in the same directory as the header
with all replacements that came from a source file that included the header
file. The YAML file will have:
 - Name of the file
 - Transform ID that generated the replacement
 - Offset
 - Length
 - Replacement text

Any tool reading these replacements should read them using the TransformDocument
struct.

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

llvm-svn: 187204
2013-07-26 14:11:45 +00:00
Edwin Vane 5466b7cbbb cpp11-migrate: Tweak lit tests to avoid false negatives
Recent failures on a freebsd buildbot indicated a weakness in the
Reformatting.cpp lit test. Tweaking the test to avoid false negatives and
hopefully make the buildbot happy.

llvm-svn: 187153
2013-07-25 20:20:20 +00:00
Ariel J. Bernal a9df759af6 Fix doxygen warnings
Doxygen doesn't recognize <blockquote> html tags. Added support for <blockquote>
and Markdown was introduce with doxygen 1.8.0. This patch replaces blockquote
with \par for compatibility with previous versions.

llvm-svn: 187067
2013-07-24 19:14:57 +00:00
Guillaume Papin 91b568a31f cpp11-migrate: Fix build break on Windows introduced in r187041.
r187041 changed the way the transform are created and the order the transformed
are applied "may" have changed as well (no specific constraints exist on the
order). This produced a test failure on the Windows buildbot.

Now the test use -std=c++11, so 'nullptr' is defined and the test is not anymore
dependent on the order the transforms are applied.

llvm-svn: 187048
2013-07-24 15:35:24 +00:00
Guillaume Papin ebde78c4c6 cpp11-migrate: Register the transforms automatically using llvm::Registry
With this change each transform now register a factory. The factories are
registered using an llvm::Registry which makes them available globally.

llvm-svn: 187041
2013-07-24 14:24:33 +00:00
Guillaume Papin 78bfe2b12e test commit
llvm-svn: 187038
2013-07-24 13:58:28 +00:00
Ariel J. Bernal 3beac8b322 Fix doxygen warnings
It seems that doxygen fails to find overloaded methods when the parameters are
not in sync with the method declaration.
Added the fully-qualifed type to the parameters method definition although it's
not necessary since the using directive is in effect.

llvm-svn: 186948
2013-07-23 15:52:07 +00:00
Edwin Vane 571a64159b cp11-migrate: Integration with LibFormat
Adding a feature to optionally reformat code changed by the migrator. Like
LibFormat, can choose between built-in styles (LLVM, Mozilla, Google, Chromium)
or use a YAML-format config file.

Now with no dependency on iostream by the Reformatting.cpp LIT test.

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 186938
2013-07-23 12:50:03 +00:00
Michael Gottesman 29e449f222 Revert "cp11-migrate: Integration with LibFormat"
This reverts commit r186866.

This breaks the build and the original author Guillaume Papin
<guillaume.papin@epitech.eu> asked me to revert so he could look at it more with
revane.

llvm-svn: 186873
2013-07-22 21:03:56 +00:00
Edwin Vane 55b0be72d1 cp11-migrate: Integration with LibFormat
Adding a feature to optionally reformat code changed by the migrator. Like
LibFormat, can choose between built-in styles (LLVM, Mozilla, Google, Chromium)
or use a YAML-format config file.

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 186866
2013-07-22 20:26:29 +00:00
Edwin Vane 40be0dc261 cpp11-migrate: Make a VirtualFilesHelper class for the unit tests.
This change makes it easier for new unit tests to create virtual files.

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 186842
2013-07-22 16:36:58 +00:00
John Thompson b809dfcf3a Fixed some formatting issues with clang-format to get a baseline.
llvm-svn: 186675
2013-07-19 14:19:31 +00:00
Edwin Vane 0ffd0a9e54 cpp11-migrate: Use test fixture in preparation for more tests
Existing tests are not changed but the set-up work is moved into a fixture
to simplify forthcoming new tests.

llvm-svn: 186575
2013-07-18 11:59:08 +00:00
Rafael Espindola 93c49dcf42 Update for llvm API change.
llvm-svn: 186449
2013-07-16 19:44:28 +00:00
Ariel J. Bernal 601858aed7 Fix UseAuto not transforming iterator when non-fully qualifiers are used and
using inline namespaces is specified.

UseAuto used to fail to transform iterators when using inline namespaces and
non-fully qualified types, relying on a using directive previously declared.
- This fix uses the already define isFromStdNamespace matcher.
- Fixed tests and added a new test using inline namespaces.
- Added CustomMatchers to reuse common matchers among transforms.

llvm-svn: 186327
2013-07-15 15:37:05 +00:00
Tareq A. Siraj e0a03c3c64 cpp11-migrate: FileOverrides/Transform refactoring.
This commit include the following changes:
 - SourceOverrides is now a class
   - it simplifies the usage for the Transform class, since now the
     replacements can be applied directly to the file overrides with
     SourceOverrides::applyReplacements().
   - it contains a method applyRewrites() which was previously named
     collectResults() in Transform.cpp. The method has been "optimized"
     a bit to re-use the allocated buffer (std::string::clear() is called).
   - since the class has some logic it's now unit tested
 - Now FileOverrides is a class (not a std::map typedef) and store pointers
   to the SourceOverrides. The reason is that the SourceOverrides can't be
   copied anymore (which was already something to avoid since it's can be a
   quite large object).

Author: Guillaume Papin <guillaume.papin@epitech.eu>

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

llvm-svn: 186161
2013-07-12 14:36:20 +00:00
Edwin Vane af1e77eec3 cpp11-migrate: Add missing file headers in unit tests
Differential: http://llvm-reviews.chandlerc.com/D1124
Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 186093
2013-07-11 15:54:06 +00:00
Tareq A. Siraj 9c7750eeae Generate a unique filename for a given header
This patch is in preparation for writing the header replacement to disk.
Added getUniqueHeaderName() that generates a unique header filename in
the same directory as the header file.

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

llvm-svn: 186007
2013-07-10 16:09:36 +00:00
Edwin Vane 86142e02df cpp11-migrate: Fixes for r185811
Some changes to r185811 broke certain build configurations. These changes should
fix them.

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 185814
2013-07-08 12:49:04 +00:00
Edwin Vane aae33677f5 cpp11-migrate: Tidying up
* Some file headers were missing for files in Core/
* Some headers were included but not necessary
* CMakeLists.txt was linking in LLVMSupport even though CMakeLists in subdirs
  were linking it in too.
* StringRefisation of constructors of types in FileOverrides.h
* Other misc cleanups

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 185811
2013-07-08 12:17:37 +00:00
Rafael Espindola 43318aa17c Use llvm::sys::fs::createTemporaryFile.
llvm-svn: 185718
2013-07-05 20:01:03 +00:00
Edwin Vane 17b31f3d43 cpp11-migrate: Minor command-line fixes and improvements
* all transforms are in the same category
* all transforms' options are in the same category
* display the CommonOptionParser extra-help (which describe in more details the
  compilation database stuff)
* add EXAMPLES section

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 185660
2013-07-04 17:49:59 +00:00
Rafael Espindola b55bb2fccf Add 'not' to commands that are expected to fail.
llvm-svn: 185654
2013-07-04 16:28:28 +00:00
Edwin Vane 5ee6110817 cpp11-migrate: Add Replace-AutoPtr Transform
Add a new transform to replace uses of 'std::auto_ptr' by 'std::unique_ptr'.
Copy-ctor and assign-operator are wrapped with a call to 'std::move()'.

Note that until header modification is ready it is not that useful, that's why
it's marked as (EXPERIMENTAL) in the command line description and a "Known
Limitations" section is present in the transform documentation.

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 185535
2013-07-03 13:21:24 +00:00
John Thompson 161381e120 Ran clang-format on Modularize.cpp to get a baseline for future changes.
llvm-svn: 185092
2013-06-27 18:52:23 +00:00
Rafael Espindola b6d9c0001a Don't use PathV1.h in IncludeExcludeTest.cpp.
llvm-svn: 184959
2013-06-26 16:20:55 +00:00
Rafael Espindola b8db1cd13e Don't use PathV1.h in TransformTest.cpp.
llvm-svn: 184958
2013-06-26 15:48:36 +00:00
Rafael Espindola a3d1c02356 Don't use PathV1.h in PerfSupport.cpp.
llvm-svn: 184956
2013-06-26 15:22:42 +00:00
Edwin Vane 51a55d9964 cpp11-migrate: Really fixing doxygen warning
Last attempt at this fix was bogus.

llvm-svn: 184869
2013-06-25 19:01:18 +00:00
John Thompson 26b567ae6a Fixed typo.
llvm-svn: 184347
2013-06-19 20:35:50 +00:00
Edwin Vane e85ba57d6a cpp11-migrate: Fixing doxygen warning
llvm-svn: 184326
2013-06-19 17:38:56 +00:00
Edwin Vane b31df59109 cpp11-migrate: Fix parsing of '.' for header include/excludes
sys::fs::make_absolute was turning '.' into '<path>/.' which broke prefix
comparison logic. Stripping these extra chars fixes the problem.

llvm-svn: 184322
2013-06-19 17:17:31 +00:00
Manuel Klimek 1a3dc8576e Fix a remove-cstr-calls test that fails checking of the produced code.
llvm-svn: 184314
2013-06-19 15:43:40 +00:00
NAKAMURA Takumi cb873b1fc9 Prune "\param InitialState" since it has not been introduced. [-Wdocumentation]
llvm-svn: 184285
2013-06-19 06:58:29 +00:00
John Thompson 54c83695f7 Fixed a typo and naming convention.
llvm-svn: 184221
2013-06-18 19:56:05 +00:00
Edwin Vane ba6b32d1ce cpp11-migrate: Transforms honour header modification flag
Transforms will now make changes to headers if header modifications have been
enabled.

FIXME: Only UseNullptr contains a cursory header modification test. Other
transforms should have them too.

llvm-svn: 184197
2013-06-18 15:44:58 +00:00
Edwin Vane 62c013db6c cpp11-migrate: Transform now responsible for applying replacements
To make it possible for replacements made to headers as part of transforming
one translation unit to not be visible to the transform of other translation
units, Transform now handles replacement application as part of its
end-of-source handling. Several things were simplified as a result:

- The duplicated code in every transform for applying replacements is now gone
  and replaced with one location in Transform.
- RefactoringTool is no longer used since Transform houses the Replacements
  structure.
- RewriterContainer is now a private implementation detail of Transform (also
  renamed to RewriterManager since its behaviour is slightly different now with
  respect to lifetime of objects).
- There's now no distinction between input and output file state.

Misc notes:

- Interface changes reflected in unit tests.
- Replacements for files other than the main file are assumed to be for headers
  and stored as such.

llvm-svn: 184194
2013-06-18 15:31:01 +00:00
Edwin Vane 4e11abb59b cpp11-migrate: Transform now responsible for file content overriding
To better support per-translation unit replacements, any real work is being
moved out of ActionFactory and into Transform. In this revision, that means
file override application.

For simplification, Transform no longer inherits from SourceFileCallbacks.
TransformTest required updating as a result.

llvm-svn: 184098
2013-06-17 18:18:15 +00:00
Rafael Espindola f7d00ba592 Revert "sys::Path::GetCurrentDirectory has been removed. Use sys::fs::current_path."
This reverts commit r184004.

This test has some dependency on the behavior of the old function on windows. I
added it back to llvm for now.

llvm-svn: 184010
2013-06-14 21:44:06 +00:00
Rafael Espindola 584b0706b2 sys::Path::GetCurrentDirectory has been removed. Use sys::fs::current_path.
llvm-svn: 184004
2013-06-14 20:48:30 +00:00
Reid Kleckner e34930bf6f Add a dependency on LLVM's option library for clang-tools-extra
r183989 added a dependency on LLVMOption in clangFrontend.

llvm-svn: 183990
2013-06-14 17:34:04 +00:00
Rafael Espindola 5492d613f5 Force c++98 so this works on windows where c++11 is the default.
llvm-svn: 183983
2013-06-14 16:09:37 +00:00
Edwin Vane 8d28646db6 cpp11-migrate: Fixing section markup
Adhering to LLVM's ReST style for section markup.

llvm-svn: 183981
2013-06-14 15:14:20 +00:00
Sylvestre Ledru cda552b1ba Also install cpp11-migrate when built with cmake. Fixes bug #16296
llvm-svn: 183976
2013-06-14 11:25:50 +00:00
Edwin Vane 230ecb2422 cpp11-migrate: const-correcting IncludeExcludeInfo
isFileIncluded() needed to be marked const.

llvm-svn: 183918
2013-06-13 17:19:37 +00:00
Edwin Vane 90706dd424 cpp11-migrate: Add headers to file override information
File override structures now contain per-source overrides for headers.

For now, modified headers are written to disk when the Migrator is done.
This is only temporary behaviour since we can expect headers to be
changed by migrating multiple source files. The changes need to be
merged after all migrations are complete.

llvm-svn: 183917
2013-06-13 17:17:32 +00:00
Edwin Vane e0a7d9ceff cpp11-migrate: Replace file override container
A more flexible container for storing overrides is required for headers. Before
a source goes through the transform pipeline, any headers it references will be
in their original state and unaffected by transforms applied to other sources.
Therefore overrides for headers need to be kept separate for each source file.

This patch doesn't introduce support for storing header overrides yet. It only
replaces the existing structure and makes any necessary changes to support it.

llvm-svn: 183910
2013-06-13 16:00:46 +00:00
Edwin Vane 59175a1523 cpp11-migrate: Decluttering Transform.h
Moving RewriteContainer's constructor impl to Transform.cpp to reduce clutter.
More things will soon be added to this header.

llvm-svn: 183856
2013-06-12 19:58:21 +00:00
Edwin Vane a6bbcdd707 cpp11-migrate: New mechanism for overriding file contents
Next step toward supporting migrating headers. Instead of using ClangTool's
ability to override all files at once, use a custom FrontendAction and override
only the source (and eventually headers) the action is about to parse.

Use of newFrontendActionFactory() is replaced with a new factory maker provided
by Transform.

llvm-svn: 183855
2013-06-12 19:52:13 +00:00
Rafael Espindola 9c0a584c35 More build fixes.
llvm-svn: 183785
2013-06-11 20:24:32 +00:00