diff options
author | Brad King <brad.king@kitware.com> | 2016-05-06 18:19:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-06 18:25:55 (GMT) |
commit | 64b5520346c75ec479042a114390a0bf71909723 (patch) | |
tree | bea1373e84594ba036fe50eea3eab86375d63aa6 /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 73601ff831faa80a188e5997ee048b6986b00a5c (diff) | |
download | CMake-64b5520346c75ec479042a114390a0bf71909723.zip CMake-64b5520346c75ec479042a114390a0bf71909723.tar.gz CMake-64b5520346c75ec479042a114390a0bf71909723.tar.bz2 |
Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.
Find blocks of the form
os <<
"...\n"
"...\n"
;
using the command
$ git ls-files -z -- Source |
egrep -v -z '^Source/kwsys/' |
xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
'<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'
Find blocks of the form
os << "...\n"
<< "...\n"
<< "...\n";
using the command
$ git ls-files -z -- Source |
egrep -v -z '^Source/kwsys/' |
xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
'<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'
Surround such blocks with the pair
/* clang-format off */
...
/* clang-format on */
in order to protect them from update by clang-format. Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b4bdb2a..65c23ca 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3434,6 +3434,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); + /* clang-format off */ fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Deployment" @@ -3469,6 +3470,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() "\t\t</ScreenResolutions>\n" "\t</App>\n" "</Deployment>\n"; + /* clang-format on */ std::string sourceFile = this->ConvertPath(manifestFile, false); this->ConvertToWindowsSlash(sourceFile); @@ -3518,6 +3520,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81() cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); + /* clang-format off */ fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\"" @@ -3561,6 +3564,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81() "\t\t</Application>\n" "\t</Applications>\n" "</Package>\n"; + /* clang-format on */ this->WriteCommonMissingFiles(manifestFile); } @@ -3579,6 +3583,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80() cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); + /* clang-format off */ fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\">\n" @@ -3614,6 +3619,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80() "\t\t</Application>\n" "\t</Applications>\n" "</Package>\n"; + /* clang-format on */ this->WriteCommonMissingFiles(manifestFile); } @@ -3632,6 +3638,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81() cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); + /* clang-format off */ fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\"" @@ -3672,6 +3679,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81() "\t\t</Application>\n" "\t</Applications>\n" "</Package>\n"; + /* clang-format on */ this->WriteCommonMissingFiles(manifestFile); } @@ -3690,6 +3698,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0() cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); + /* clang-format off */ fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Package\n\t" @@ -3731,6 +3740,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0() "\t\t</Application>\n" "\t</Applications>\n" "</Package>\n"; + /* clang-format on */ this->WriteCommonMissingFiles(manifestFile); } |