From: Jan Korous Date: Mon, 13 May 2019 17:52:09 +0000 (+0000) Subject: [clang][ASTContext] Call setAttached for comments attached to a declaration X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=31f09da997ff53574df752319dcd14b935677148;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360607 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a2de53ca0c..814f914ec7 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -255,6 +255,7 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) == SourceMgr.getLineNumber(CommentBeginDecomp.first, CommentBeginDecomp.second)) { + (**Comment).setAttached(); return *Comment; } } @@ -296,6 +297,7 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { if (Text.find_first_of(";{}#@") != StringRef::npos) return nullptr; + (**Comment).setAttached(); return *Comment; }