Is there any way to make preprocessor retain comment with clangTool? #192
Labels
clang:driver
'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
clang:tooling
LibTooling
question
A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
I am trying to use clang AST matcher to parse comments from input source code but the comments inside ASTContext still remains empty. Here is a simple example of my input code.
After my program process the input, it will output
tag_A, tag_B
. I attempt to follow the clang users manual and add-Wdocumentation
,-fparse-all-comments
even-E -CC
but none of these make AST retain comments after preprocessing. I attach my compile_commands.json as follows.And here is how I check if there is comment node in AST.
I modify the tutorial in the LLVM documentation to the code above. Besides adding comment parsing flags, I also try to mimic how ClangTool runs FrontendAction. However, codes become more and more out of control. I still wonder if there is any way to explicitly modify the PreprocessorOutputOptions.ShowComments in the CompilerInstance or CompilerInvocation.
In a word, I would like to know how to make ASTContext retain the comment information after preprocessing.
Thank you.
The text was updated successfully, but these errors were encountered: