|
ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
|
Utilities for interacting with Clang at runtime This includes runtime detection of Clang paths and AST operations. More...
#include <clang/Basic/Diagnostic.h>#include <functional>#include <memory>#include <string>#include <vector>Go to the source code of this file.
Classes | |
| struct | acav::DiagnosticMessage |
Typedefs | |
| using | acav::DiagnosticCallback = std::function<void(const DiagnosticMessage &)> |
Functions | |
| std::string | acav::getClangResourceDir (const std::string &overrideResourceDir="") |
| Get clang resource directory. | |
| std::vector< std::string > | acav::buildToolchainAdjustedCommandLine (const std::vector< std::string > &commandLine, const std::string &clangResourceDir, std::string &diagnostic) |
| Normalize a Clang command line for ACAV's embedded Clang. | |
| std::unique_ptr< clang::ASTUnit > | acav::createAstFromCDB (const std::string &compilationDatabase, const std::string &sourcePath, std::string &errorMessage, const DiagnosticCallback &diagnosticCallback=nullptr, const std::string &clangResourceDirOverride="") |
| Create AST from a given compilation database This function provides a easy way to generate clang AST for a given file and it's compile command. | |
| bool | acav::saveAst (clang::ASTUnit &astUnit, const std::string &outputPath, std::string &errorMessage) |
| Save ast to local file. | |
| std::unique_ptr< clang::ASTUnit > | acav::loadAstFromFile (const std::string &astFilePath, std::string &errorMessage, const std::string &compilationDbPath="", const std::string &sourcePath="", const DiagnosticCallback &diagnosticCallback=nullptr) |
| Load AST from local file. | |
| std::vector< std::string > | acav::getSourceFilesFromCompilationDatabase (const std::string &compDbPath, std::string &errorMessage) |
| Extract source file paths from a compilation database. | |
Utilities for interacting with Clang at runtime This includes runtime detection of Clang paths and AST operations.
Definition in file ClangUtils.h.
| using acav::DiagnosticCallback = std::function<void(const DiagnosticMessage &)> |
Definition at line 50 of file ClangUtils.h.
| std::vector< std::string > acav::buildToolchainAdjustedCommandLine | ( | const std::vector< std::string > & | commandLine, |
| const std::string & | clangResourceDir, | ||
| std::string & | diagnostic ) |
Normalize a Clang command line for ACAV's embedded Clang.
This removes stale resource-dir flags, forces ACAV's resource dir, and on macOS adds the active SDK sysroot when the compile command does not already specify one. Standard library, system include, and framework discovery is left to Clang's driver/tooling APIs.
Definition at line 387 of file ClangUtils.cpp.
| std::unique_ptr< clang::ASTUnit > acav::createAstFromCDB | ( | const std::string & | compilationDatabase, |
| const std::string & | sourcePath, | ||
| std::string & | errorMessage, | ||
| const DiagnosticCallback & | diagnosticCallback = nullptr, | ||
| const std::string & | clangResourceDirOverride = "" ) |
Create AST from a given compilation database This function provides a easy way to generate clang AST for a given file and it's compile command.
There are several steps:
Definition at line 454 of file ClangUtils.cpp.
| std::string acav::getClangResourceDir | ( | const std::string & | overrideResourceDir = "" | ) |
Get clang resource directory.
Discovery order:
| overrideResourceDir | Optional explicit path to use |
Definition at line 312 of file ClangUtils.cpp.
| std::vector< std::string > acav::getSourceFilesFromCompilationDatabase | ( | const std::string & | compDbPath, |
| std::string & | errorMessage ) |
Extract source file paths from a compilation database.
| compDbPath | Path to compile_commands.json |
| errorMessage | Output parameter for error details |
Thread-safe: Can be called from any thread
Definition at line 779 of file ClangUtils.cpp.
| std::unique_ptr< clang::ASTUnit > acav::loadAstFromFile | ( | const std::string & | astFilePath, |
| std::string & | errorMessage, | ||
| const std::string & | compilationDbPath = "", | ||
| const std::string & | sourcePath = "", | ||
| const DiagnosticCallback & | diagnosticCallback = nullptr ) |
Load AST from local file.
| astFilePath | Path to the .ast file |
| errorMessage | Output parameter for error details |
| compilationDbPath | Path to compile_commands.json for C++20 module resolution. If empty, module resolution may fail for module imports. |
| sourcePath | Source file path to extract module mappings for. Required if compilationDbPath is provided. |
Definition at line 645 of file ClangUtils.cpp.
| bool acav::saveAst | ( | clang::ASTUnit & | astUnit, |
| const std::string & | outputPath, | ||
| std::string & | errorMessage ) |
Save ast to local file.
Definition at line 634 of file ClangUtils.cpp.