aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Index/CommentToXML.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-11-08 16:11:33 +0000
committerDaniel Jasper <djasper@google.com>2016-11-08 16:11:33 +0000
commit528d682ff6f5180360b978a93ea0d49ebb758d5c (patch)
tree584641b67d74d2b77a032a0274717b91b4e0d72c /clang/lib/Index/CommentToXML.cpp
parent73c3a36b9f5036f4e497035193765c465d1b9ca2 (diff)
downloadllvm-528d682ff6f5180360b978a93ea0d49ebb758d5c.zip
llvm-528d682ff6f5180360b978a93ea0d49ebb758d5c.tar.gz
llvm-528d682ff6f5180360b978a93ea0d49ebb758d5c.tar.bz2
[clang-format] Remove (SourceManager, FileID) variants
In Format, remove the reformat() and clean() functions taking a SourceManager and a FileID. Keep the versions taking StringRef Code. - there was duplicated functionality - the FileID versions were harder to use - the clean() version is dead code anyways Patch by Krasimir Georgiev. Thank you. llvm-svn: 286243
Diffstat (limited to 'clang/lib/Index/CommentToXML.cpp')
-rw-r--r--clang/lib/Index/CommentToXML.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/clang/lib/Index/CommentToXML.cpp b/clang/lib/Index/CommentToXML.cpp
index c4beef2..4210b89 100644
--- a/clang/lib/Index/CommentToXML.cpp
+++ b/clang/lib/Index/CommentToXML.cpp
@@ -597,20 +597,21 @@ void CommentASTToXMLConverter::formatTextOfDeclaration(
// Formatter specific code.
// Form a unique in memory buffer name.
- SmallString<128> filename;
- filename += "xmldecl";
- filename += llvm::utostr(FormatInMemoryUniqueId);
- filename += ".xd";
- FileID ID = FormatRewriterContext.createInMemoryFile(filename, StringDecl);
- SourceLocation Start = FormatRewriterContext.Sources.getLocForStartOfFile(ID)
- .getLocWithOffset(0);
+ SmallString<128> Filename;
+ Filename += "xmldecl";
+ Filename += llvm::utostr(FormatInMemoryUniqueId);
+ Filename += ".xd";
+ unsigned Offset = 0;
unsigned Length = Declaration.size();
- tooling::Replacements Replace = reformat(
- format::getLLVMStyle(), FormatRewriterContext.Sources, ID,
- CharSourceRange::getCharRange(Start, Start.getLocWithOffset(Length)));
- applyAllReplacements(Replace, FormatRewriterContext.Rewrite);
- Declaration = FormatRewriterContext.getRewrittenText(ID);
+ bool IncompleteFormat = false;
+ tooling::Replacements Replaces =
+ reformat(format::getLLVMStyle(), StringDecl,
+ tooling::Range(Offset, Length), Filename, &IncompleteFormat);
+ auto FormattedStringDecl = applyAllReplacements(StringDecl, Replaces);
+ if (static_cast<bool>(FormattedStringDecl)) {
+ Declaration = *FormattedStringDecl;
+ }
}
} // end unnamed namespace
@@ -1159,4 +1160,3 @@ void CommentToXMLConverter::convertCommentToXML(const FullComment *FC,
FormatInMemoryUniqueId++);
Converter.visit(FC);
}
-