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

Moving DerivedFnCollector out of ClangPlugin #868

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

vaithak
Copy link
Collaborator

@vaithak vaithak commented Apr 25, 2024

This is part of the initial refactoring required to remove direct access to ClangPlugin methods.

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.81%. Comparing base (91308b8) to head (b00c0c1).
Report is 5 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #868      +/-   ##
==========================================
+ Coverage   94.77%   94.81%   +0.04%     
==========================================
  Files          49       51       +2     
  Lines        7596     7618      +22     
==========================================
+ Hits         7199     7223      +24     
+ Misses        397      395       -2     
Files Coverage Δ
include/clad/Differentiator/DerivativeBuilder.h 100.00% <ø> (ø)
include/clad/Differentiator/DerivedFnCollector.h 100.00% <100.00%> (ø)
include/clad/Differentiator/DerivedFnInfo.h 100.00% <100.00%> (ø)
lib/Differentiator/BaseForwardModeVisitor.cpp 98.81% <100.00%> (+<0.01%) ⬆️
lib/Differentiator/DerivativeBuilder.cpp 98.98% <100.00%> (+0.02%) ⬆️
lib/Differentiator/DerivedFnCollector.cpp 100.00% <100.00%> (ø)
lib/Differentiator/DerivedFnInfo.cpp 100.00% <100.00%> (ø)
lib/Differentiator/ReverseModeVisitor.cpp 97.18% <100.00%> (+0.01%) ⬆️
tools/ClangPlugin.cpp 95.63% <100.00%> (-0.32%) ⬇️
tools/ClangPlugin.h 94.02% <100.00%> (-0.05%) ⬇️

... and 3 files with indirect coverage changes

Files Coverage Δ
include/clad/Differentiator/DerivativeBuilder.h 100.00% <ø> (ø)
include/clad/Differentiator/DerivedFnCollector.h 100.00% <100.00%> (ø)
include/clad/Differentiator/DerivedFnInfo.h 100.00% <100.00%> (ø)
lib/Differentiator/BaseForwardModeVisitor.cpp 98.81% <100.00%> (+<0.01%) ⬆️
lib/Differentiator/DerivativeBuilder.cpp 98.98% <100.00%> (+0.02%) ⬆️
lib/Differentiator/DerivedFnCollector.cpp 100.00% <100.00%> (ø)
lib/Differentiator/DerivedFnInfo.cpp 100.00% <100.00%> (ø)
lib/Differentiator/ReverseModeVisitor.cpp 97.18% <100.00%> (+0.01%) ⬆️
tools/ClangPlugin.cpp 95.63% <100.00%> (-0.32%) ⬇️
tools/ClangPlugin.h 94.02% <100.00%> (-0.05%) ⬇️

... and 3 files with indirect coverage changes

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

include/clad/Differentiator/DerivedFnInfo.h Outdated Show resolved Hide resolved
include/clad/Differentiator/DerivedFnInfo.h Outdated Show resolved Hide resolved
lib/Differentiator/DerivativeBuilder.cpp Show resolved Hide resolved
lib/Differentiator/DerivedFnCollector.cpp Outdated Show resolved Hide resolved
lib/Differentiator/DerivedFnCollector.cpp Outdated Show resolved Hide resolved
lib/Differentiator/DerivedFnCollector.cpp Outdated Show resolved Hide resolved
lib/Differentiator/DerivedFnCollector.cpp Outdated Show resolved Hide resolved
lib/Differentiator/DerivedFnCollector.cpp Outdated Show resolved Hide resolved
@@ -122,7 +122,7 @@ namespace clad {
Sema& S = m_CI.getSema();

if (!m_DerivativeBuilder)
m_DerivativeBuilder.reset(new DerivativeBuilder(S, *this));
m_DerivativeBuilder.reset(new DerivativeBuilder(S, *this, m_DFC));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use std::make_unique instead [modernize-make-unique]

Suggested change
m_DerivativeBuilder.reset(new DerivativeBuilder(S, *this, m_DFC));
m_DerivativeBuilder = std::make_unique<DerivativeBuilder>(S, *this, m_DFC);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want to apply this suggestion?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that’s only available in c++14 onward.

@@ -122,7 +122,7 @@
Sema& S = m_CI.getSema();

if (!m_DerivativeBuilder)
m_DerivativeBuilder.reset(new DerivativeBuilder(S, *this));
m_DerivativeBuilder.reset(new DerivativeBuilder(S, *this, m_DFC));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: initializing non-owner argument of type 'std::unique_ptrclad::DerivativeBuilder::pointer' (aka 'clad::DerivativeBuilder *') with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]

        m_DerivativeBuilder.reset(new DerivativeBuilder(S, *this, m_DFC));
                                  ^

@@ -0,0 +1,40 @@
#ifndef CLAD_DIFFERENTIATOR_DERIVEDFNCOLLECTOR_H
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move that header file and its friends in lib?

Copy link
Collaborator Author

@vaithak vaithak Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason as to why we want to move this header file to lib? I thought all header files go in include directory.

Copy link
Owner

@vgvassilev vgvassilev Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These header files are "local"/"implementation internal" files that are related to the build artifact not the user interface. That is, we do not need to have them installed for clad to work...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it, but the issue is that this file is imported by DerivativeBuilder.h, which is further imported by all the Visitors.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair enough.

Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vgvassilev vgvassilev merged commit d879f1b into vgvassilev:master Apr 25, 2024
89 checks passed
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

Successfully merging this pull request may close these issues.

2 participants