Libtooling with -fmodules error

I have a libtooling tool named ‘ExportAST’ which used to export the declaration information of the specified header file.
I almost did. When I was debugging an objective-c module. I got a problem.

can you help me?

There is a problem with libtooling that has been bothering me,
A specified header file named BBPAppDelegate.h to be exported:

/ / BBPAppDelegate.h
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
@ import ObjectiveC.runtime;
@ import ObjectiveC.message;

@interface BBPAppDelegate : NSObject<UIApplicationDelegate, UNUserNotificationCenterDelegate>



execute cmd:

    $ ./ExportAST BBPAppDelegate.h -- -isysroot /Applications/ -isystem /Applications/ -x objective-c -fobjc-arc -fmodules

Then got the Errors:
/Applications/ error: header 'stdarg.h' not found header "stdarg.h" // note: supplied by the compiler ^ /Applications/ note: submodule of top-level module 'Darwin' implicitly imported here #include <sys/types.h> ...** many error **...

To Execute after remove the option ‘-fmodules’:

    $ . / ExportAST BBPAppDelegate. H -- -- - isysroot/Applications/Xcode. The app/Contents/Developer/Platforms/iPhoneSimulator platform/Developer/SDKs/iPhoneSimulator13.2 SDK - isystem / Applications/Xcode. App/Contents/Developer/Toolchains/XcodeDefault xctoolchain/usr/lib/clang 11.0.0 / include - x objective - c - fobjc - arc

Error still reported:
../BBPAppDelegate.h:13:1: error: use of '@import' when modules are disabled @import ObjectiveC.runtime; ^ ../BBPAppDelegate.h:14:1: error: use of '@import' when modules are disabled @import ObjectiveC.message;

When test with libclang:

There is no error when using a libclang tool which linkd libclang.dynlib by Apple produced(/Applications/

However, it’s also failed when using a libclang tool which linkd libclang.dynlib by my compilation(/volume/ExtDisk/llvm-project-apple/lib/libclang.dylib), regardless of whether -fmoudles were added or not.
BBPAppDelegate. H :13:1: fatal error: could not build module 'UIKit'

So I think it’s what cmake parameters added by Apple when compiling and generating llvm-project of Xcode, Using the apple llvm-project

I compile the llvm-project with the paramters:

    $ cmake ../llvm-project-apple/llvm  -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_RTTI:BOOL=ON -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;libunwind;compiler-rt"
    $ make j4

Use llvm:
    $ cmake ../llvm-project-apple/llvm  -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_RTTI:BOOL=ON
    $ make j4

Both versions of clang are compiled with the same result
To support objective-c modules (@import objective-c. Runtime) which parameters should I use for cmake llvm-project?

Any Suggestions would be greatly appreciated!

Related information:
OS:Mac OS 10.15.1
llvm-project: llvm-mirror/llvm.git
llvm-project-apple: apple/llvm-project.git
Xcode: Xcode 11.2.1(Apple clang version 11.0.0 (clang-1100.0.33.12))
cmake version: cmake version 3.14.5
make version: GNU Make 3.81

Has the problem been solved?