how to add objectlike macro?

Hello all.
I want to add some objectlike macro to Preprocessor. I'm using libclang, i
want add macro in code. I just know add simple one.
e.g. #define TEST ==>>
    Preprocessor *pp;
    IdentifierInfo *Id = pp->getIdentifierInfo("TEST");
    MacroInfo *MI = pp->AllocateMacroInfo(SourceLocation());
    MI->setIsBuiltinMacro();
    pp->setMacroInfo(Id, MI);

#define MAX 100
How to do next?

Hello all.
I want to add some objectlike macro to Preprocessor. I’m using libclang, i
want add macro in code. I just know add simple one.
e.g. #define TEST ==>>
Preprocessor *pp;
IdentifierInfo *Id = pp->getIdentifierInfo(“TEST”);
MacroInfo *MI = pp->AllocateMacroInfo(SourceLocation());
MI->setIsBuiltinMacro();
pp->setMacroInfo(Id, MI);

#define MAX 100
How to do next?

Not sure what you are trying to do, can’t you pass a “-D” option to define the macro in the compiler arguments ?

Thank you for reply.
I'm not using the command line. I just want to define macro programatically.

This is my code:
    DiagnosticOptions diagnosticOptions;
    TextDiagnosticPrinter *printer = new
TextDiagnosticPrinter(llvm::nulls(), diagnosticOptions);

    llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs;
    DiagnosticsEngine diagnostics(diagIDs, printer);

    LangOptions languageOptions;
    FileSystemOptions fileSystemOptions;
    FileManager fileManager(fileSystemOptions);

    SourceManager sourceManager(diagnostics, fileManager);

    TargetOptions targetOptions;
    targetOptions.Triple = llvm::sys::getDefaultTargetTriple();
    TargetInfo *pTargetInfo =
clang::TargetInfo::CreateTargetInfo(diagnostics, targetOptions);

    HeaderSearch headerSearch(fileManager, diagnostics, languageOptions,
pTargetInfo);

    HeaderSearchOptions headerSearchOptions;

    for (set<string>::iterator it =
filefold.begin();it!=filefold.end();it++)
    {
        headerSearchOptions.AddPath(*it,frontend::Quoted,false,false,false);
    }
    ApplyHeaderSearchOptions(headerSearch, headerSearchOptions,
languageOptions, pTargetInfo->getTriple());

    CompilerInstance* ci = new CompilerInstance;
    CompilerInstance& theCompInst = *ci;

    Preprocessor *ppp = new Preprocessor(diagnostics, languageOptions,
pTargetInfo, sourceManager, headerSearch, theCompInst);
    Preprocessor& pp = *ppp;
    PreprocessorOptions preprocessorOptions;
    FrontendOptions frontendOptions;
    InitializePreprocessor(pp, preprocessorOptions, headerSearchOptions,
frontendOptions);
    
* for (int i=0;i<(int)compile_define.size();i++)
    {
        RegisterMacro(ppp, compile_define[i]); <<<<<============== add
Preprocessor define
    }*

    const FileEntry *pFile = fileManager.getFile(file_name);
    sourceManager.createMainFileID(pFile);
  
    theCompInst.setDiagnostics(&diagnostics);
   
theCompInst.getDiagnosticClient().BeginSourceFile(theCompInst.getLangOpts(),&pp);
    theCompInst.setPreprocessor(&pp);
    theCompInst.setSourceManager(&sourceManager);
    theCompInst.setTarget(pTargetInfo);
    theCompInst.setDiagnostics(&diagnostics);
    SourceManager &sourceMgr = theCompInst.getSourceManager();
    theCompInst.createASTContext();
    Rewriter rewriter;
    rewriter.setSourceMgr(sourceMgr,languageOptions);

    MemoryMonitorASTConsumer consumer(rewriter);
    consumer.mVisitor.SetCheckFunctionName(function);
    consumer.mVisitor.SetCheckFunctionArgumentIndex(arg_index);
    ParseAST(theCompInst.getPreprocessor(), &consumer,
theCompInst.getASTContext());
    theCompInst.getDiagnosticClient().EndSourceFile();

There is a simpler way, just add your macro defines with PreprocessorOptions::addMacroDef().