clang-uml: clang-uml does not handle types in the root namespace correctly

Example:

I have a class MyPos in the root namespace, and a class MyPos3D (and MyPos2D) that inherits (publicly) from MyPos. However, clang-uml skips the inheritance because it does not understand that ::MyPos is identical to MyPos in this case.

If I enclose the class definitions in namespace test, it does work as expected (it would require synthetically modifying hundreds of source files, however).

please tell me if you need more verbose logs

[debug] [tid 12621] [translation_unit_visitor.cc:415] Setting user data for class MyPos, 0x7f188d660260
[debug] [tid 12621] [diagram.cc:117] Adding class: ::MyPos, MyPos
[debug] [tid 12621] [nested_trait.h:63] Adding nested element MyPos at path ''
[debug] [tid 12621] [nested_trait.h:83] Getting nested element at path: MyPos
[debug] [tid 12621] [translation_unit_visitor.cc:138] ========== Visiting 'MyPos' - class

...

[debug] [tid 12621] [translation_unit_visitor.cc:619] Found base class ::MyPos for class MyPos3D
[debug] [tid 12621] [translation_unit_visitor.cc:415] Setting user data for class MyPos3D, 0x7f188c303da0
[debug] [tid 12621] [diagram.cc:117] Adding class: ::MyPos3D, MyPos3D
[debug] [tid 12621] [diagram.cc:149] Class MyPos3D (MyPos3D) already in the model

...

[debug] [tid 12621] [diagram.cc:199] Looking for alias for ::MyPos
[debug] [tid 12621] [class_diagram_generator.cc:326] === Skipping inheritance relation from ::MyPos to MyPos3D due to: Missing alias for ::MyPos

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

@meastp I’m glad you were able to get it working 😃

As to the custom smart pointers, I have todo for this to add this to config file, for now if you don’t mind modifying the source yourself you can extend the if-else block here

with sth like (assuming myptr::clone_ptr is a template type smart pointer?):

    if (tr_unaliased_declaration.find("std::shared_ptr") == 0) {
        nested_relationship_hint = relationship_t::kAssociation;
    }
    else if (tr_unaliased_declaration.find("std::weak_ptr") == 0) {
        nested_relationship_hint = relationship_t::kAssociation;
    }
    else if (tr_unaliased_declaration.find("myptr::clone_ptr") == 0) {
        nested_relationship_hint = relationship_t::kAggregation; // or relationship_t::kComposition
    }

Btw please don’t close the issue - I have 1 or 2 more edge cases related to the root namespace references I want to test and then I’ll close it when merging to master…