summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp')
-rw-r--r--contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp45
1 files changed, 13 insertions, 32 deletions
diff --git a/contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp b/contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp
index c4beef2..ee066cc 100644
--- a/contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp
+++ b/contrib/llvm/tools/clang/lib/Index/CommentToXML.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include "clang/Index/CommentToXML.h"
-#include "SimpleFormatContext.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Comment.h"
@@ -531,12 +530,8 @@ public:
CommentASTToXMLConverter(const FullComment *FC,
SmallVectorImpl<char> &Str,
const CommandTraits &Traits,
- const SourceManager &SM,
- SimpleFormatContext &SFC,
- unsigned FUID) :
- FC(FC), Result(Str), Traits(Traits), SM(SM),
- FormatRewriterContext(SFC),
- FormatInMemoryUniqueId(FUID) { }
+ const SourceManager &SM) :
+ FC(FC), Result(Str), Traits(Traits), SM(SM) { }
// Inline content.
void visitTextComment(const TextComment *C);
@@ -574,8 +569,6 @@ private:
const CommandTraits &Traits;
const SourceManager &SM;
- SimpleFormatContext &FormatRewriterContext;
- unsigned FormatInMemoryUniqueId;
};
void getSourceTextOfDeclaration(const DeclInfo *ThisDecl,
@@ -596,21 +589,17 @@ void CommentASTToXMLConverter::formatTextOfDeclaration(
StringRef StringDecl(Declaration.c_str(), Declaration.size());
// 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);
+ 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), "xmldecl.xd", &IncompleteFormat);
+ auto FormattedStringDecl = applyAllReplacements(StringDecl, Replaces);
+ if (static_cast<bool>(FormattedStringDecl)) {
+ Declaration = *FormattedStringDecl;
+ }
}
} // end unnamed namespace
@@ -1126,7 +1115,7 @@ void CommentASTToXMLConverter::appendToResultWithCDATAEscaping(StringRef S) {
Result << "]]>";
}
-CommentToXMLConverter::CommentToXMLConverter() : FormatInMemoryUniqueId(0) {}
+CommentToXMLConverter::CommentToXMLConverter() {}
CommentToXMLConverter::~CommentToXMLConverter() {}
void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC,
@@ -1148,15 +1137,7 @@ void CommentToXMLConverter::convertHTMLTagNodeToText(
void CommentToXMLConverter::convertCommentToXML(const FullComment *FC,
SmallVectorImpl<char> &XML,
const ASTContext &Context) {
- if (!FormatContext || (FormatInMemoryUniqueId % 1000) == 0) {
- // Create a new format context, or re-create it after some number of
- // iterations, so the buffers don't grow too large.
- FormatContext.reset(new SimpleFormatContext(Context.getLangOpts()));
- }
-
CommentASTToXMLConverter Converter(FC, XML, Context.getCommentCommandTraits(),
- Context.getSourceManager(), *FormatContext,
- FormatInMemoryUniqueId++);
+ Context.getSourceManager());
Converter.visit(FC);
}
-
OpenPOWER on IntegriCloud