r179180 - Add an option to parse all comments as documentation comments

jahanian fjahanian at apple.com
Wed Apr 10 10:51:14 PDT 2013


On Apr 10, 2013, at 8:35 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> Author: gribozavr
> Date: Wed Apr 10 10:35:17 2013
> New Revision: 179180
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179180&view=rev
> Log:
> Add an option to parse all comments as documentation comments
> 
> Patch by Amin Shali.
> 
> Modified:
>    cfe/trunk/docs/UsersManual.rst
>    cfe/trunk/include/clang/AST/RawCommentList.h
>    cfe/trunk/include/clang/Basic/CommentOptions.h
>    cfe/trunk/include/clang/Driver/Options.td
>    cfe/trunk/lib/AST/ASTContext.cpp
>    cfe/trunk/lib/AST/RawCommentList.cpp
>    cfe/trunk/lib/Driver/Tools.cpp
>    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>    cfe/trunk/lib/Sema/Sema.cpp
>    cfe/trunk/lib/Serialization/ASTReader.cpp
>    cfe/trunk/lib/Serialization/ASTWriter.cpp
> 
> Modified: cfe/trunk/docs/UsersManual.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=179180&r1=179179&r2=179180&view=diff
> ==============================================================================
> --- cfe/trunk/docs/UsersManual.rst (original)
> +++ cfe/trunk/docs/UsersManual.rst Wed Apr 10 10:35:17 2013
> @@ -1005,6 +1005,19 @@ below. If multiple flags are present, th
> 
>   Generate complete debug info.
> 
> +Comment Parsing Options
> +--------------------------
> +
> +Clang parses Doxygen and non-Doxygen style documentation comments and attaches
> +them to the appropriate declaration nodes.  By default, it only parses
> +Doxygen-style comments and ignores ordinary comments starting with ``//`` and
> +``/*``.
> +
> +.. option:: -fparse-all-comments
> +
> +  Parse all comments as documentation comments (including ordinary comments
> +  starting with ``//`` and ``/*``).
> +
> .. _c:
> 
> C Language Features
> 
> Modified: cfe/trunk/include/clang/AST/RawCommentList.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=179180&r1=179179&r2=179180&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/RawCommentList.h (original)
> +++ cfe/trunk/include/clang/AST/RawCommentList.h Wed Apr 10 10:35:17 2013
> @@ -10,6 +10,7 @@
> #ifndef LLVM_CLANG_AST_RAW_COMMENT_LIST_H
> #define LLVM_CLANG_AST_RAW_COMMENT_LIST_H
> 
> +#include "clang/Basic/CommentOptions.h"
> #include "clang/Basic/SourceManager.h"
> #include "llvm/ADT/ArrayRef.h"
> 
> @@ -40,7 +41,7 @@ public:
>   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
> 
>   RawComment(const SourceManager &SourceMgr, SourceRange SR,
> -             bool Merged = false);
> +             bool Merged, bool ParseAllComments);
> 
>   CommentKind getKind() const LLVM_READONLY {
>     return (CommentKind) Kind;
> @@ -82,12 +83,18 @@ public:
> 
>   /// Returns true if this comment is not a documentation comment.
>   bool isOrdinary() const LLVM_READONLY {
> -    return (Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC);
> +    return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
> +        !ParseAllComments;
>   }
> 
>   /// Returns true if this comment any kind of a documentation comment.
>   bool isDocumentation() const LLVM_READONLY {
> -    return !isInvalid() && !isOrdinary();
> +    return !isInvalid() && (!isOrdinary() || ParseAllComments);

It seems to me check for ParseAllComments is unnecessary here. It has been pushed into
IsOrdinary().
- Fariborz





More information about the cfe-commits mailing list