Sequence diagram translation unit visitor. More...
Sequence diagram translation unit visitor.
This class implements the clang::RecursiveASTVisitor
interface for selected visitors relevant to generating sequence diagrams.
Definition at line 49 of file translation_unit_visitor.h.
#include <translation_unit_visitor.h>
Public Types | |
using | template_builder_t = common::visitor::template_builder< translation_unit_visitor > |
using | config_t = ConfigT |
using | diagram_t = DiagramT |
![]() | |
using | config_t = ConfigT |
using | diagram_t = DiagramT |
Public Member Functions | |
translation_unit_visitor (clang::SourceManager &sm, clanguml::sequence_diagram::model::diagram &diagram, const clanguml::config::sequence_diagram &config) | |
Constructor. | |
~translation_unit_visitor () override=default | |
bool | shouldVisitTemplateInstantiations () |
bool | VisitReturnStmt (clang::ReturnStmt *stmt) |
bool | VisitCallExpr (clang::CallExpr *expr) |
bool | VisitObjCMessageExpr (clang::ObjCMessageExpr *expr) |
bool | VisitObjCPropertyRefExpr (clang::ObjCPropertyRefExpr *expr) |
bool | TraverseVarDecl (clang::VarDecl *VD) |
bool | TraverseCoyieldExpr (clang::CoyieldExpr *expr) |
bool | TraverseCoawaitExpr (clang::CoawaitExpr *expr) |
bool | TraverseCoreturnStmt (clang::CoreturnStmt *stmt) |
bool | TraverseCallExpr (clang::CallExpr *expr) |
bool | TraverseObjCMessageExpr (clang::ObjCMessageExpr *expr) |
bool | TraverseCUDAKernelCallExpr (clang::CUDAKernelCallExpr *expr) |
bool | TraverseCXXMemberCallExpr (clang::CXXMemberCallExpr *expr) |
bool | TraverseCXXOperatorCallExpr (clang::CXXOperatorCallExpr *expr) |
bool | VisitCXXConstructExpr (clang::CXXConstructExpr *expr) |
bool | TraverseCXXConstructExpr (clang::CXXConstructExpr *expr) |
bool | TraverseCXXTemporaryObjectExpr (clang::CXXTemporaryObjectExpr *expr) |
bool | TraverseReturnStmt (clang::ReturnStmt *stmt) |
bool | VisitCoreturnStmt (clang::CoreturnStmt *stmt) |
bool | VisitCoyieldExpr (clang::CoyieldExpr *expr) |
bool | VisitCoawaitExpr (clang::CoawaitExpr *expr) |
bool | VisitLambdaExpr (clang::LambdaExpr *expr) |
bool | TraverseLambdaExpr (clang::LambdaExpr *expr) |
bool | TraverseCXXMethodDecl (clang::CXXMethodDecl *declaration) |
bool | TraverseObjCMethodDecl (clang::ObjCMethodDecl *declaration) |
bool | VisitObjCMethodDecl (clang::ObjCMethodDecl *declaration) |
bool | VisitCXXMethodDecl (clang::CXXMethodDecl *declaration) |
bool | TraverseCXXRecordDecl (clang::CXXRecordDecl *declaration) |
bool | VisitCXXRecordDecl (clang::CXXRecordDecl *declaration) |
bool | VisitClassTemplateDecl (clang::ClassTemplateDecl *declaration) |
bool | VisitClassTemplateSpecializationDecl (clang::ClassTemplateSpecializationDecl *declaration) |
bool | TraverseFunctionDecl (clang::FunctionDecl *declaration) |
bool | VisitFunctionDecl (clang::FunctionDecl *declaration) |
bool | TraverseFunctionTemplateDecl (clang::FunctionTemplateDecl *declaration) |
bool | VisitFunctionTemplateDecl (clang::FunctionTemplateDecl *function_declaration) |
bool | VisitObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_declaration) |
bool | VisitObjCProtocolDecl (clang::ObjCProtocolDecl *protocol_declaration) |
bool | TraverseCompoundStmt (clang::CompoundStmt *stmt) |
bool | TraverseIfStmt (clang::IfStmt *stmt) |
bool | TraverseWhileStmt (clang::WhileStmt *stmt) |
bool | TraverseDoStmt (clang::DoStmt *stmt) |
bool | TraverseForStmt (clang::ForStmt *stmt) |
bool | TraverseCXXForRangeStmt (clang::CXXForRangeStmt *stmt) |
bool | TraverseCXXTryStmt (clang::CXXTryStmt *stmt) |
bool | TraverseCXXCatchStmt (clang::CXXCatchStmt *stmt) |
bool | TraverseSwitchStmt (clang::SwitchStmt *stmt) |
bool | TraverseCaseStmt (clang::CaseStmt *stmt) |
bool | TraverseDefaultStmt (clang::DefaultStmt *stmt) |
bool | TraverseConditionalOperator (clang::ConditionalOperator *stmt) |
call_expression_context & | context () |
Get current call expression context reference. | |
const call_expression_context & | context () const |
Get current call expression context reference. | |
template<typename T = model::participant> | |
common::optional_ref< T > | get_participant (const clang::Decl *decl) |
Get participant by declaration. | |
template<typename T = model::participant> | |
common::optional_ref< T > | get_participant (const clang::Decl *decl) const |
Get participant by declaration. | |
template<typename T = model::participant> | |
common::optional_ref< T > | get_participant (const eid_t id) |
Get participant by global element id. | |
template<typename T = model::participant> | |
common::optional_ref< T > | get_participant (eid_t id) const |
Get participant by global element id. | |
void | set_unique_id (int64_t local_id, eid_t global_id) |
Store the mapping from local clang entity id (obtained using getID()) method to clang-uml global id. | |
std::optional< eid_t > | get_unique_id (eid_t local_id) const |
Retrieve the global clang-uml entity id based on the Clang local id. | |
void | finalize () |
Finalize diagram model for this translation unit. | |
std::unique_ptr< sequence_diagram::model::class_ > | create_element (const clang::NamedDecl *decl) const |
![]() | |
translation_unit_visitor (clang::SourceManager &sm, DiagramT &diagram, const ConfigT &config) | |
Constructor. | |
virtual | ~translation_unit_visitor ()=default |
void | set_tu_path (const std::string &translation_unit_path) |
const std::filesystem::path & | tu_path () const |
Return relative path to current translation unit. | |
common::visitor::ast_id_mapper & | id_mapper () const |
Get reference to Clang AST to clang-uml id mapper. | |
clang::SourceManager & | source_manager () const |
Get clang::SourceManager. | |
void | set_source_location (const clang::Decl &decl, clanguml::common::model::source_location &element) |
Set source location in diagram element. | |
void | set_source_location (const clang::Expr &expr, clanguml::common::model::source_location &element) |
Set source location in diagram element. | |
void | set_source_location (const clang::Stmt &stmt, clanguml::common::model::source_location &element) |
void | set_qualified_name (const clang::NamedDecl &decl, clanguml::common::model::element &element) |
void | set_source_location (const clang::SourceLocation &location, clanguml::common::model::source_location &element) |
Set source location in diagram element. | |
void | set_owning_module (const clang::Decl &decl, clanguml::common::model::element &element) |
virtual void | add_diagram_element (std::unique_ptr< common::model::template_element > element) |
void | process_comment (const clang::NamedDecl &decl, clanguml::common::model::decorated_element &e) |
Process comment directives in comment attached to a declaration. | |
std::string | process_comment (const clang::RawComment *comment, clang::DiagnosticsEngine &de, clanguml::common::model::decorated_element &e) |
Process comment directives in raw comment. | |
bool | skip_system_header_decl (const clang::NamedDecl *decl) const |
bool | should_include (const clang::NamedDecl *decl) const |
Check if the diagram should include a declaration. | |
DiagramT & | diagram () |
Get diagram model reference. | |
const DiagramT & | diagram () const |
Get diagram model reference. | |
const ConfigT & | config () const |
Get diagram config instance. | |
Private Member Functions | |
bool | should_include (const clang::TagDecl *decl) const |
Check if the diagram should include a declaration. | |
bool | should_include (const clang::ObjCContainerDecl *decl) const |
Check if the diagram should include an ObjC declaration. | |
bool | should_include (const clang::LambdaExpr *expr) const |
Check if the diagram should include a lambda expression. | |
bool | should_include (const clang::CallExpr *expr) const |
Check if the diagram should include a call expression. | |
bool | should_include (const clang::ObjCMessageExpr *expr) const |
Check if the diagram should include an ObjC message expression. | |
bool | should_include (const clang::CXXMethodDecl *decl) const |
Check if the diagram should include a declaration. | |
bool | should_include (const clang::ObjCMethodDecl *decl) const |
bool | should_include (const clang::FunctionDecl *decl) const |
Check if the diagram should include a declaration. | |
bool | should_include (const clang::FunctionTemplateDecl *decl) const |
Check if the diagram should include a declaration. | |
bool | should_include (const clang::ClassTemplateDecl *decl) const |
Check if the diagram should include a declaration. | |
std::unique_ptr< clanguml::sequence_diagram::model::class_ > | create_objc_interface_model (clang::ObjCInterfaceDecl *cls) |
std::unique_ptr< clanguml::sequence_diagram::model::class_ > | create_objc_protocol_model (clang::ObjCProtocolDecl *cls) |
std::unique_ptr< clanguml::sequence_diagram::model::class_ > | create_class_model (clang::CXXRecordDecl *cls) |
std::unique_ptr< clanguml::sequence_diagram::model::method > | create_method_model (clang::CXXMethodDecl *cls) |
std::unique_ptr< clanguml::sequence_diagram::model::objc_method > | create_objc_method_model (clang::ObjCMethodDecl *cls) |
std::unique_ptr< clanguml::sequence_diagram::model::method > | create_lambda_method_model (clang::CXXMethodDecl *cls) |
std::unique_ptr< model::function_template > | build_function_template_instantiation (const clang::FunctionDecl &pDecl) |
std::unique_ptr< model::function > | build_function_model (const clang::FunctionDecl &declaration) |
std::unique_ptr< model::function_template > | build_function_template (const clang::FunctionTemplateDecl &declaration) |
std::unique_ptr< model::class_ > | process_class_template_specialization (clang::ClassTemplateSpecializationDecl *cls) |
std::string | simplify_system_template (const std::string &full_name) const |
std::string | make_lambda_name (const clang::CXXRecordDecl *cls) const |
Assuming cls is a lambda, create it's full name. | |
std::string | lambda_source_location (const clang::SourceLocation &source_location) const |
Render lambda source location to string. | |
bool | is_smart_pointer (const clang::TemplateDecl *primary_template) const |
Check if template is a smart pointer. | |
bool | is_callee_valid_template_specialization (const clang::CXXDependentScopeMemberExpr *dependent_member_expr) const |
Check, the callee is a template specialization. | |
bool | process_callee (clang::CallExpr *expr, model::message &m, bool generated_message_from_comment) |
bool | process_construct_expression (model::message &m, const clang::CXXConstructExpr *construct_expr) |
Handle CXX constructor call. | |
bool | process_operator_call_expression (model::message &m, const clang::CXXOperatorCallExpr *operator_call_expr) |
Handle a operator call expression. | |
bool | process_cuda_kernel_call_expression (model::message &m, const clang::CUDAKernelCallExpr *cuda_call_expr) |
bool | process_class_method_call_expression (model::message &m, const clang::CXXMemberCallExpr *method_call_expr) |
Handle a class method call expresion. | |
bool | process_objc_message_expression (model::message &m, const clang::ObjCMessageExpr *message_expr) |
bool | process_class_template_method_call_expression (model::message &m, const clang::CallExpr *expr) |
Handle a class template method call expresion. | |
bool | process_function_call_expression (model::message &m, const clang::CallExpr *expr) |
Handle a function call expresion. | |
bool | process_unresolved_lookup_call_expression (model::message &m, const clang::CallExpr *expr) const |
Handle an unresolved lookup call expresion. | |
bool | process_lambda_call_expression (model::message &m, const clang::CallExpr *expr) const |
void | push_message (clang::CallExpr *expr, model::message &&m) |
Register a message model m with a call expression. | |
void | push_message (clang::CXXConstructExpr *expr, model::message &&m) |
void | push_message (clang::ObjCMessageExpr *expr, model::message &&m) |
void | push_message (clang::ReturnStmt *stmt, model::message &&m) |
void | push_message (clang::CoreturnStmt *stmt, model::message &&m) |
void | push_message (clang::CoyieldExpr *stmt, model::message &&m) |
void | push_message (clang::CoawaitExpr *stmt, model::message &&m) |
void | pop_message_to_diagram (clang::CallExpr *expr) |
Move a message model to diagram. | |
void | pop_message_to_diagram (clang::CXXConstructExpr *expr) |
void | pop_message_to_diagram (clang::ObjCMessageExpr *expr) |
void | pop_message_to_diagram (clang::ReturnStmt *stmt) |
void | pop_message_to_diagram (clang::CoreturnStmt *stmt) |
void | pop_message_to_diagram (clang::CoyieldExpr *expr) |
void | pop_message_to_diagram (clang::CoawaitExpr *expr) |
std::optional< std::pair< unsigned int, std::string > > | get_expression_comment (const clang::SourceManager &sm, const clang::ASTContext &context, eid_t caller_id, const clang::Stmt *stmt) |
bool | generate_message_from_comment (model::message &m) const |
Initializes model message from comment call directive. | |
template_builder_t & | tbuilder () |
Get template builder reference. | |
void | resolve_ids_to_global () |
void | ensure_lambda_messages_have_operator_as_target () |
void | add_callers_to_activities () |
void | ensure_activity_exists (const model::message &m) |
void | process_function_parameters (const clang::FunctionDecl &declaration, model::function &method_model) const |
Additional Inherited Members | |
![]() | |
std::set< const clang::RawComment * > & | processed_comments () |
std::string | get_file_path (const std::string &file_location) const |
using clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT >::config_t = ConfigT |
Definition at line 56 of file translation_unit_visitor.h.
using clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT >::diagram_t = DiagramT |
Definition at line 57 of file translation_unit_visitor.h.
using clanguml::sequence_diagram::visitor::translation_unit_visitor::template_builder_t = common::visitor::template_builder<translation_unit_visitor> |
Definition at line 56 of file translation_unit_visitor.h.
clanguml::sequence_diagram::visitor::translation_unit_visitor::translation_unit_visitor | ( | clang::SourceManager & | sm, |
clanguml::sequence_diagram::model::diagram & | diagram, | ||
const clanguml::config::sequence_diagram & | config | ||
) |
Constructor.
sm | Current source manager reference |
diagram | Diagram model |
config | Diagram configuration |
Definition at line 27 of file translation_unit_visitor.cc.
|
overridevirtualdefault |
Reimplemented from clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT >.
|
private |
Definition at line 3030 of file translation_unit_visitor.cc.
|
private |
Definition at line 2654 of file translation_unit_visitor.cc.
|
private |
Definition at line 2610 of file translation_unit_visitor.cc.
|
private |
Definition at line 2635 of file translation_unit_visitor.cc.
call_expression_context & clanguml::sequence_diagram::visitor::translation_unit_visitor::context | ( | ) |
Get current call expression context reference.
Definition at line 48 of file translation_unit_visitor.cc.
const call_expression_context & clanguml::sequence_diagram::visitor::translation_unit_visitor::context | ( | ) | const |
Get current call expression context reference.
Definition at line 53 of file translation_unit_visitor.cc.
|
private |
Definition at line 2430 of file translation_unit_visitor.cc.
std::unique_ptr< sequence_diagram::model::class_ > clanguml::sequence_diagram::visitor::translation_unit_visitor::create_element | ( | const clang::NamedDecl * | decl | ) | const |
Definition at line 36 of file translation_unit_visitor.cc.
|
private |
Definition at line 3058 of file translation_unit_visitor.cc.
|
private |
Definition at line 3160 of file translation_unit_visitor.cc.
|
private |
Definition at line 2402 of file translation_unit_visitor.cc.
|
private |
Definition at line 3092 of file translation_unit_visitor.cc.
|
private |
Definition at line 2374 of file translation_unit_visitor.cc.
|
private |
Definition at line 1922 of file translation_unit_visitor.cc.
|
private |
Definition at line 2981 of file translation_unit_visitor.cc.
void clanguml::sequence_diagram::visitor::translation_unit_visitor::finalize | ( | ) |
Finalize diagram model for this translation unit.
Definition at line 2965 of file translation_unit_visitor.cc.
|
private |
Initializes model message from comment call directive.
m | Message instance |
Definition at line 1933 of file translation_unit_visitor.cc.
|
private |
Definition at line 3376 of file translation_unit_visitor.cc.
|
inline |
Get participant by declaration.
T | Participant type |
decl | Clang entity declaration |
Definition at line 200 of file translation_unit_visitor.h.
|
inline |
Get participant by declaration.
T | Participant type |
decl | Clang entity declaration |
Definition at line 219 of file translation_unit_visitor.h.
|
inline |
Get participant by global element id.
T | Participant type |
id | Global element id |
Definition at line 238 of file translation_unit_visitor.h.
|
inline |
Get participant by global element id.
T | Participant type |
id | Global element id |
Definition at line 255 of file translation_unit_visitor.h.
std::optional< eid_t > clanguml::sequence_diagram::visitor::translation_unit_visitor::get_unique_id | ( | eid_t | local_id | ) | const |
Retrieve the global clang-uml
entity id based on the Clang local id.
local_id | AST local element id |
Definition at line 2600 of file translation_unit_visitor.cc.
|
private |
Check, the callee is a template specialization.
dependent_member_expr | Dependent member expression |
Definition at line 2345 of file translation_unit_visitor.cc.
|
private |
Check if template is a smart pointer.
primary_template | Template declaration |
Definition at line 2363 of file translation_unit_visitor.cc.
|
private |
Render lambda source location to string.
Returns exact source code location of the lambda expression in the form <filepath>:<line>:<column>.
The filepath is relative to the relative_to
config option.
source_location | Clang SourceLocation instance associated with lambda expression |
Definition at line 2721 of file translation_unit_visitor.cc.
|
private |
Assuming cls
is a lambda, create it's full name.
cls | Lambda declaration |
Definition at line 2736 of file translation_unit_visitor.cc.
|
private |
Move a message model to diagram.
expr | Call expression |
Definition at line 2826 of file translation_unit_visitor.cc.
|
private |
Definition at line 2929 of file translation_unit_visitor.cc.
|
private |
Definition at line 2893 of file translation_unit_visitor.cc.
|
private |
Definition at line 2911 of file translation_unit_visitor.cc.
|
private |
Definition at line 2857 of file translation_unit_visitor.cc.
|
private |
Definition at line 2947 of file translation_unit_visitor.cc.
|
private |
Definition at line 2876 of file translation_unit_visitor.cc.
|
private |
Definition at line 1525 of file translation_unit_visitor.cc.
|
private |
Handle a class method call expresion.
m | Message model |
method_call_expr | Operator call expression |
m
contains now a valid call expression model Definition at line 2151 of file translation_unit_visitor.cc.
|
private |
Handle a class template method call expresion.
m | Message model |
expr | Class template method call expression |
m
contains now a valid call expression model Definition at line 2185 of file translation_unit_visitor.cc.
|
private |
Definition at line 2679 of file translation_unit_visitor.cc.
|
private |
Handle CXX constructor call.
m | Message model |
construct_expr | CXX Construct expression |
m
contains a valid constructor call Definition at line 2078 of file translation_unit_visitor.cc.
|
private |
Definition at line 2011 of file translation_unit_visitor.cc.
|
private |
Handle a function call expresion.
m | Message model |
expr | Function call expression |
m
contains now a valid call expression model Definition at line 2270 of file translation_unit_visitor.cc.
|
private |
Definition at line 3221 of file translation_unit_visitor.cc.
|
private |
Definition at line 2299 of file translation_unit_visitor.cc.
|
private |
Definition at line 2104 of file translation_unit_visitor.cc.
|
private |
Handle a operator call expression.
m | Message model |
operator_call_expr | Operator call expression |
m
contains now a valid call expression model Definition at line 2040 of file translation_unit_visitor.cc.
|
private |
Handle an unresolved lookup call expresion.
Unresolved lookup expression is a reference to a name which Clang was not able to look up during parsing but could not resolve to a specific declaration.
m | Message model |
expr | Call expression |
m
contains now a valid call expression model Definition at line 2314 of file translation_unit_visitor.cc.
|
private |
Register a message model m
with a call expression.
This is used to know whether a model for a specific call expression has already been created, but not yet added to the diagram.
expr | Call expresion |
m | Message model |
Definition at line 2784 of file translation_unit_visitor.cc.
|
private |
Definition at line 2820 of file translation_unit_visitor.cc.
|
private |
Definition at line 2808 of file translation_unit_visitor.cc.
|
private |
Definition at line 2814 of file translation_unit_visitor.cc.
|
private |
Definition at line 2790 of file translation_unit_visitor.cc.
|
private |
Definition at line 2796 of file translation_unit_visitor.cc.
|
private |
Definition at line 2802 of file translation_unit_visitor.cc.
|
private |
Definition at line 3001 of file translation_unit_visitor.cc.
void clanguml::sequence_diagram::visitor::translation_unit_visitor::set_unique_id | ( | int64_t | local_id, |
eid_t | global_id | ||
) |
Store the mapping from local clang entity id (obtained using getID()) method to clang-uml global id.
local_id | Local AST element id |
global_id | Globa diagram element id |
Definition at line 2591 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a call expression.
expr | Call expression. |
Definition at line 3289 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a declaration.
decl | Clang declaration. |
Definition at line 3369 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a declaration.
decl | Clang declaration. |
Definition at line 3330 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a declaration.
decl | Clang declaration. |
Definition at line 3357 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a declaration.
decl | Clang declaration. |
Definition at line 3363 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a lambda expression.
expr | Lambda expression. |
Definition at line 3253 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include an ObjC declaration.
decl | Clang declaration. |
Definition at line 3246 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include an ObjC message expression.
expr | ObjC message expression. |
Definition at line 3271 of file translation_unit_visitor.cc.
|
private |
Definition at line 3345 of file translation_unit_visitor.cc.
|
private |
Check if the diagram should include a declaration.
decl | Clang declaration. |
Definition at line 3240 of file translation_unit_visitor.cc.
|
private |
Definition at line 2715 of file translation_unit_visitor.cc.
|
inlineprivate |
Get template builder reference.
Definition at line 566 of file translation_unit_visitor.h.
|
private |
Definition at line 605 of file translation_unit_visitor.h.
|
mutableprivate |
Definition at line 609 of file translation_unit_visitor.h.
|
private |
Definition at line 603 of file translation_unit_visitor.h.
|
private |
This is used to generate messages in proper order in case of nested call expressions (e.g. a(b(c(), d())), as they need to be added to the diagram sequence after the visitor leaves the call expression AST node
Definition at line 587 of file translation_unit_visitor.h.
|
private |
Definition at line 579 of file translation_unit_visitor.h.
|
private |
Definition at line 591 of file translation_unit_visitor.h.
|
private |
Definition at line 589 of file translation_unit_visitor.h.
|
private |
Definition at line 590 of file translation_unit_visitor.h.
|
private |
Definition at line 594 of file translation_unit_visitor.h.
|
private |
Definition at line 598 of file translation_unit_visitor.h.
|
private |
Definition at line 595 of file translation_unit_visitor.h.
|
mutableprivate |
Definition at line 612 of file translation_unit_visitor.h.
|
private |
Definition at line 588 of file translation_unit_visitor.h.
|
private |
Definition at line 614 of file translation_unit_visitor.h.
|
mutableprivate |
Definition at line 607 of file translation_unit_visitor.h.