[clang][ASTContext] Call setAttached for comments attached to a declaration
This is a bug affecting performance when compiling with -Wdocumentation.
In Sema::ActOnDocumentable we're checking whether there are any comments unattached to declaration at the end of comment list whenever we encounter new documentable declaration.
Since this property of RawComment was never set we were trying to find comments every time and that involves at least a couple expensive SourceLocation decompositions.
Differential Revision: https://reviews.llvm.org/D61538
llvm-svn: 360607
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a2de53c..814f914 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -255,6 +255,7 @@
SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second)
== SourceMgr.getLineNumber(CommentBeginDecomp.first,
CommentBeginDecomp.second)) {
+ (**Comment).setAttached();
return *Comment;
}
}
@@ -296,6 +297,7 @@
if (Text.find_first_of(";{}#@") != StringRef::npos)
return nullptr;
+ (**Comment).setAttached();
return *Comment;
}