[cfe-dev] Parsing All Comments

James Dennett via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 16 01:26:55 PDT 2015


On Fri, Oct 16, 2015 at 1:16 AM, Chengnian Sun <chengniansun at gmail.com>
wrote:

> Thank you for your reply. The comment is very simple. Each function
> definition has a preceding comment, listing all the global variables used
> in the function definition. I need to parse this comment to get the
> variable list.
>
> Yes, I actually found another old post mentioning CommentOptions::ParseAllComments.
> However I am new to LLVM/Clang, and I found out it was just a structure
> defined in CommentOptions.h if I am not wrong.
>
>
CommentOptions is indeed just a class, and ParseAllComments a field in it.
It's normally set by this code from lib/Frontend/CompilerInvocation.cpp:

static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
  Opts.BlockCommandNames =
Args.getAllArgValues(OPT_fcomment_block_commands);
  Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
}

i.e., you can set it using a command line argument -fparse-all-comments if
that's how you're configuring your tool.

-- James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151016/db3717cf/attachment.html>


More information about the cfe-dev mailing list