Lachei / VulkanPBRT

Vulkan physically based raytracer including denoising
MIT License
28 stars 11 forks source link

clang-format and clang-tidy #36

Closed sven-luepke closed 2 years ago

sven-luepke commented 2 years ago

Following our short discussion on variable case type in #34, this PR adds .clang-format and .clang-tidy files and applied them to the whole source directory.

The most important style/format aspects in the files are:

sven-luepke commented 2 years ago

I updated the build instructions to generate a compilation database. @Lachei could you check if pre-commit works properly on linux with the updated commands?

Lachei commented 2 years ago

Running pre-commit works, however there are a few compiler errors found by clang-tidy:

clang-format.............................................................Passed
clang-tidy...............................................................Failed
- hook id: clang-tidy
- exit code: 1

/home/lachei/Dokumente/VulkanPBRT/source/renderModules/PBRTPipeline.cpp:33:16: error: use of undeclared identifier 'gBuffer'; did you mean 'g_buffer'? [clang-diagnostic-error]
        assert(gBuffer);
               ^~~~~~~
               g_buffer
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/lachei/Dokumente/VulkanPBRT/source/renderModules/PBRTPipeline.cpp:22:81: note: 'g_buffer' declared here
PBRTPipeline::PBRTPipeline(vsg::ref_ptr<vsg::Node> scene, vsg::ref_ptr<GBuffer> g_buffer,
                                                                                ^
14082 warnings generated.
Suppressed 14082 warnings (14082 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
14483 warnings and 1 error generated.
Error while processing /home/lachei/Dokumente/VulkanPBRT/source/renderModules/PBRTPipeline.cpp.
Suppressed 14483 warnings (14483 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler errors, but -fix-errors was not specified.
Fixes have NOT been applied.

Found compiler error(s).
/home/lachei/Dokumente/VulkanPBRT/source/buffers/IlluminationBuffer.cpp:38:12: error: use of undeclared identifier 'imageIndex' [clang-diagnostic-error]
    assert(imageIndex < illuminationImages.size());
           ^
/home/lachei/Dokumente/VulkanPBRT/source/buffers/IlluminationBuffer.cpp:38:25: error: use of undeclared identifier 'illuminationImages' [clang-diagnostic-error]
    assert(imageIndex < illuminationImages.size());
                        ^
16663 warnings generated.
Suppressed 16672 warnings (16663 in non-user code, 9 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
14126 warnings generated.
Suppressed 14126 warnings (14126 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
14120 warnings and 2 errors generated.
Error while processing /home/lachei/Dokumente/VulkanPBRT/source/buffers/IlluminationBuffer.cpp.
Suppressed 14120 warnings (14120 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler errors, but -fix-errors was not specified.
Fixes have NOT been applied.

I have fixed the errors (I guess the asserts were simply disabled in your configuration). Other than that ready to merge