clang-uml icon indicating copy to clipboard operation
clang-uml copied to clipboard

Can't find relationships between files

Open CyCle1024 opened this issue 2 years ago • 3 comments

test.h:

namespace test1 {

template <typename T>
class TestBase {
public:
  TestBase() = delete;
  ~TestBase() = default;
  TestBase(int a_, float b_, T c_) : a(a_), b(b_), c(c_) {};
  int a;
  float b;
  T c;
};

}

test.cc:

#include <test.h>

namespace test1 {

template class TestBase<double *>;

class TestDerive : public TestBase<double *> {
public:
  TestDerive(int a_, float b_, double *c_);
};

TestDerive::TestDerive(int a_, float b_, double *c_) : TestBase<double *>(a_, b_, c_) {
  a += 1;
  b -= 1;
}

}

result test.puml:

@startuml
class "test1::TestBase<double*>" as C_0000000002
class C_0000000002 {
}
class "test1::TestDerive" as C_0000000011
class C_0000000011 {
{static} +TestDerive(int a_, float b_, double* c_) : void
}
class "test1::TestBase<T>" as C_0000000016
class C_0000000016 {
{static} +TestBase() : void
{static} +~TestBase() : void
{static} +TestBase(int a_, float b_, T c_) : void
+a : int
+b : float
+c : T
}
C_0000000002 <|-- C_0000000011
@enduml

rendered pic: image

CyCle1024 avatar May 17 '22 16:05 CyCle1024

@CyCle1024 Thanks for the detailed issue description. I'll into that this week...

If you're in a hurry, you can try to rebuild clang-uml from branch improve-alias-template-generation, where I'm currently refactoring template instantiation relationships - I'm hoping to finalize it in the next week or two but I need to resolve a few edge cases...

If all else fails you can add the relationship for now by hand in the .clang-uml configuration file in the plantuml section, e.g.:

diagrams:
  mydiagram:
    type: class
    #...
    plantuml:
      after:
        - '{{ alias("test1::TestBase<double*>") }} --|> {{ alias("test1::TestBase<T>") }}'

bkryza avatar May 17 '22 16:05 bkryza

@bkryza Thanks for rely ! I'm not in hurry.

I found sth detailed... The .clang-uml used to generate problem uml is:

compilation_database_dir: ./build
output_directory: .
diagrams:
  test:
    type: class
    glob:
      - **/test.cc
      - **/test.h
    include:
      - test1
      - test2

If I change the glob part into (** is some path of my project):

....
    glob:
      - **/test.cc
      - **/test.h

The relationship can be found.

Correct .clang-uml:

compilation_database_dir: ./build
output_directory: .
diagrams:
  test:
    type: class
    glob:
      - **/test.h
      - **/test.cc
    include:
      - test1
      - test2

Correct test.puml:

@startuml
class "test1::TestBase<T>" as C_0000000003
class C_0000000003 {
{static} +TestBase() : void
{static} +~TestBase() : void
{static} +TestBase(int a_, float b_, T c_) : void
+a : int
+b : float
+c : T
}
class "test1::TestBase<double*>" as C_0000000007
class C_0000000007 {
}
class "test1::TestDerive" as C_0000000016
class C_0000000016 {
{static} +TestDerive(int a_, float b_, double* c_) : void
}
C_0000000007 ..|> C_0000000003
C_0000000007 <|-- C_0000000016
@enduml

Correct rendered diagram: image

CyCle1024 avatar May 17 '22 16:05 CyCle1024

@CyCle1024 Ok thanks - in that case this another issue related to the glob search pattern processing - thanks for pointing it out! I'll look into it nevertheless...

bkryza avatar May 17 '22 16:05 bkryza

@CyCle1024 This is now fixed since 0.2.0, there is a test case checking for that:

  • https://github.com/bkryza/clang-uml/blob/master/docs/test_cases/t00048.md

bkryza avatar Sep 03 '22 19:09 bkryza

@bkryza Thx a lot!

CyCle1024 avatar Sep 04 '22 16:09 CyCle1024