From: Dmitri Gribenko Date: Wed, 27 Jun 2012 23:43:37 +0000 (+0000) Subject: Attaching documentation comments to declarations: don't attach a comment to a declara... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bdb58a7835a9a90dd9b9791fccf269cbc1dcef3;p=clang Attaching documentation comments to declarations: don't attach a comment to a declaration if there is a preprocessor directive between them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159305 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index ca631736d9..9fb2dc1a94 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -134,8 +134,9 @@ const RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { StringRef Text(Buffer + CommentEndDecomp.second, DeclLocDecomp.second - CommentEndDecomp.second); - // There should be no other declarations between comment and declaration. - if (Text.find_first_of(",;{}") != StringRef::npos) + // There should be no other declarations or preprocessor directives between + // comment and declaration. + if (Text.find_first_of(",;{}#") != StringRef::npos) return NULL; return &*Comment; diff --git a/test/Index/annotate-comments.cpp b/test/Index/annotate-comments.cpp index 64d1c983bc..cb0630b739 100644 --- a/test/Index/annotate-comments.cpp +++ b/test/Index/annotate-comments.cpp @@ -194,6 +194,10 @@ void isdoxy44(void); /// Ggg. IS_DOXYGEN_END void isdoxy45(void); +/// IS_DOXYGEN_NOT_ATTACHED +#define FOO +void notdoxy46(void); + #endif // RUN: rm -rf %t