]> granicus.if.org Git - clang/commitdiff
[clang][ASTContext] Call setAttached for comments attached to a declaration
authorJan Korous <jkorous@apple.com>
Mon, 13 May 2019 17:52:09 +0000 (17:52 +0000)
committerJan Korous <jkorous@apple.com>
Mon, 13 May 2019 17:52:09 +0000 (17:52 +0000)
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

lib/AST/ASTContext.cpp

index a2de53ca0c11c42d12181180cc9f6cb072a59002..814f914ec7107f9d1467f1eb8a74b914f01b6839 100644 (file)
@@ -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;
 }