Index: clang/bindings/xml/comment-xml-schema.rng
===================================================================
--- clang/bindings/xml/comment-xml-schema.rng
+++ clang/bindings/xml/comment-xml-schema.rng
@@ -579,6 +579,12 @@
.*\S.*
+
+
+
+ .*\S.*
+
+
Index: clang/include/clang-c/Documentation.h
===================================================================
--- clang/include/clang-c/Documentation.h
+++ clang/include/clang-c/Documentation.h
@@ -182,7 +182,13 @@
* Command argument should be rendered emphasized (typically italic
* font).
*/
- CXCommentInlineCommandRenderKind_Emphasized
+ CXCommentInlineCommandRenderKind_Emphasized,
+
+ /**
+ * Command argument should not be rendered (since it is a only defines
+ * an anchor).
+ */
+ CXCommentInlineCommandRenderKind_Anchor
};
/**
Index: clang/include/clang/AST/Comment.h
===================================================================
--- clang/include/clang/AST/Comment.h
+++ clang/include/clang/AST/Comment.h
@@ -94,10 +94,11 @@
unsigned : NumInlineContentCommentBits;
- unsigned RenderKind : 2;
+ unsigned RenderKind : 3;
+
unsigned CommandID : CommandInfo::NumCommandIDBits;
};
- enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 +
+ enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 3 +
CommandInfo::NumCommandIDBits };
class HTMLTagCommentBitfields {
@@ -310,7 +311,8 @@
RenderNormal,
RenderBold,
RenderMonospaced,
- RenderEmphasized
+ RenderEmphasized,
+ RenderAnchor
};
protected:
Index: clang/include/clang/AST/CommentCommands.td
===================================================================
--- clang/include/clang/AST/CommentCommands.td
+++ clang/include/clang/AST/CommentCommands.td
@@ -81,12 +81,13 @@
// InlineCommand
//===----------------------------------------------------------------------===//
-def B : InlineCommand<"b">;
-def C : InlineCommand<"c">;
-def P : InlineCommand<"p">;
-def A : InlineCommand<"a">;
-def E : InlineCommand<"e">;
-def Em : InlineCommand<"em">;
+def B : InlineCommand<"b">;
+def C : InlineCommand<"c">;
+def P : InlineCommand<"p">;
+def A : InlineCommand<"a">;
+def E : InlineCommand<"e">;
+def Em : InlineCommand<"em">;
+def Anchor : InlineCommand<"anchor">;
//===----------------------------------------------------------------------===//
// BlockCommand
Index: clang/lib/AST/CommentSema.cpp
===================================================================
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -1127,6 +1127,7 @@
.Case("b", InlineCommandComment::RenderBold)
.Cases("c", "p", InlineCommandComment::RenderMonospaced)
.Cases("a", "e", "em", InlineCommandComment::RenderEmphasized)
+ .Case("anchor", InlineCommandComment::RenderAnchor)
.Default(InlineCommandComment::RenderNormal);
}
Index: clang/lib/AST/JSONNodeDumper.cpp
===================================================================
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -1488,6 +1488,9 @@
case comments::InlineCommandComment::RenderMonospaced:
JOS.attribute("renderKind", "monospaced");
break;
+ case comments::InlineCommandComment::RenderAnchor:
+ JOS.attribute("renderKind", "anchor");
+ break;
}
llvm::json::Array Args;
Index: clang/lib/AST/TextNodeDumper.cpp
===================================================================
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -489,6 +489,9 @@
case comments::InlineCommandComment::RenderEmphasized:
OS << " RenderEmphasized";
break;
+ case comments::InlineCommandComment::RenderAnchor:
+ OS << " RenderAnchor";
+ break;
}
for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
Index: clang/lib/Index/CommentToXML.cpp
===================================================================
--- clang/lib/Index/CommentToXML.cpp
+++ clang/lib/Index/CommentToXML.cpp
@@ -297,6 +297,12 @@
appendToResultWithHTMLEscaping(Arg0);
Result << "";
return;
+ case InlineCommandComment::RenderAnchor:
+ assert(C->getNumArgs() == 1);
+ Result << "";
+ return;
}
}
@@ -641,6 +647,12 @@
appendToResultWithXMLEscaping(Arg0);
Result << "";
return;
+ case InlineCommandComment::RenderAnchor:
+ assert(C->getNumArgs() == 1);
+ Result << "";
+ appendToResultWithXMLEscaping(Arg0);
+ Result << "";
+ return;
}
}
Index: clang/test/Index/Inputs/CommentXML/valid-function-02.xml
===================================================================
--- clang/test/Index/Inputs/CommentXML/valid-function-02.xml
+++ clang/test/Index/Inputs/CommentXML/valid-function-02.xml
@@ -9,6 +9,7 @@
<eee>
<fff>
<ggg>.
+ hhh
Index: clang/test/Index/comment-to-html-xml-conversion.cpp
===================================================================
--- clang/test/Index/comment-to-html-xml-conversion.cpp
+++ clang/test/Index/comment-to-html-xml-conversion.cpp
@@ -734,6 +734,16 @@
// CHECK-NEXT: (CXComment_Text Text=[Aaa])
// CHECK-NEXT: (CXComment_HTMLEndTag Name=[h1])))]
+/// \anchor A
+void comment_to_html_conversion_37();
+
+// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_37:{{.*}} FullCommentAsHTML=[
] FullCommentAsXML=[comment_to_html_conversion_37c:@F@comment_to_html_conversion_37#void comment_to_html_conversion_37() A]
+// CHECK-NEXT: CommentAST=[
+// CHECK-NEXT: (CXComment_FullComment
+// CHECK-NEXT: (CXComment_Paragraph
+// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)
+// CHECK-NEXT: (CXComment_InlineCommand CommandName=[anchor] RenderAnchor Arg[0]=A)))]
+
/// Aaa.
class comment_to_xml_conversion_01 {
Index: clang/test/Sema/warn-documentation.cpp
===================================================================
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1057,6 +1057,13 @@
/// \a A
int test_inline_no_argument_a_good(int);
+// expected-warning@+1 {{'\anchor' command does not have a valid word argument}}
+/// \anchor
+int test_inline_no_argument_anchor_bad(int);
+
+/// \anchor A
+int test_inline_no_argument_anchor_good(int);
+
// expected-warning@+1 {{'@b' command does not have a valid word argument}}
/// @b
int test_inline_no_argument_b_bad(int);
Index: clang/tools/c-index-test/c-index-test.c
===================================================================
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -497,6 +497,9 @@
case CXCommentInlineCommandRenderKind_Emphasized:
printf(" RenderEmphasized");
break;
+ case CXCommentInlineCommandRenderKind_Anchor:
+ printf(" RenderAnchor");
+ break;
}
for (i = 0, e = clang_InlineCommandComment_getNumArgs(Comment);
i != e; ++i) {
Index: clang/tools/libclang/CXComment.cpp
===================================================================
--- clang/tools/libclang/CXComment.cpp
+++ clang/tools/libclang/CXComment.cpp
@@ -159,6 +159,9 @@
case InlineCommandComment::RenderEmphasized:
return CXCommentInlineCommandRenderKind_Emphasized;
+
+ case InlineCommandComment::RenderAnchor:
+ return CXCommentInlineCommandRenderKind_Anchor;
}
llvm_unreachable("unknown InlineCommandComment::RenderKind");
}