Add a new libclang completion API to get brief documentation comment that is
attached to a declaration in the completion string.
Since extracting comments isn't free, a new code completion option is
introduced.
A new code completion option that enables including brief comments
into CodeCompletionString should be a, err, code completion option.
But because ASTUnit caches global declarations during parsing before
even completion consumer is created, the option is duplicated as a
translation unit option (in both libclang and ASTUnit, like the option
to cache code completion results).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159539 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/RawCommentList.cpp b/lib/AST/RawCommentList.cpp
index b2b0c43..e7b86df 100644
--- a/lib/AST/RawCommentList.cpp
+++ b/lib/AST/RawCommentList.cpp
@@ -130,7 +130,7 @@
return StringRef(BufferStart + BeginOffset, Length);
}
-StringRef RawComment::extractBriefText(const ASTContext &Context) const {
+const char *RawComment::extractBriefText(const ASTContext &Context) const {
// Make sure that RawText is valid.
getRawText(Context.getSourceManager());
@@ -142,10 +142,10 @@
const unsigned BriefTextLength = Result.size();
char *BriefTextPtr = new (Context) char[BriefTextLength + 1];
memcpy(BriefTextPtr, Result.c_str(), BriefTextLength + 1);
- BriefText = StringRef(BriefTextPtr, BriefTextLength);
+ BriefText = BriefTextPtr;
BriefTextValid = true;
- return BriefText;
+ return BriefTextPtr;
}
namespace {