[PATCH] This change-list changes clang to attach the ordinary comments if an option is specified
Amin Shali
amshali at gmail.com
Tue Apr 9 11:31:42 PDT 2013
Thank you for comments and help. Updated UsersManual.rst with a new section for comment processing options. Please take a look.
================
Comment at: include/clang/AST/RawCommentList.h:144
@@ -136,1 +143,3 @@
bool IsAlmostTrailingComment : 1;
+ /// When true, ordinary comments starting with "//" will be considered as
+ /// documentation comments.
----------------
Dmitri Gribenko wrote:
> Also mention /* ... */ comments.
Done.
================
Comment at: include/clang/Basic/CommentOptions.h:31-32
@@ +30,4 @@
+
+ /// \brief Treat ordinary comments as doc-comments.
+ bool ParseAllComments;
+
----------------
Dmitri Gribenko wrote:
> Serialization/deserialization code is missing. Grep for BlockCommandNames to find the relevant places.
Done. Thanks.
================
Comment at: lib/AST/RawCommentList.cpp:232
@@ -230,3 +231,3 @@
// Ordinary comments are not interesting for us.
- if (RC.isOrdinary())
+ if (!RC.isDocumentation())
return;
----------------
Dmitri Gribenko wrote:
> Why this change? isOrdinary() should be the exact opposite of isDocumentation() (modulo invalid cases).
Reverted. Fixed isOrdinary and isDocumentation. PTAL.
================
Comment at: test/Index/parse-all-comments.c:6-7
@@ +5,4 @@
+
+// Not a Doxygen comment. notdoxy1 NOT_DOXYGEN
+void notdoxy1(void);
+
----------------
Dmitri Gribenko wrote:
> Please add a test that consecutive '//' comments are merged. See isdoxy20 in the original test for an idea.
Added.
================
Comment at: test/Index/parse-all-comments.c:35
@@ +34,3 @@
+// RUN: FileCheck %s < %t/out.c-index-direct
+
+// CHECK: parse-all-comments.c:7:6: FunctionDecl=notdoxy1:{{.*}} notdoxy1 NOT_DOXYGEN
----------------
Dmitri Gribenko wrote:
> Amin Shali wrote:
> > For some reason the out.c-index-pch does not have the I expected.
> > Running the follwing check fails after this RUN:
> > // RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
> >
> > Can you help me with that? Is it necessary to run the check on out.c-index-pch or out.c-index-direct good enough?
> >
> Yes, pch usecase is important. This error is caused by missing serialization/deserialization code in `lib/Serialization/ASTReader.cpp` and `lib/Serialization/ASTWriter.cpp`.
Thanks. Done.
================
Comment at: include/clang/AST/RawCommentList.h:92
@@ -89,3 +91,3 @@
bool isDocumentation() const LLVM_READONLY {
- return !isInvalid() && !isOrdinary();
+ return !isInvalid() && (!isOrdinary() || TreatOrdinaryCommentAsDocComment);
}
----------------
Dmitri Gribenko wrote:
> Amin Shali wrote:
> > Dmitri Gribenko wrote:
> > > It would be better to change isOrdinary instead:
> > >
> > > return (Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC) || TreatOrdinaryCommentAsDocComment;
> > >
> > Wait, you mean:
> >
> > return (Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC) || !ParseAllComments;
> >
> > But then it skips doxygen style comments when ParseAllComments is false.
> > Besides I think it should be in isDocumentation because otherwise it will fail to return the comment for a declaration because of the check at line 191 file: ASTContext.cpp.
> >
> Yes, that line is incorrect. The correct should be:
>
> return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) && !ParseAllComments;
>
> Does this fix the issue in ASTContext?
Since isDocumentation is the opposite of isOrdinary, I need to change both for whole thing to work fine.
http://llvm-reviews.chandlerc.com/D614
More information about the cfe-commits
mailing list