[PATCH] D125429: Comment parsing: Allow inline commands to have 0 or more than 1 argument
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 11 16:32:14 PDT 2022
aaronpuchert added inline comments.
================
Comment at: clang/include/clang/AST/Comment.h:303
-
- Argument(SourceRange Range, StringRef Text) : Range(Range), Text(Text) { }
};
----------------
Removing that allows me to build an array without initializing all members right away. Alternative would be to add a default constructor here.
================
Comment at: clang/include/clang/Basic/DiagnosticCommentKinds.td:159
+def warn_doc_inline_command_not_enough_arguments : Warning<
+ "'%select{\\|@}0%1' command has %plural{0:no|:%2}2 word argument%s2, expected %3">,
InGroup<Documentation>, DefaultIgnore;
----------------
If you find that `%plural` too fancy, a plain `%2` should also do.
================
Comment at: clang/lib/AST/CommentParser.cpp:295-307
typedef BlockCommandComment::Argument Argument;
Argument *Args =
new (Allocator.Allocate<Argument>(NumArgs)) Argument[NumArgs];
unsigned ParsedArgs = 0;
Token Arg;
while (ParsedArgs < NumArgs && Retokenizer.lexWord(Arg)) {
Args[ParsedArgs] = Argument(SourceRange(Arg.getLocation(),
----------------
This is basically what I'm duplicating. As it happens, the two `Argument` structures are structurally the same, so we could unify them and factor out this code. I'd probably do that in a separate change though (prior to this or as follow-up).
================
Comment at: clang/test/Headers/x86-intrinsics-headers-clean.cpp:4
// RUN: %clang_cc1 -ffreestanding -triple i386-unknown-unknown \
-// RUN: -Wextra -Werror -Wsystem-headers -Wsign-conversion -Wcast-qual -Wdocumentation \
+// RUN: -Wextra -Werror -Wsystem-headers -Wsign-conversion -Wcast-qual -Wdocumentation -Wdocumentation-pedantic -Wdocumentation-unknown-command \
// RUN: -fsyntax-only -fretain-comments-from-system-headers -flax-vector-conversions=none -x c++ -verify %s
----------------
@RKSimon, according to https://github.com/llvm/llvm-project/issues/35297 you mostly wanted -pedantic, but I took the liberty of enabling both. They're currently coupled (similar to https://github.com/llvm/llvm-project/issues/19442).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125429/new/
https://reviews.llvm.org/D125429
More information about the cfe-commits
mailing list