ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
AcavAstBuilder.h
Go to the documentation of this file.
1/*$!{
2* Aurora Clang AST Viewer (ACAV)
3*
4* Copyright (c) 2026 Min Liu
5* Copyright (c) 2026 Michael David Adams
6*
7* SPDX-License-Identifier: GPL-2.0-or-later
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License along
20* with this program; if not, see <https://www.gnu.org/licenses/>.
21}$!*/
22
25#pragma once
26
27#include "common/FileManager.h"
28#include "core/AstNode.h"
30#include <clang/AST/ASTContext.h>
31#include <clang/AST/PrettyPrinter.h>
32#include <clang/AST/RecursiveASTVisitor.h>
33
34namespace clang {
35class ASTUnit;
36class Decl;
37class Stmt;
38class Type;
39class TypeLoc;
40class Attr;
41class ConceptReference;
42class CXXBaseSpecifier;
43class CXXCtorInitializer;
44class LambdaCapture;
45class NestedNameSpecifier;
46class NestedNameSpecifierLoc;
47class TemplateArgument;
48class TemplateArgumentList;
49class TemplateArgumentLoc;
50class TemplateName;
51} // namespace clang
52
53namespace acav {
54
56class TypeInfoExtractor {
57public:
58 explicit TypeInfoExtractor(clang::ASTContext &ctx);
59
69 void extractTypeInfo(clang::QualType qt, AcavJson &properties) const;
70
76 void extractTypeLocInfo(clang::TypeLoc tl, AcavJson &properties) const;
77
82 void extractTemplateArgs(const clang::TemplateArgumentList *args,
83 AcavJson &properties) const;
84
86 AcavJson extractTemplateArg(const clang::TemplateArgument &arg) const;
87
88private:
89 clang::ASTContext &ctx_;
90 clang::PrintingPolicy policy_;
91
93 std::string getQualifierString(clang::Qualifiers quals) const;
94};
95
102public:
111 static AstViewNode *buildFromASTUnit(clang::ASTUnit &astUnit,
112 AstContext *context,
113 FileManager &fileManager,
114 AstExtractionStats &stats,
115 bool extractComments = false);
116
117private:
118 // Implementation is hidden in .cpp file
119 class Impl;
120};
121
122} // namespace acav
Qt runner for AST extraction pipeline.
AST data structures and memory management.
nlohmann::basic_json< std::map, std::vector, InternedString, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer, std::vector< uint8_t > > AcavJson
Custom JSON type using InternedString for automatic string deduplication.
Definition AstNode.h:51
Centralized file registry with path-to-FileID mapping.
ACAV AST builder with comprehensive type extraction.
static AstViewNode * buildFromASTUnit(clang::ASTUnit &astUnit, AstContext *context, FileManager &fileManager, AstExtractionStats &stats, bool extractComments=false)
Build ACAV AST from Clang ASTUnit.
Memory manager for AST nodes in a translation unit.
Definition AstNode.h:66
Represents node in AST tree hierarchy.
Definition AstNode.h:195
Centralized file registry providing path-to-FileID mapping.
Definition FileManager.h:45
void extractTypeInfo(clang::QualType qt, AcavJson &properties) const
Extract comprehensive type information into JSON.
void extractTypeLocInfo(clang::TypeLoc tl, AcavJson &properties) const
Extract TypeLoc-specific information.
AcavJson extractTemplateArg(const clang::TemplateArgument &arg) const
Extract single template argument details.
void extractTemplateArgs(const clang::TemplateArgumentList *args, AcavJson &properties) const
Extract template argument information.
Statistics collected during AST extraction.