[cfe-users] Some basic AST file generation questions

Ray Mitchell via cfe-users cfe-users at lists.llvm.org
Thu Mar 25 17:25:25 PDT 2021

Win10-64, clang v11.0.0, VS2019

When I enter "clang.exe -help" from the command line I get a long list of clang options, and one of them is "-Xclang <arg>".  Thanks to previous help from a member of the cfe-users digest, I am able to do "clang.exe -Xclang -ast-dump -fsyntax-only SourceFile.c" to get the AST file for my source file.  I have some basic questions about all this:

1. I may have asked this before, but I've forgotten :-(  The -ast-dump and -fsyntax-only options above are not listed when I enter "clang.exe -help".  Is there a command line option that will list these and all other options that are missing from the basic -help list?  If so, what is it?  If not, specifically where can I find these additional options listed and described?

2. All of the following code I describe compiles, links, and runs correctly:  I have an include guard protected header file named MyClass.h that includes a couple standard library headers followed by the declaration of a const variable followed by the definition of C++ class named MyClass followed by the definition of an inline function.  When I do "clang.exe -Xclang -ast-dump -fsyntax-only MyClass.h" the resulting AST file contains the typical AST information from the two included header files, but only contains the two following lines for my code:
    |-VarDecl 0xb1ba010 <C:\MyClass.h:23:1, col:7> col:7 invalid MyClass 'int'
    `-VarDecl 0xb1ba060 <line:41:1, col:13> col:13 invalid MyClass 'void'
When I look at the AST files produced for any of my implementation files that contain #include "MyClass.h", the complete AST information for MyClass.h is there.  Why is most of that AST information missing from the AST file produced directly from MyClass.h and how can I cause it to be there?

Thank you :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20210325/64a86bd7/attachment.html>

More information about the cfe-users mailing list