ΒΆstd::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(
    llvm::StringRef Code,
    const std::vector<std::string>& Args,
    llvm::StringRef FileName = "input.cc",
    llvm::StringRef ToolName = "clang-tool",
    std::shared_ptr<PCHContainerOperations>
        PCHContainerOps = std::make_shared<
            clang::PCHContainerOperations>(),
    clang::tooling::ArgumentsAdjuster Adjuster =
        getClangStripDependencyFileAdjuster(),
    const clang::tooling::FileContentMappings&
        VirtualMappedFiles = std::vector<
            std::pair<std::basic_string<
                          char,
                          std::char_traits<char>,
                          std::allocator<char>>,
                      std::basic_string<
                          char,
                          std::char_traits<char>,
                          std::allocator<char>>>,
            std::allocator<std::pair<
                std::basic_string<
                    char,
                    std::char_traits<char>,
                    std::allocator<char>>,
                std::basic_string<
                    char,
                    std::char_traits<char>,
                    std::allocator<char>>>>>(),
    clang::DiagnosticConsumer* DiagConsumer =
        nullptr)

Description

Builds an AST for 'Code' with additional flags.

Declared at: clang/include/clang/Tooling/Tooling.h:229

Parameters

llvm::StringRef Code
C++ code.
const std::vector<std::string>& Args
Additional flags to pass on.
llvm::StringRef FileName = "input.cc"
The file name which 'Code' will be mapped as.
llvm::StringRef ToolName = "clang-tool"
The name of the binary running the tool. Standard library header paths will be resolved relative to this.
std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<clang::PCHContainerOperations>()
The PCHContainerOperations for loading and creating clang modules.
clang::tooling::ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster()
A function to filter the command line arguments as specified.
const clang::tooling::FileContentMappings& VirtualMappedFiles = std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>()
clang::DiagnosticConsumer* DiagConsumer = nullptr

Returns

The resulting AST or null if an error occurred.