<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">A test case please.<div><br><div>- Thanks, Fariborz</div><div><br><div><div>On Apr 10, 2013, at 8:35 AM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Author: gribozavr<br>Date: Wed Apr 10 10:35:17 2013<br>New Revision: 179180<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=179180&view=rev">http://llvm.org/viewvc/llvm-project?rev=179180&view=rev</a><br>Log:<br>Add an option to parse all comments as documentation comments<br><br>Patch by Amin Shali.<br><br>Modified:<br> cfe/trunk/docs/UsersManual.rst<br> cfe/trunk/include/clang/AST/RawCommentList.h<br> cfe/trunk/include/clang/Basic/CommentOptions.h<br> cfe/trunk/include/clang/Driver/Options.td<br> cfe/trunk/lib/AST/ASTContext.cpp<br> cfe/trunk/lib/AST/RawCommentList.cpp<br> cfe/trunk/lib/Driver/Tools.cpp<br> cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br> cfe/trunk/lib/Sema/Sema.cpp<br> cfe/trunk/lib/Serialization/ASTReader.cpp<br> cfe/trunk/lib/Serialization/ASTWriter.cpp<br><br>Modified: cfe/trunk/docs/UsersManual.rst<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/docs/UsersManual.rst (original)<br>+++ cfe/trunk/docs/UsersManual.rst Wed Apr 10 10:35:17 2013<br>@@ -1005,6 +1005,19 @@ below. If multiple flags are present, th<br><br> Generate complete debug info.<br><br>+Comment Parsing Options<br>+--------------------------<br>+<br>+Clang parses Doxygen and non-Doxygen style documentation comments and attaches<br>+them to the appropriate declaration nodes. By default, it only parses<br>+Doxygen-style comments and ignores ordinary comments starting with ``//`` and<br>+``/*``.<br>+<br>+.. option:: -fparse-all-comments<br>+<br>+ Parse all comments as documentation comments (including ordinary comments<br>+ starting with ``//`` and ``/*``).<br>+<br>.. _c:<br><br>C Language Features<br><br>Modified: cfe/trunk/include/clang/AST/RawCommentList.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/AST/RawCommentList.h (original)<br>+++ cfe/trunk/include/clang/AST/RawCommentList.h Wed Apr 10 10:35:17 2013<br>@@ -10,6 +10,7 @@<br>#ifndef LLVM_CLANG_AST_RAW_COMMENT_LIST_H<br>#define LLVM_CLANG_AST_RAW_COMMENT_LIST_H<br><br>+#include "clang/Basic/CommentOptions.h"<br>#include "clang/Basic/SourceManager.h"<br>#include "llvm/ADT/ArrayRef.h"<br><br>@@ -40,7 +41,7 @@ public:<br> RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }<br><br> RawComment(const SourceManager &SourceMgr, SourceRange SR,<br>- bool Merged = false);<br>+ bool Merged, bool ParseAllComments);<br><br> CommentKind getKind() const LLVM_READONLY {<br> return (CommentKind) Kind;<br>@@ -82,12 +83,18 @@ public:<br><br> /// Returns true if this comment is not a documentation comment.<br> bool isOrdinary() const LLVM_READONLY {<br>- return (Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC);<br>+ return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&<br>+ !ParseAllComments;<br> }<br><br> /// Returns true if this comment any kind of a documentation comment.<br> bool isDocumentation() const LLVM_READONLY {<br>- return !isInvalid() && !isOrdinary();<br>+ return !isInvalid() && (!isOrdinary() || ParseAllComments);<br>+ }<br>+<br>+ /// Returns whether we are parsing all comments.<br>+ bool isParseAllComments() const LLVM_READONLY {<br>+ return ParseAllComments;<br> }<br><br> /// Returns raw comment text with comment markers.<br>@@ -135,6 +142,10 @@ private:<br> bool IsTrailingComment : 1;<br> bool IsAlmostTrailingComment : 1;<br><br>+ /// When true, ordinary comments starting with "//" and "/*" will be<br>+ /// considered as documentation comments.<br>+ bool ParseAllComments : 1;<br>+<br> mutable bool BeginLineValid : 1; ///< True if BeginLine is valid<br> mutable bool EndLineValid : 1; ///< True if EndLine is valid<br> mutable unsigned BeginLine; ///< Cached line number<br>@@ -142,10 +153,12 @@ private:<br><br> /// \brief Constructor for AST deserialization.<br> RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,<br>- bool IsAlmostTrailingComment) :<br>+ bool IsAlmostTrailingComment,<br>+ bool ParseAllComments) :<br> Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),<br> IsAttached(false), IsTrailingComment(IsTrailingComment),<br> IsAlmostTrailingComment(IsAlmostTrailingComment),<br>+ ParseAllComments(ParseAllComments),<br> BeginLineValid(false), EndLineValid(false)<br> { }<br><br>@@ -207,4 +220,3 @@ private:<br>} // end namespace clang<br><br>#endif<br>-<br><br>Modified: cfe/trunk/include/clang/Basic/CommentOptions.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CommentOptions.h?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CommentOptions.h?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/CommentOptions.h (original)<br>+++ cfe/trunk/include/clang/Basic/CommentOptions.h Wed Apr 10 10:35:17 2013<br>@@ -27,6 +27,11 @@ struct CommentOptions {<br> /// \brief Command names to treat as block commands in comments.<br> /// Should not include the leading backslash.<br> BlockCommandNamesTy BlockCommandNames;<br>+<br>+ /// \brief Treat ordinary comments as documentation comments.<br>+ bool ParseAllComments;<br>+<br>+ CommentOptions() : ParseAllComments(false) { }<br>};<br><br>} // end namespace clang<br><br>Modified: cfe/trunk/include/clang/Driver/Options.td<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/Driver/Options.td (original)<br>+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 10 10:35:17 2013<br>@@ -330,6 +330,7 @@ def fcolor_diagnostics : Flag<["-"], "fc<br>def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group<f_clang_Group>, Flags<[CC1Option]>,<br> HelpText<"Treat each comma separated argument in <arg> as a documentation comment block command">,<br> MetaVarName<"<arg>">;<br>+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group<f_clang_Group>, Flags<[CC1Option]>;<br>def fcommon : Flag<["-"], "fcommon">, Group<f_Group>;<br>def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group<f_Group>;<br>def fconstant_cfstrings : Flag<["-"], "fconstant-cfstrings">, Group<f_Group>;<br><br>Modified: cfe/trunk/lib/AST/ASTContext.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/AST/ASTContext.cpp (original)<br>+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Apr 10 10:35:17 2013<br>@@ -141,7 +141,9 @@ RawComment *ASTContext::getRawCommentFor<br> // When searching for comments during parsing, the comment we are looking<br> // for is usually among the last two comments we parsed -- check them<br> // first.<br>- RawComment CommentAtDeclLoc(SourceMgr, SourceRange(DeclLoc));<br>+ RawComment CommentAtDeclLoc(<br>+ SourceMgr, SourceRange(DeclLoc), false,<br>+ LangOpts.CommentOpts.ParseAllComments);<br> BeforeThanCompare<RawComment> Compare(SourceMgr);<br> ArrayRef<RawComment *>::iterator MaybeBeforeDecl = RawComments.end() - 1;<br> bool Found = Compare(*MaybeBeforeDecl, &CommentAtDeclLoc);<br><br>Modified: cfe/trunk/lib/AST/RawCommentList.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RawCommentList.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RawCommentList.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/AST/RawCommentList.cpp (original)<br>+++ cfe/trunk/lib/AST/RawCommentList.cpp Wed Apr 10 10:35:17 2013<br>@@ -63,9 +63,10 @@ bool mergedCommentIsTrailingComment(Stri<br>} // unnamed namespace<br><br>RawComment::RawComment(const SourceManager &SourceMgr, SourceRange SR,<br>- bool Merged) :<br>+ bool Merged, bool ParseAllComments) :<br> Range(SR), RawTextValid(false), BriefTextValid(false),<br> IsAttached(false), IsAlmostTrailingComment(false),<br>+ ParseAllComments(ParseAllComments),<br> BeginLineValid(false), EndLineValid(false) {<br> // Extract raw comment text, if possible.<br> if (SR.getBegin() == SR.getEnd() || getRawText(SourceMgr).empty()) {<br>@@ -253,7 +254,8 @@ void RawCommentList::addComment(const Ra<br> if (C1EndLine + 1 == C2BeginLine || C1EndLine == C2BeginLine) {<br> SourceRange MergedRange(C1.getSourceRange().getBegin(),<br> C2.getSourceRange().getEnd());<br>- *Comments.back() = RawComment(SourceMgr, MergedRange, true);<br>+ *Comments.back() = RawComment(SourceMgr, MergedRange, true,<br>+ RC.isParseAllComments());<br> Merged = true;<br> }<br> }<br>@@ -262,4 +264,3 @@ void RawCommentList::addComment(const Ra<br><br> OnlyWhitespaceSeen = true;<br>}<br>-<br><br>Modified: cfe/trunk/lib/Driver/Tools.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>+++ cfe/trunk/lib/Driver/Tools.cpp Wed Apr 10 10:35:17 2013<br>@@ -3294,6 +3294,8 @@ void Clang::ConstructJob(Compilation &C,<br><br> // Forward -fcomment-block-commands to -cc1.<br> Args.AddAllArgs(CmdArgs, options::OPT_fcomment_block_commands);<br>+ // Forward -fparse-all-comments to -cc1.<br>+ Args.AddAllArgs(CmdArgs, options::OPT_fparse_all_comments);<br><br> // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option<br> // parser.<br><br>Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 10 10:35:17 2013<br>@@ -281,6 +281,7 @@ static bool ParseMigratorArgs(MigratorOp<br><br>static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {<br> Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);<br>+ Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);<br>}<br><br>static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,<br><br>Modified: cfe/trunk/lib/Sema/Sema.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Sema/Sema.cpp (original)<br>+++ cfe/trunk/lib/Sema/Sema.cpp Wed Apr 10 10:35:17 2013<br>@@ -1077,7 +1077,8 @@ void Sema::ActOnComment(SourceRange Comm<br> if (!LangOpts.RetainCommentsFromSystemHeaders &&<br> SourceMgr.isInSystemHeader(Comment.getBegin()))<br> return;<br>- RawComment RC(SourceMgr, Comment);<br>+ RawComment RC(SourceMgr, Comment, false,<br>+ LangOpts.CommentOpts.ParseAllComments);<br> if (RC.isAlmostTrailingComment()) {<br> SourceRange MagicMarkerRange(Comment.getBegin(),<br> Comment.getBegin().getLocWithOffset(3));<br><br>Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Apr 10 10:35:17 2013<br>@@ -3907,6 +3907,7 @@ bool ASTReader::ParseLanguageOptions(con<br> LangOpts.CommentOpts.BlockCommandNames.push_back(<br> ReadString(Record, Idx));<br> }<br>+ LangOpts.CommentOpts.ParseAllComments = Record[Idx++];<br><br> return Listener.ReadLanguageOptions(LangOpts, Complain);<br>}<br>@@ -7165,9 +7166,9 @@ void ASTReader::ReadComments() {<br> (RawComment::CommentKind) Record[Idx++];<br> bool IsTrailingComment = Record[Idx++];<br> bool IsAlmostTrailingComment = Record[Idx++];<br>- Comments.push_back(new (Context) RawComment(SR, Kind,<br>- IsTrailingComment,<br>- IsAlmostTrailingComment));<br>+ Comments.push_back(new (Context) RawComment(<br>+ SR, Kind, IsTrailingComment, IsAlmostTrailingComment,<br>+ Context.getLangOpts().CommentOpts.ParseAllComments));<br> break;<br> }<br> }<br><br>Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=179180&r1=179179&r2=179180&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=179180&r1=179179&r2=179180&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Apr 10 10:35:17 2013<br>@@ -1069,6 +1069,7 @@ void ASTWriter::WriteControlBlock(Prepro<br> I != IEnd; ++I) {<br> AddString(*I, Record);<br> }<br>+ Record.push_back(LangOpts.CommentOpts.ParseAllComments);<br><br> Stream.EmitRecord(LANGUAGE_OPTIONS, Record);<br><br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></div></blockquote></div><br></div></div></body></html>