Skip to content
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

clang-uml terminates with error #231

Closed
kahlenberg opened this issue Jan 18, 2024 · 7 comments
Closed

clang-uml terminates with error #231

kahlenberg opened this issue Jan 18, 2024 · 7 comments

Comments

@kahlenberg
Copy link

Hi,
I want to use clang-uml with a project that has a C++ code more than 20 years old! I just want to generate a class diagram.

I am using Windows 10 Enterprise, 64bit, Microsoft Visual Studio 17.8, cmake 3.27.6, clang++ version 16.0.5

I run the clang-uml command from terminal and after parsing a lot of file, I get following error:
[error] [tid 28768] [C:\clang-uml-tmp\clang-uml-042\src\common\generators\generators.cc:265] canonical: unknown error: "C:\workspace\app-build\C"

clang-uml --validate-only says that .clang-uml is valid.

@bkryza
Copy link
Owner

bkryza commented Jan 18, 2024

@kahlenberg This will be a problem related to absolute vs relative paths somewhere.

Any chance you could share your .clang-uml config and at least 1 entry from compile_commands.json?

If not please at least try to provide the following information:

  • are the paths to source files in your compile_commands.json relative or absolute?
  • do you have any glob patterns in your .clang-uml and are they relative to location of .clang-uml
  • where is your .clang-uml and where do you run clang-uml in relation to your sources
  • rerun clang-uml with -vvv flag and paste the output

@kahlenberg
Copy link
Author

kahlenberg commented Jan 18, 2024

Thanks for fast answer!

.clang-uml looks like:

# Change to directory where compile_commands.json is
compilation_database_dir: .
# Change to directory where diagram should be written
output_directory: docs/diagrams
diagrams:
  example_class_diagram:
    type: class
    glob:
      - "*.cpp"
remove_compile_flags:
  - -Wshadow=compatible-local
  - -Wstrict-null-sentinel
  - -Wno-maybe-uninitialized

compile_commands.json looks like:

```  {
\"directory\": \"C:/workspace/theapp-build/\",
\"command\": "\"C:/Program Files/LLVM/bin/clang++.exe\" -x c++ \"C:/workspace/theapp/app/my_app/my_app/main_window.cpp\" -std=c++17 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -m32 -fsyntax-only \"-D_MT\" \"-DWIN32\" \"-D_WINDOWS\" \"-D_DEBUG\" \"-DUSE_TRANSLATION\" \"-DSEG_USE_QTSINGLEAPPLICATION\" \"-DQT_CORE_LIB\" \"-DQT_GUI_LIB\" \"-DQT_WIDGETS_LIB\" \"-DQT_XML_LIB\" \"-DQT_NETWORK_LIB\" \"-DWITH_QT5\" \"-DNO_WARN_MBCS_MFC_DEPRECATION\" \"-D_WIN32_WINNT=0x502\" \"-DWINVER=0x502\" \"-DSEG_MFC=1\" \"-DSEG_my_app=1\" \"-D_CRT_SECURE_NO_DEPRECATE\" \"-D_CRT_NONSTDC_NO_DEPRECATE\" \"-D_CRT_NON_CONFORMING_SWPRINTFS\" \"-D_SCL_SECURE_NO_WARNINGS\" \"-DFFMPEG_STRCASE\" \"-DQT_NO_CAST_FROM_ASCII\" \"-DQT_NO_CAST_TO_ASCII\" \"-DLINK_PROT_2\" \"-D_CRT_SECURE_NO_WARNINGS\" \"-DLOG4CPLUS_STATIC\" \"-DTIXML_USE_TICPP\" \"-DNOMINMAX\" \"-DPLATFORM_WIN32\" \"-DVC_EXTRALEAN\" \"-DQTWINMIGRATE_WITHMFC\" \"-DQT_CONCURRENT_LIB\" \"-DQT_OPENGL_LIB\" \"-DQT_PRINTSUPPORT_LIB\" \"-DQT_MULTIMEDIA_LIB\" \"-DQT_SERIALPORT_LIB\" \"-DQT_SQL_LIB\" \"-DQT_STATICPLUGIN\" \"-DQT_SVG_LIB\" \"-DCMAKE_INTDIR=/\"Debug/\"\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtCore\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/./mkspecs/win32-msvc2015\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtGui\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtWidgets\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtXml\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtNetwork\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtConcurrent\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtOpenGL\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtPrintSupport\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtMultimedia\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtSerialPort\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtSql\" -isystem\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtSvg\" -I\"C:/workspace/theapp-build/app/my_app/my_app\" -I\"C:/workspace/theapp/app/my_app/my_app\" -I\"C:/workspace/theapp-build/app/my_app/my_app/my_app_autogen/include_Debug\" -I\"C:/workspace/theapp-build/cmake\" -I\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtCore/5.6.0\" -I\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtCore/5.6.0/QtCore\" -I\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtGui/5.6.0\" -I\"C:/workspace/sw_build_libs/Qt/qt-win-5.6.0/include/QtGui/5.6.0/QtGui\" -I\"C:/workspace/theapp/libs/S3DLibrary\" -I\"C:/workspace/sw_build_libs/boost/include/boost-1_55\" -I\"C:/workspace/sw_build_libs/Rockey/include\" -I\"C:/workspace/sw_build_libs/log4cplus/include\" -I\"C:/workspace/theapp\" -I\"C:/workspace/theapp/libs\" -I\"C:/workspace/theapp-build\" -I\"C:/workspace/theapp-build/libs\" -I\"C:/workspace/theapp/libs/TestingFramework\" -I\"C:/workspace/theapp/libs/sw_lib\" -I\"C:/workspace/theapp/libs/SharedSources_PCSW_Embedded\" -I\"C:/workspace/theapp/app/my_app/my_appQt\" -I\"C:/workspace/theapp/app/my_app/.\" -I\"C:/workspace/theapp-build/app/my_app\" -I\"C:/workspace/theapp/libs/sw_lib/QtWidgets/SegDockArea\" -I\"C:/workspace/sw_build_libs/SchiebelSimulationLibrary/include\" -I\"C:/workspace/theapp/app/Plugins\",
\"file\": \"C:/workspace/theapp/app/my_app/my_app/main_window.cpp\"

} ```

The source code is in C:/workspace/theapp/app/my_app/my_app/*.cpp and the build directory is C:/workspace/theapp-build/
`.clang-uml` and   `compile_commands.json` are in C:/workspace/theapp/app/my_app/my_app/ and I run clang-uml in the same directory

@bkryza
Copy link
Owner

bkryza commented Jan 18, 2024

@kahlenberg Ok, I'll try to reproduce although I think this might be related to another issue I've already fixed it (https://github.com/bkryza/clang-uml/pull/220/commits), unfortunately it's in master branch only not in the 0.4.2 release.

I'm hoping to release the next version early next week...

As a test, could you make the following changes:

  • in your compile_commands.json just change this one entry:
      "file": "C:/workspace/theapp/app/my_app/my_app/main_window.cpp"
    
    to
      "file": "main_window.cpp"
    

and in your .clang-uml set the glob for only this file for now:

# ...
diagrams:
  example_class_diagram:
    type: class
    glob:
      - main_window.cpp
# ...

@kahlenberg
Copy link
Author

It cannot find the file:

[debug] [tid 2384] [C:\clang-uml-tmp\clang-uml-042\src\config\config.cc:242] Searching glob path C:\workspace\theapp\app\my_app\my_app/main_window.cpp                                                                                       
[error] [tid 2384] [C:\clang-uml-tmp\clang-uml-042\src\common\generators\generators.cc:238] Diagram example_class_diagram generation failed: no translation units found. Please make sure that your 'glob' patterns match at least 1 file in 'compile_commands.json'. 

But if I use the whole absolute path "file": "C:/workspace/theapp/app/my_app/my_app/main_window.cpp", then it finds and starts and again I get the error:
[error] [tid 24872] [C:\clang-uml-tmp\clang-uml-042\src\common\generators\generators.cc:265] canonical: unknown error: "C:\workspace\theapp-build\C"

Before that, I get another error, this is the first error:

In file included from C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/include\string:8:
C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/include\yvals_core.h:887:1: error: static assertion failed: Error in C++ Standard Library usage.
_EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 16.0.0 or newer.");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am using clang version 16.0.5

@bkryza
Copy link
Owner

bkryza commented Jan 18, 2024

@kahlenberg I can't seem to be able to reproduce it, however I've published a release candidate for the next release just for MSVC, could please check if this one fixes this issue (preferably using your unmodified compile_commands and .clang-uml config:

https://github.com/bkryza/clang-uml/releases/tag/0.4.3-rc1

@kahlenberg
Copy link
Author

Thanks for RC, it seems to be working. Now I was able to generate .puml file for a specific cpp file. Now I must figure out how I can convert puml to svg on Windows :) Do you know how I can convert it?

@bkryza
Copy link
Owner

bkryza commented Jan 22, 2024

@kahlenberg You can simply download the PlantUML in jar form (it requires Java) from here: https://plantuml.com/starting

Also, if you don't want to install anything you can generate an image using online PlantUML server: https://planttext.com/, just paste the contents of the generated .puml.

@bkryza bkryza closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants