The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.
This should fix the reverted commit r188610 (buildbot failures on Windows).
llvm-svn: 188791
This reverts commit r188610.
Issue with the absolute include paths not found in the unit tests on the Windows
bots. Needs investigation.
llvm-svn: 188611
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.
llvm-svn: 188610
Another attempt to commit r187204 after windows related problems has
been fixed. Note that changes to this patch reflect the current behavior
of cpp11-migrate.
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 header file
- Name of the source file that included the header file
- Transform ID that generated the replacement
- Offset
- Length
- Replacement text
Any tool reading these replacements should read them using the
HeaderChangeDocument struct.
Differential Revision: http://llvm-reviews.chandlerc.com/D1369
llvm-svn: 188274
This fixes a problem when the path separator in the include/exclude
directory is different (e.g. "\" vs. "/") from the path separator in
the file path we are modifying.
Differential Revision: http://llvm-reviews.chandlerc.com/D1326
llvm-svn: 188094
Committing r187204 with fixes for darwin. Note that one of the lit tests are
disabled on windows due to a bug in writing header replacements to file.
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.
llvm-svn: 187428
This change add a new option command line option -for-compilers that allows the
user to enable multiple transforms automatically.
Another difference is that now all transforms are enabled by default.
llvm-svn: 187360
This is the first version of a possible clang-tidy architecture. The
purpose of clang-tidy is to detect errors in adhering to common coding
patterns, e.g. described in the LLVM Coding Standards.
This is still heavily in flux.
Review: http://llvm-reviews.chandlerc.com/D884
llvm-svn: 187345
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
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
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
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
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
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
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
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
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
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
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
Refactored how global options are passed to Transforms to avoid widespread
changes every time a new global option is added.
Tests updated to reflect new interface.
llvm-svn: 183443
Performance timers captured in each transform for all files they process are now collected and arranged per source file in preparation for writing to disk.
This revision is the last piece of the initial implementation of performance timer capturing.
llvm-svn: 183274
Using updated form of newFrontendActionFactory(), Transforms now automatically
measure, if requested, how long it takes to apply a MatchFinder to a source
file. Other per-transform overhead, e.g. applying replacements, is not
currently measured. This behaviour is disabled for now and soon will be
connected to a new command line arg.
llvm-svn: 182942
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
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
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
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
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