<div dir="ltr">Hello Daniel,<br><br>This commit broke at least one of our builders:<br><a href="http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/234">http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/234</a><br><br>Please have a look at this?<br><br>Thanks<br><br>Galina<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 8, 2016 at 8:11 AM, Daniel Jasper via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: djasper<br>
Date: Tue Nov 8 10:11:33 2016<br>
New Revision: 286243<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=286243&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=286243&view=rev</a><br>
Log:<br>
[clang-format] Remove (SourceManager, FileID) variants<br>
<br>
In Format, remove the reformat() and clean() functions taking a SourceManager<br>
and a FileID. Keep the versions taking StringRef Code.<br>
<br>
- there was duplicated functionality<br>
- the FileID versions were harder to use<br>
- the clean() version is dead code anyways<br>
<br>
Patch by Krasimir Georgiev. Thank you.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/<wbr>Format/Format.h<br>
cfe/trunk/lib/Format/Format.<wbr>cpp<br>
cfe/trunk/lib/Index/<wbr>CommentToXML.cpp<br>
<br>
Modified: cfe/trunk/include/clang/<wbr>Format/Format.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=286243&r1=286242&r2=286243&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Format/Format.h?rev=<wbr>286243&r1=286242&r2=286243&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/<wbr>Format/Format.h (original)<br>
+++ cfe/trunk/include/clang/<wbr>Format/Format.h Tue Nov 8 10:11:33 2016<br>
@@ -794,7 +794,7 @@ llvm::Expected<tooling::<wbr>Replacements><br>
cleanupAroundReplacements(<wbr>StringRef Code, const tooling::Replacements &Replaces,<br>
const FormatStyle &Style);<br>
<br>
-/// \brief Reformats the given \p Ranges in the file \p ID.<br>
+/// \brief Reformats the given \p Ranges in \p Code.<br>
///<br>
/// Each range is extended on either end to its next bigger logic unit, i.e.<br>
/// everything that might influence its formatting or might be influenced by its<br>
@@ -806,31 +806,15 @@ cleanupAroundReplacements(<wbr>StringRef Code<br>
/// If ``IncompleteFormat`` is non-null, its value will be set to true if any<br>
/// of the affected ranges were not formatted due to a non-recoverable syntax<br>
/// error.<br>
-tooling::Replacements reformat(const FormatStyle &Style,<br>
- SourceManager &SourceMgr, FileID ID,<br>
- ArrayRef<CharSourceRange> Ranges,<br>
- bool *IncompleteFormat = nullptr);<br>
-<br>
-/// \brief Reformats the given \p Ranges in \p Code.<br>
-///<br>
-/// Otherwise identical to the reformat() function using a file ID.<br>
tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,<br>
ArrayRef<tooling::Range> Ranges,<br>
StringRef FileName = "<stdin>",<br>
bool *IncompleteFormat = nullptr);<br>
<br>
-/// \brief Clean up any erroneous/redundant code in the given \p Ranges in the<br>
-/// file \p ID.<br>
-///<br>
-/// Returns the ``Replacements`` that clean up all \p Ranges in the file \p ID.<br>
-tooling::Replacements cleanup(const FormatStyle &Style,<br>
- SourceManager &SourceMgr, FileID ID,<br>
- ArrayRef<CharSourceRange> Ranges);<br>
-<br>
/// \brief Clean up any erroneous/redundant code in the given \p Ranges in \p<br>
/// Code.<br>
///<br>
-/// Otherwise identical to the cleanup() function using a file ID.<br>
+/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.<br>
tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,<br>
ArrayRef<tooling::Range> Ranges,<br>
StringRef FileName = "<stdin>");<br>
<br>
Modified: cfe/trunk/lib/Format/Format.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=286243&r1=286242&r2=286243&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Format/<wbr>Format.cpp?rev=286243&r1=<wbr>286242&r2=286243&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Format/Format.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/Format/Format.<wbr>cpp Tue Nov 8 10:11:33 2016<br>
@@ -1719,18 +1719,6 @@ cleanupAroundReplacements(<wbr>StringRef Code<br>
return processReplacements(Cleanup, Code, NewReplaces, Style);<br>
}<br>
<br>
-tooling::Replacements reformat(const FormatStyle &Style, SourceManager &SM,<br>
- FileID ID, ArrayRef<CharSourceRange> Ranges,<br>
- bool *IncompleteFormat) {<br>
- FormatStyle Expanded = expandPresets(Style);<br>
- if (Expanded.DisableFormat)<br>
- return tooling::Replacements();<br>
-<br>
- Environment Env(SM, ID, Ranges);<br>
- Formatter Format(Env, Expanded, IncompleteFormat);<br>
- return Format.process();<br>
-}<br>
-<br>
tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,<br>
ArrayRef<tooling::Range> Ranges,<br>
StringRef FileName, bool *IncompleteFormat) {<br>
@@ -1760,13 +1748,6 @@ tooling::Replacements reformat(const For<br>
return Format.process();<br>
}<br>
<br>
-tooling::Replacements cleanup(const FormatStyle &Style, SourceManager &SM,<br>
- FileID ID, ArrayRef<CharSourceRange> Ranges) {<br>
- Environment Env(SM, ID, Ranges);<br>
- Cleaner Clean(Env, Style);<br>
- return Clean.process();<br>
-}<br>
-<br>
tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,<br>
ArrayRef<tooling::Range> Ranges,<br>
StringRef FileName) {<br>
<br>
Modified: cfe/trunk/lib/Index/<wbr>CommentToXML.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=286243&r1=286242&r2=286243&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Index/<wbr>CommentToXML.cpp?rev=286243&<wbr>r1=286242&r2=286243&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Index/<wbr>CommentToXML.cpp (original)<br>
+++ cfe/trunk/lib/Index/<wbr>CommentToXML.cpp Tue Nov 8 10:11:33 2016<br>
@@ -597,20 +597,21 @@ void CommentASTToXMLConverter::<wbr>formatTex<br>
<br>
// Formatter specific code.<br>
// Form a unique in memory buffer name.<br>
- SmallString<128> filename;<br>
- filename += "xmldecl";<br>
- filename += llvm::utostr(<wbr>FormatInMemoryUniqueId);<br>
- filename += ".xd";<br>
- FileID ID = FormatRewriterContext.<wbr>createInMemoryFile(filename, StringDecl);<br>
- SourceLocation Start = FormatRewriterContext.Sources.<wbr>getLocForStartOfFile(ID)<br>
- .getLocWithOffset(0);<br>
+ SmallString<128> Filename;<br>
+ Filename += "xmldecl";<br>
+ Filename += llvm::utostr(<wbr>FormatInMemoryUniqueId);<br>
+ Filename += ".xd";<br>
+ unsigned Offset = 0;<br>
unsigned Length = Declaration.size();<br>
<br>
- tooling::Replacements Replace = reformat(<br>
- format::getLLVMStyle(), FormatRewriterContext.Sources, ID,<br>
- CharSourceRange::getCharRange(<wbr>Start, Start.getLocWithOffset(Length)<wbr>));<br>
- applyAllReplacements(Replace, FormatRewriterContext.Rewrite)<wbr>;<br>
- Declaration = FormatRewriterContext.<wbr>getRewrittenText(ID);<br>
+ bool IncompleteFormat = false;<br>
+ tooling::Replacements Replaces =<br>
+ reformat(format::getLLVMStyle(<wbr>), StringDecl,<br>
+ tooling::Range(Offset, Length), Filename, &IncompleteFormat);<br>
+ auto FormattedStringDecl = applyAllReplacements(<wbr>StringDecl, Replaces);<br>
+ if (static_cast<bool>(<wbr>FormattedStringDecl)) {<br>
+ Declaration = *FormattedStringDecl;<br>
+ }<br>
}<br>
<br>
} // end unnamed namespace<br>
@@ -1159,4 +1160,3 @@ void CommentToXMLConverter::<wbr>convertComme<br>
FormatInMemoryUniqueId++);<br>
Converter.visit(FC);<br>
}<br>
-<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>