summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp19
-rw-r--r--clang/lib/AST/RawCommentList.cpp15
2 files changed, 17 insertions, 17 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 99c5ff6d567..12f1d4de039 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -72,7 +72,7 @@ const RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
if (isa<ParmVarDecl>(D))
return NULL;
- ArrayRef<RawComment> RawComments = Comments.getComments();
+ ArrayRef<RawComment *> RawComments = Comments.getComments();
// If there are no comments anywhere, we won't find anything.
if (RawComments.empty())
@@ -85,10 +85,11 @@ const RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
return NULL;
// Find the comment that occurs just after this declaration.
- ArrayRef<RawComment>::iterator Comment
+ RawComment CommentAtDeclLoc(SourceMgr, SourceRange(DeclLoc));
+ ArrayRef<RawComment *>::iterator Comment
= std::lower_bound(RawComments.begin(),
RawComments.end(),
- RawComment(SourceMgr, SourceRange(DeclLoc)),
+ &CommentAtDeclLoc,
BeforeThanCompare<RawComment>(SourceMgr));
// Decompose the location for the declaration and find the beginning of the
@@ -97,17 +98,17 @@ const RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
// First check whether we have a trailing comment.
if (Comment != RawComments.end() &&
- Comment->isDocumentation() && Comment->isTrailingComment() &&
+ (*Comment)->isDocumentation() && (*Comment)->isTrailingComment() &&
!isa<TagDecl>(D) && !isa<NamespaceDecl>(D)) {
std::pair<FileID, unsigned> CommentBeginDecomp
- = SourceMgr.getDecomposedLoc(Comment->getSourceRange().getBegin());
+ = SourceMgr.getDecomposedLoc((*Comment)->getSourceRange().getBegin());
// Check that Doxygen trailing comment comes after the declaration, starts
// on the same line and in the same file as the declaration.
if (DeclLocDecomp.first == CommentBeginDecomp.first &&
SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second)
== SourceMgr.getLineNumber(CommentBeginDecomp.first,
CommentBeginDecomp.second)) {
- return &*Comment;
+ return *Comment;
}
}
@@ -118,12 +119,12 @@ const RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
--Comment;
// Check that we actually have a non-member Doxygen comment.
- if (!Comment->isDocumentation() || Comment->isTrailingComment())
+ if (!(*Comment)->isDocumentation() || (*Comment)->isTrailingComment())
return NULL;
// Decompose the end of the comment.
std::pair<FileID, unsigned> CommentEndDecomp
- = SourceMgr.getDecomposedLoc(Comment->getSourceRange().getEnd());
+ = SourceMgr.getDecomposedLoc((*Comment)->getSourceRange().getEnd());
// If the comment and the declaration aren't in the same file, then they
// aren't related.
@@ -146,7 +147,7 @@ const RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
if (Text.find_first_of(",;{}#") != StringRef::npos)
return NULL;
- return &*Comment;
+ return *Comment;
}
const RawComment *ASTContext::getRawCommentForDecl(const Decl *D) const {
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index 791215103f0..d67eb0822f2 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -176,14 +176,15 @@ bool onlyWhitespaceBetweenComments(SourceManager &SM,
}
} // unnamed namespace
-void RawCommentList::addComment(const RawComment &RC) {
+void RawCommentList::addComment(const RawComment &RC,
+ llvm::BumpPtrAllocator &Allocator) {
if (RC.isInvalid())
return;
// Check if the comments are not in source order.
while (!Comments.empty() &&
!SourceMgr.isBeforeInTranslationUnit(
- Comments.back().getSourceRange().getBegin(),
+ Comments.back()->getSourceRange().getBegin(),
RC.getSourceRange().getBegin())) {
// If they are, just pop a few last comments that don't fit.
// This happens if an \#include directive contains comments.
@@ -204,12 +205,12 @@ void RawCommentList::addComment(const RawComment &RC) {
// If this is the first Doxygen comment, save it (because there isn't
// anything to merge it with).
if (Comments.empty()) {
- Comments.push_back(RC);
+ Comments.push_back(new (Allocator) RawComment(RC));
OnlyWhitespaceSeen = true;
return;
}
- const RawComment &C1 = Comments.back();
+ const RawComment &C1 = *Comments.back();
const RawComment &C2 = RC;
// Merge comments only if there is only whitespace between them.
@@ -221,11 +222,9 @@ void RawCommentList::addComment(const RawComment &RC) {
C1.getEndLine(SourceMgr) + 1 >= C2.getBeginLine(SourceMgr))) {
SourceRange MergedRange(C1.getSourceRange().getBegin(),
C2.getSourceRange().getEnd());
- RawComment Merged(SourceMgr, MergedRange, true);
- Comments.pop_back();
- Comments.push_back(Merged);
+ *Comments.back() = RawComment(SourceMgr, MergedRange, true);
} else
- Comments.push_back(RC);
+ Comments.push_back(new (Allocator) RawComment(RC));
OnlyWhitespaceSeen = true;
}
OpenPOWER on IntegriCloud