Skip to content

Commit 21cea29

Browse files
authored
Merge pull request #320 from bkryza/add-objective-c-support-2
Add objective c support 2
2 parents a36f4ca + 90d21a3 commit 21cea29

File tree

407 files changed

+16644
-5261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+16644
-5261
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,33 @@ on:
2626

2727
jobs:
2828
build-ubuntu:
29-
runs-on: ubuntu-22.04
29+
runs-on: ubuntu-24.04
3030
steps:
3131
- name: Checkout repository
3232
uses: actions/checkout@v4
3333
- name: Update package database
3434
run: sudo apt -y update
3535
- name: ccache
3636
uses: hendrikmuhs/[email protected]
37+
with:
38+
max-size: "2000M"
3739
- name: Install deps
38-
run: sudo apt -y install git make pkg-config gcc-11 g++-11 ccache cmake libyaml-cpp-dev llvm-15 clang-15 libclang-15-dev libclang-cpp15-dev clang-format-15 lcov zlib1g-dev libunwind-dev libdw-dev
39-
- name: Select g++ version
40-
run: |
41-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
42-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11
40+
run: sudo apt -y install git make grcov ninja-build pkg-config gcc g++ ccache cmake libyaml-cpp-dev llvm-18 clang-18 libclang-18-dev libclang-cpp18-dev clang-format-18 lcov zlib1g-dev libunwind-dev libdw-dev gnustep-back-common libgnustep-base-dev gnustep-make
4341
- name: Check code formatting
4442
run: |
4543
make check-formatting
4644
- name: Build and unit test
4745
run: |
48-
NUMPROC=2 CODE_COVERAGE=ON LLVM_VERSION=15 make test
46+
CC=/usr/bin/clang-18 CXX=/usr/bin/clang++-18 LLVM_VERSION=18 NUMPROC=2 CMAKE_GENERATOR=Ninja CODE_COVERAGE=ON LLVM_VERSION=18 ENABLE_CXX_MODULES_TEST_CASES=ON ENABLE_CUDA_TEST_CASES=OFF ENABLE_OBJECTIVE_C_TEST_CASES=ON FETCH_LIBOBJC2=ON CLANG_UML_ENABLE_BACKTRACE=ON make test
4947
- name: Run coverage
5048
run: |
51-
lcov -c -d debug -o coverage.info
52-
lcov -r coverage.info -o coverage-src.info "$PWD/src/main.cc" "$PWD/src/common/generators/generators.cc"
53-
lcov -e coverage-src.info -o coverage-src.info "$PWD/src/*"
54-
lcov -l coverage-src.info
49+
grcov --llvm --binary-path debug --output-path coverage.info -t lcov --keep-only 'src/*' --source-dir . --ignore src/main.cc --ignore src/common/generators/generators.cc .
50+
lcov --ignore-errors inconsistent -l coverage.info
5551
- name: Upload coverage
5652
uses: codecov/codecov-action@v3
5753
with:
58-
files: coverage-src.info
54+
files: coverage.info
5955
disable_search: true
6056
name: clang-uml
6157
token: ${{ secrets.CODECOV_TOKEN }}
62-
fail_ci_if_error: false
58+
fail_ci_if_error: false

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: brew install llvm@18 ninja yaml-cpp cmake ccache
4141

4242
- name: Build and test
43-
run: CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ CMAKE_PREFIX=/opt/homebrew/opt/llvm/lib/cmake/llvm/ CMAKE_GENERATOR=Ninja CMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++" make test
43+
run: CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ CMAKE_PREFIX=/opt/homebrew/opt/llvm/lib/cmake/llvm/ CMAKE_GENERATOR=Ninja CMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++" ENABLE_OBJECTIVE_C_TEST_CASES=ON make test
4444

4545
- name: Print build version
4646
run: debug/src/clang-uml --version

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
* Added support for Objective C (#296)
4+
* Added option to fold repeated activities in sequence diagrams (#317)
5+
* Fixed default arguments braces in mermaid diagrams (#312)
6+
37
### 0.5.4
48
* Updated thirdparty dependencies (#306)
59
* Added regular expression support to remove_compile_flags (#303)

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ message(STATUS "clang-uml version: "
6666
#
6767
option(CODE_COVERAGE "" OFF)
6868
if(CODE_COVERAGE)
69-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fno-inline")
70-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage")
69+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g --coverage -fno-inline")
70+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g --coverage -fno-inline")
71+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
7172
endif(CODE_COVERAGE)
7273

7374
#
@@ -195,6 +196,8 @@ add_subdirectory(src)
195196
option(BUILD_TESTS "" ON)
196197
option(ENABLE_CXX_MODULES_TEST_CASES "" OFF)
197198
option(ENABLE_CUDA_TEST_CASES "" OFF)
199+
option(ENABLE_OBJECTIVE_C_TEST_CASES "" OFF)
200+
option(FETCH_LIBOBJC2 "" OFF)
198201

199202
#
200203
# Setup CUDA if available
@@ -207,6 +210,13 @@ if(ENABLE_CUDA_TEST_CASES)
207210
enable_language(CUDA)
208211
endif(ENABLE_CUDA_TEST_CASES)
209212

213+
if(ENABLE_OBJECTIVE_C_TEST_CASES)
214+
enable_language(OBJC)
215+
if(UNIX AND NOT APPLE)
216+
find_package(GNUstep REQUIRED)
217+
endif()
218+
endif(ENABLE_OBJECTIVE_C_TEST_CASES)
219+
210220
if(BUILD_TESTS)
211221
enable_testing()
212222
add_subdirectory(tests)

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ ADDRESS_SANITIZER ?= OFF
4242

4343
ENABLE_CXX_MODULES_TEST_CASES ?= OFF
4444
ENABLE_CUDA_TEST_CASES ?= OFF
45+
ENABLE_OBJECTIVE_C_TEST_CASES ?= OFF
46+
FETCH_LIBOBJC2 ?= OFF
4547

4648
GIT_VERSION ?= $(shell git describe --tags --always --abbrev=7)
4749
PKG_VERSION ?= $(shell git describe --tags --always --abbrev=7 | tr - .)
@@ -59,6 +61,7 @@ debug/CMakeLists.txt:
5961
cmake -S . -B debug \
6062
-G"$(CMAKE_GENERATOR)" \
6163
-DGIT_VERSION=$(GIT_VERSION) \
64+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
6265
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
6366
-DCMAKE_BUILD_TYPE=Debug \
6467
-DCMAKE_CXX_FLAGS="$(CMAKE_CXX_FLAGS)" \
@@ -69,6 +72,8 @@ debug/CMakeLists.txt:
6972
-DCMAKE_PREFIX=${CMAKE_PREFIX} \
7073
-DENABLE_CUDA_TEST_CASES=$(ENABLE_CUDA_TEST_CASES) \
7174
-DENABLE_CXX_MODULES_TEST_CASES=$(ENABLE_CXX_MODULES_TEST_CASES) \
75+
-DENABLE_OBJECTIVE_C_TEST_CASES=$(ENABLE_OBJECTIVE_C_TEST_CASES) \
76+
-DFETCH_LIBOBJC2=$(FETCH_LIBOBJC2) \
7277
-DCODE_COVERAGE=$(CODE_COVERAGE) \
7378
-DADDRESS_SANITIZER=$(ADDRESS_SANITIZER) \
7479
-DCLANG_UML_ENABLE_BACKTRACE=$(CLANG_UML_ENABLE_BACKTRACE)
@@ -78,6 +83,7 @@ release/CMakeLists.txt:
7883
cmake -S . -B release \
7984
-G"$(CMAKE_GENERATOR)" \
8085
-DGIT_VERSION=$(GIT_VERSION) \
86+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
8187
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
8288
-DCMAKE_BUILD_TYPE=Release \
8389
-DCMAKE_CXX_FLAGS="$(CMAKE_CXX_FLAGS)" \
@@ -89,12 +95,15 @@ release/CMakeLists.txt:
8995
-DADDRESS_SANITIZER=$(ADDRESS_SANITIZER) \
9096
-DENABLE_CUDA_TEST_CASES=$(ENABLE_CUDA_TEST_CASES) \
9197
-DENABLE_CXX_MODULES_TEST_CASES=$(ENABLE_CXX_MODULES_TEST_CASES) \
98+
-DENABLE_OBJECTIVE_C_TEST_CASES=$(ENABLE_OBJECTIVE_C_TEST_CASES) \
99+
-DFETCH_LIBOBJC2=$(FETCH_LIBOBJC2) \
92100
-DCLANG_UML_ENABLE_BACKTRACE=$(CLANG_UML_ENABLE_BACKTRACE)
93101

94102
debug_tidy/CMakeLists.txt:
95103
cmake -S . -B debug_tidy \
96104
-G"$(CMAKE_GENERATOR)" \
97105
-DGIT_VERSION=$(GIT_VERSION) \
106+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
98107
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
99108
-DCMAKE_BUILD_TYPE=Debug \
100109
-DBUILD_TESTS=OFF \
@@ -105,7 +114,9 @@ debug_tidy/CMakeLists.txt:
105114
-DLINK_LLVM_SHARED=${LLVM_SHARED} \
106115
-DCMAKE_PREFIX=${CMAKE_PREFIX} \
107116
-DENABLE_CUDA_TEST_CASES=$(ENABLE_CUDA_TEST_CASES) \
108-
-DENABLE_CXX_MODULES_TEST_CASES=$(ENABLE_CXX_MODULES_TEST_CASES)
117+
-DENABLE_CXX_MODULES_TEST_CASES=$(ENABLE_CXX_MODULES_TEST_CASES) \
118+
-DENABLE_OBJECTIVE_C_TEST_CASES=$(ENABLE_OBJECTIVE_C_TEST_CASES) \
119+
-DFETCH_LIBOBJC2=$(FETCH_LIBOBJC2)
109120

110121
debug: debug/CMakeLists.txt
111122
echo "Using ${NUMPROC} cores"
@@ -125,7 +136,7 @@ test_release: release
125136
CTEST_OUTPUT_ON_FAILURE=1 ctest --test-dir release
126137

127138
coverage_report: test
128-
lcov -c -d debug -o coverage.info
139+
lcov -c -d debug -o coverage.info --no-external --gcov-tool util/clang_gcov.sh
129140
lcov -r coverage.info -o coverage-src.info "${PWD}/src/main.cc" "${PWD}/src/common/generators/generators.cc"
130141
lcov -e coverage-src.info -o coverage-src.info "${PWD}/src/*"
131142
lcov -l coverage-src.info
@@ -171,11 +182,11 @@ init_compile_commands: debug
171182

172183
.PHONY: clang-format
173184
clang-format:
174-
docker run --rm -v $(CURDIR):/root/sources bkryza/clang-format-check:1.4
185+
docker run --rm -v $(CURDIR):/root/sources bkryza/clang-format-check:1.5
175186

176187
.PHONY: format
177188
format:
178-
docker run --rm -v $(CURDIR):/root/sources bkryza/clang-format-check:1.4
189+
docker run --rm -v $(CURDIR):/root/sources bkryza/clang-format-check:1.5
179190

180191
.PHONY: debug_tidy
181192
tidy: debug_tidy

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ types and contents of each generated diagram.
1717
The diagrams can be generated in [PlantUML](https://plantuml.com),
1818
[MermaidJS](https://mermaid.js.org/) and JSON formats.
1919

20-
`clang-uml` currently supports C++ up to version 17 with partial support for C++ 20.
20+
`clang-uml` currently supports C++ up to version 17 with partial support for C++ 20,
21+
as well as C and Objective-C.
2122

2223
Full documentation can be found at [clang-uml.github.io](https://clang-uml.github.io).
2324

@@ -45,6 +46,7 @@ Main features supported so far include:
4546
* C++20 concept constraints - [_example_](docs/test_cases/t00059.md)
4647
* C++20 coroutines - [_example_](docs/test_cases/t00069.md)
4748
* Diagram content filtering based on C++20 modules - [_example_](docs/test_cases/t00070.md)
49+
* Objective-C class diagrams - [_example_](docs/test_cases/t00084.md)
4850
* **Sequence diagram generation**
4951
* Generation of sequence diagram from specific method or function - [_example_](docs/test_cases/t20001.md)
5052
* Generation of loop and conditional statements - [_example_](docs/test_cases/t20021.md)
@@ -54,12 +56,14 @@ Main features supported so far include:
5456
* Handling of lambda expressions - [_example_](docs/test_cases/t20012.md)
5557
* Interactive links to online code to classes and call expressions - [_example_](https://raw.githubusercontent.com/bkryza/clang-uml/master/docs/test_cases/t20021_sequence.svg)
5658
* Support for CUDA Kernel and CUDA Device function calls - [_example_](docs/test_cases/t20050.md)
59+
* Objective-C sequence diagrams - [_example_](docs/test_cases/t20058.md)
5760
* **Package diagram generation**
5861
* Generation of package diagram based on C++ namespaces - [_example_](docs/test_cases/t30001.md)
5962
* Generation of package diagram based on subdirectories - [_example_](docs/test_cases/t30010.md)
6063
* Generation of package diagram based on C++20 modules - [_example_](docs/test_cases/t30014.md)
6164
* Dependencies between packages based on symbols used in the code - [_example_](docs/test_cases/t30002.md)
6265
* Interactive links to online code to packages - [_example_](https://raw.githubusercontent.com/bkryza/clang-uml/master/docs/test_cases/t30002_package.svg)
66+
* Objective-C package diagrams based on subdirectories - [_example_](docs/test_cases/t30016.md)
6367
* **Include graph diagram generation**
6468
* Show include graph for selected files - [_example_](docs/test_cases/t40001.md)
6569

@@ -88,6 +92,7 @@ Nowadays, this file can be generated rather easily using multiple methods:
8892
* For SCons, invoke `compilation_db` tool (requires SCons > 4.0.0)
8993
* For Bazel, try [bazel-compile-commands-extractor](https://github.com/hedronvision/bazel-compile-commands-extractor)
9094
* For Microsoft Visual Studio projects try [Clang Power Tools](https://www.clangpowertools.com)
95+
* For Objective-C based XCode projects see [xcpretty](https://github.com/xcpretty/xcpretty)
9196

9297
### Invocation
9398

0 commit comments

Comments
 (0)