-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No translation units found #337
Comments
@ppetrov75 Can you share the contents of your |
Thank you. I shortened a little, removed many includes.
|
@ppetrov75 Ok, the problem is that your build generator created the compile commands with files relative to Either change the patterns in relative_to: src |
sorry I did mistake
I checked this file in the clang-uml project:
here path to file is full. now:
option exclude doesn't help
Thank you |
@ppetrov75 Relative paths definitely used to work, but maybe there is a regression - I'll check. As to your second error, those kinds of errors (assuming your code actually compiles) are relative to invalid or missing paths to system headers. The easiest option to overcome them is to add the following option to clang-uml command line Out of curiosity, what tool are you using to generate |
I use grailbio/bazel-compilation-database . It's old and there recommended to switch on hedronvision/bazel-compile-commands-extractor or bazel-stack-vscode-cc. I tried first and same problem, maybe required some time. It started to work, I see class diagram now. I replaced clang on clang++, added full paths, and call with --query_command . . Which one helped I don't know. ) sequence diagram still not generated.
in Main.cpp:
Thank you! |
@ppetrov75 Ok, so there is progress at least. In case of the sequence diagrams, you have to specify the |
@ppetrov75 I need more information to reproduce the problem. Can you share entire contents of |
.clang-uml:
Main.cpp:
A.h:
A.cpp:
|
output with -vvv:
|
@ppetrov75 This is very strange. I created a small CMake project using your exact files, I just added the cmake_minimum_required(VERSION 3.15)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(Issue337 LANGUAGES CXX)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(Main src/dir2/Main.cpp src/dir1/A.cpp) and the output log I get at the end is: [trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:523] --- Participants ---
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:525] 1384446150650511929 - Participant 'method': id=1384446150650511929, name=ns::A::foo(), class_id=5106305860160781827
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:525] 2963991483338076281 - Participant 'function': id=2963991483338076281 name=handling()
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:525] 5106305860160781827 - Participant 'class': id=5106305860160781827 name=ns::A
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:525] 10172215697977537271 - Participant 'method': id=10172215697977537271, name=ns::A::A(), class_id=5106305860160781827
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:525] 10203697914391728678 - Participant 'function': id=10203697914391728678 name=main(int,const char **)
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:525] 18026605205433578579 - Participant 'function': id=18026605205433578579 name=main_end()
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:528] --- Activities ---
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:533] Sequence id=10203697914391728678:
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:537] Activity id=10203697914391728678, from=main(int,const char **):
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:561] Message from=main(int,const char **), from_id=10203697914391728678, to=handling(), to_id=2963991483338076281, name=handling, type=call, comment=None
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:561] Message from=main(int,const char **), from_id=10203697914391728678, to=ns::A::A(), to_id=10172215697977537271, name=ns::A::A, type=call, comment=None
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:561] Message from=main(int,const char **), from_id=10203697914391728678, to=ns::A::foo(), to_id=1384446150650511929, name=foo, type=call, comment=None
[trace] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/model/diagram.cc:561] Message from=main(int,const char **), from_id=10203697914391728678, to=main_end(), to_id=18026605205433578579, name=main_end, type=call, comment=None
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:682] Found sequence diagram start point: 10203697914391728678
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:197] Generating message [10203697914391728678] --> [2963991483338076281]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:129] Generated call '' from main(int,const char **) [10203697914391728678] to handling() [2963991483338076281]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:215] Skipping activity 10203697914391728678 --> 2963991483338076281 - missing sequence 2963991483338076281
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:197] Generating message [10203697914391728678] --> [10172215697977537271]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:129] Generated call 'A()' from main(int,const char **) [10203697914391728678] to ns::A::A() [10172215697977537271]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:215] Skipping activity 10203697914391728678 --> 10172215697977537271 - missing sequence 10172215697977537271
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:197] Generating message [10203697914391728678] --> [1384446150650511929]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:129] Generated call 'foo()' from main(int,const char **) [10203697914391728678] to ns::A::foo() [1384446150650511929]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:215] Skipping activity 10203697914391728678 --> 1384446150650511929 - missing sequence 1384446150650511929
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:197] Generating message [10203697914391728678] --> [18026605205433578579]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:129] Generated call '' from main(int,const char **) [10203697914391728678] to main_end() [18026605205433578579]
[debug] [tid 453951] [/home/bartek/devel/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:215] Skipping activity 10203697914391728678 --> 18026605205433578579 - missing sequence 18026605205433578579
[info] [tid 453951] [/home/bartek/devel/clang-uml/src/common/generators/generators.cc:118] Written sequence_diagram diagram to /home/bartek/devel/clang-uml-issues/337/sequence_diagram.puml and the diagram: @startuml
participant "main(int,const char **)" as C_0010203697914391728678
activate C_0010203697914391728678
participant "handling()" as C_0002963991483338076281
C_0010203697914391728678 -> C_0002963991483338076281 :
activate C_0002963991483338076281
deactivate C_0002963991483338076281
participant "A" as C_0005106305860160781827
C_0010203697914391728678 -> C_0005106305860160781827 : A()
activate C_0005106305860160781827
deactivate C_0005106305860160781827
C_0010203697914391728678 -> C_0005106305860160781827 : foo()
activate C_0005106305860160781827
deactivate C_0005106305860160781827
participant "main_end()" as C_0018026605205433578579
C_0010203697914391728678 -> C_0018026605205433578579 :
activate C_0018026605205433578579
deactivate C_0018026605205433578579
deactivate C_0010203697914391728678
'Generated with clang-uml, version 0.5.5-37-g7e28757
'LLVM version Ubuntu clang version 18.1.8 (++20240731025043+3b5b5c1ec4a3-1~exp1~20240731145144.92)
@enduml
From the log you've sent me it seems on your side, Clang is not visiting the |
I built on last master: cb03149
maybe built not right?
|
@ppetrov75
But that is impossible with the |
Good day. I tried on small project with cmake. The tool works fine:
config:
it's not required even include all files, additional includes namespaces etc:
Regarding real project. I tried to build sequence diagram inside class. It doesn't build sequences for different namespaces, classes or even maybe for other files. Maybe some fix with not strict filtering rules will help. ) Thank you. |
@ppetrov75 I've created a branch If you still can't figure out the issue, please paste also the output of |
@ppetrov75 Also, I've just fixed a small regression I found today that impacted filtering sequence diagrams using |
Hello. I tried clang-uml based on issue-337. I didn't find any "rejected" message in out like "... rejected by namespace_filter" just "Skipping call expression at". I tried to place files in one directory, corrected paths in compile_commands.json and it started to work (I didn't understand yet it took all dependencies or not ). compile_commands.json and sources are input data for processing clang-uml. No more dependencies? Then it looks there are some problem with compile_commands.json ? I checked there all paths to files are correct. It didn't work before probably because paths were relative, I changed on full. No more idea. ) it's part of compile_commands.json for short project:
If I change here paths on relative it doesn't find files. Thank you. |
@ppetrov75 Ok, just to be sure, can you also try on the latest If it doesn't help, please paste the output of |
Yes. I tried latest master, issue-337 and rebased issue337 on the latest master. |
@ppetrov75 I don't have any more ideas really, so I created a repository https://github.com/bkryza/issue337, with your example and your ❯ ~/devel/clang-uml/debug/src/clang-uml -n sequence_diagram
[info] [tid 1929778] [/home/bartek/devel/clang-uml/src/cli/cli_handler.cc:306] Loaded clang-uml config from .clang-uml
[info] [tid 1929778] [/home/bartek/devel/clang-uml/src/cli/cli_handler.cc:334] Loading compilation database from /home/bartek/devel/clang-uml-issues/337/test/debug directory
[info] [tid 1929789] [/home/bartek/devel/clang-uml/src/common/generators/generators.h:367] Generating diagram sequence_diagram
[info] [tid 1929789] [/home/bartek/devel/clang-uml/src/common/generators/clang_tool.cc:161] Processing diagram 'sequence_diagram' translation unit: /home/bartek/devel/clang-uml-issues/337/test/src/dir1/A.cpp
[info] [tid 1929789] [/home/bartek/devel/clang-uml/src/common/generators/clang_tool.cc:161] Processing diagram 'sequence_diagram' translation unit: /home/bartek/devel/clang-uml-issues/337/test/src/Main.cpp
[info] [tid 1929789] [/home/bartek/devel/clang-uml/src/common/generators/generators.cc:118] Written sequence_diagram diagram to /home/bartek/devel/clang-uml-issues/337/test/sequence_diagram.puml
❯ cat sequence_diagram.puml
@startuml
participant "main(int,const char **)" as C_0010203697914391728678
activate C_0010203697914391728678
participant "handling()" as C_0002963991483338076281
C_0010203697914391728678 -> C_0002963991483338076281 :
activate C_0002963991483338076281
deactivate C_0002963991483338076281
participant "A" as C_0005106305860160781827
C_0010203697914391728678 -> C_0005106305860160781827 : A()
activate C_0005106305860160781827
deactivate C_0005106305860160781827
C_0010203697914391728678 -> C_0005106305860160781827 : foo()
activate C_0005106305860160781827
deactivate C_0005106305860160781827
participant "main_end()" as C_0018026605205433578579
C_0010203697914391728678 -> C_0018026605205433578579 :
activate C_0018026605205433578579
deactivate C_0018026605205433578579
deactivate C_0010203697914391728678
'Generated with clang-uml, version 0.5.5-39-g9d86ae1
'LLVM version Ubuntu clang version 18.1.8 (++20240731025043+3b5b5c1ec4a3-1~exp1~20240731145144.92)
@enduml
If this doesn't work for you - the only idea I have left is that there something wrong with your LLVM/Clang installation - are you able to install/build another version of LLVM on your machine? |
@ppetrov75 In theory yes, but you would have to specify the layout constraint for every pair of classes like so: layout:
ClassA:
- up: ClassB not really practical in your case, but in PlantUML you change the orientation of the layout to vertical, try adding the following diagrams:
mydiagram:
type: class
...
plantuml:
before:
- left to right direction |
@ppetrov75 Not sure what you mean by aggregated types specifically, but checkout the filters documentation here and also some of the test cases: t00040 or t00041. |
Hello. some details:
cat /usr/lib/clang/17/include/stdarg.h:
The same problem with another external library. As I understood there is problem with spelling some method and It cancel call completely. Is it possible to mask problem calls in config ? Thank you. |
@ppetrov75 The log "Skipping call expression at" is fine in general, it means that according to the diagram filters you don't want that call in your diagram (or at least it should be). Can you share the config for this diagram, the line of code at |
Forgot to write after "Skipping call expression at" usually "Skipping call expression due to filter at" with same message after "at:" config:
in file1.cpp:N:
some kind of https://en.cppreference.com/w/cpp/utility/variadic/va_start |
@ppetrov75 Ok, the problem is that you have no filters, i.e. this will try to include all calls. The easiest way to limit your diagram to calls within your codebase, just add: include:
paths:
- . |
Sorry. It didn't help. i tried on small project:
src
it looks it tries to find inside _builtin_va*:
|
@ppetrov75 Ok, thanks for the example, I will try to reproduce on my side today evening. |
@ppetrov75 One more question - what was the error in that small example? No diagram generated? Missing call? If you got any diagram generated from the above example, can you paste it here? |
Diagram is generated. It's correct. But in log:
It searchs __builtin_va_start, __builtin_va_end. If it is not found we have "Skipping call". |
Ok, sorry I thought you weren't getting a valid diagram. I've tried to reproduce and I also get the correct diagram. The thing is that when analysing function which should be in the diagram (e.g. Now going back to your original problem, you mention that:
If you have a call to these functions and they cannot be resolved by Clang in your header search path, then you should get an error and no diagram should be generated. Is that the case? If yes then you need to adjust your compile commands so that these functions are resolved properly. If not, can you explain the issue in more detail? What exactly is the problem in the end beside the logs? Preferably with example showing piece of code, the output diagram, and what is missing (or what is too much)? |
I don't know what is real problem why diagrams are not built in some cases. We see "Skipping call expression due to filter at" and points on some sequence of externals headers. |
I still don't understand what do you mean by possible here? If you have a case that a diagram is not generated at all, this means that there is an issue with your compilation database (e.g. include paths), and there is now way around this. |
It looks that it built some tree until "unknown" call. There are some messages in log:
until:
finally diagram
|
@ppetrov75 Ok this is interesting, but can you modify the above simple example with add_nums so that it fails in the same way? I found this SO discussion that I think discusses the same issue - I will try to investigate... |
@ppetrov75 I added a test case t20062 https://github.com/bkryza/clang-uml/blob/add-vaargs-test-case/docs/test_cases/t20062.md in branch |
Hello.
I just started to use clang-uml and maybe do not right.
I use simple .clang-uml:
output of call clang-uml -vvv :
I see info about files searched by glob at compile_commands.json . But diagrams are not generated.
If I use parameter path instead glob then number of translation much bigger but result is same.
I would appreciate if you point me right way to get build diagrams.
Thank you.
The text was updated successfully, but these errors were encountered: