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

Pass the DiffRequest down to the visitors. NFC. #933

Merged
merged 3 commits into from
Jun 11, 2024
Merged

Conversation

vgvassilev
Copy link
Owner

@vgvassilev vgvassilev commented Jun 11, 2024

The intent of this patch is to centralize the information about the diff request in one place. This will help upcoming patches to reduce the state of the visitors and refactor some of the implementation in a common place.

That will unblock work on #721.

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.72%. Comparing base (340ad91) to head (72052cb).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #933   +/-   ##
=======================================
  Coverage   93.72%   93.72%           
=======================================
  Files          53       54    +1     
  Lines        7773     7781    +8     
=======================================
+ Hits         7285     7293    +8     
  Misses        488      488           
Files Coverage Δ
demos/ErrorEstimation/CustomModel/CustomModel.h 100.00% <100.00%> (ø)
demos/ErrorEstimation/PrintModel/PrintModel.h 100.00% <100.00%> (ø)
...clude/clad/Differentiator/BaseForwardModeVisitor.h 100.00% <ø> (ø)
include/clad/Differentiator/DiffPlanner.h 68.18% <100.00%> (+1.51%) ⬆️
include/clad/Differentiator/EstimationModel.h 100.00% <100.00%> (ø)
include/clad/Differentiator/HessianModeVisitor.h 100.00% <100.00%> (ø)
...clude/clad/Differentiator/PushForwardModeVisitor.h 100.00% <ø> (ø)
...e/clad/Differentiator/ReverseModeForwPassVisitor.h 100.00% <ø> (ø)
include/clad/Differentiator/ReverseModeVisitor.h 97.84% <ø> (ø)
...clad/Differentiator/VectorPushForwardModeVisitor.h 100.00% <ø> (ø)
... and 12 more
Files Coverage Δ
demos/ErrorEstimation/CustomModel/CustomModel.h 100.00% <100.00%> (ø)
demos/ErrorEstimation/PrintModel/PrintModel.h 100.00% <100.00%> (ø)
...clude/clad/Differentiator/BaseForwardModeVisitor.h 100.00% <ø> (ø)
include/clad/Differentiator/DiffPlanner.h 68.18% <100.00%> (+1.51%) ⬆️
include/clad/Differentiator/EstimationModel.h 100.00% <100.00%> (ø)
include/clad/Differentiator/HessianModeVisitor.h 100.00% <100.00%> (ø)
...clude/clad/Differentiator/PushForwardModeVisitor.h 100.00% <ø> (ø)
...e/clad/Differentiator/ReverseModeForwPassVisitor.h 100.00% <ø> (ø)
include/clad/Differentiator/ReverseModeVisitor.h 97.84% <ø> (ø)
...clad/Differentiator/VectorPushForwardModeVisitor.h 100.00% <ø> (ø)
... and 12 more

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

There were too many comments to post at once. Showing the first 10 out of 28. Check the log or trigger a new build to see more.

@@ -99,11 +99,11 @@ namespace clad {
/// A base class for all common functionality for visitors
class VisitorBase {
protected:
VisitorBase(DerivativeBuilder& builder)
VisitorBase(DerivativeBuilder& builder, const DiffRequest& request)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: constructor does not initialize these fields: m_Mode [cppcoreguidelines-pro-type-member-init]

    VisitorBase(DerivativeBuilder& builder, const DiffRequest& request)
    ^

/// The function that is currently differentiated.
const clang::FunctionDecl* m_Function;
/// The differentiation request that is being currently processed.
const DiffRequest& m_DiffReq;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member 'm_DiffReq' of type 'const DiffRequest &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

    const DiffRequest& m_DiffReq;
                       ^

/// The function that is currently differentiated.
const clang::FunctionDecl* m_Function;
/// The differentiation request that is being currently processed.
const DiffRequest& m_DiffReq;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member variable 'm_DiffReq' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

    const DiffRequest& m_DiffReq;
                       ^

DeclarationNameInfo name(II, validLoc);
llvm::SaveAndRestore<DeclContext*> SaveContext(m_Sema.CurContext);
llvm::SaveAndRestore<Scope*> SaveScope(getCurrentScope());
DeclContext* DC = const_cast<DeclContext*>(m_Function->getDeclContext());
DeclContext* DC = const_cast<DeclContext*>(m_DiffReq->getDeclContext());
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: do not use const_cast [cppcoreguidelines-pro-type-const-cast]

  DeclContext* DC = const_cast<DeclContext*>(m_DiffReq->getDeclContext());
                    ^

lib/Differentiator/BaseForwardModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/BaseForwardModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/BaseForwardModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/HessianModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/HessianModeVisitor.cpp Outdated Show resolved Hide resolved
The intent of this patch is to centralize the information about the diff request
in one place. This will help upcoming patches to reduce the state of the
visitors and refactor some of the implementation in a common place.

That will unblock work on #721.
Repository owner deleted a comment from github-actions bot Jun 11, 2024
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

There were too many comments to post at once. Showing the first 10 out of 17. Check the log or trigger a new build to see more.

lib/Differentiator/HessianModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/HessianModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/HessianModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/HessianModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
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

lib/Differentiator/VectorForwardModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/VectorForwardModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/VectorForwardModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/VectorForwardModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/VectorForwardModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/VisitorBase.cpp Outdated Show resolved Hide resolved
@vgvassilev vgvassilev force-pushed the diff-req-nfc branch 2 times, most recently from 6bc7d9e to 97d7051 Compare June 11, 2024 19:16
This patch avoids picking up the latest uploaded llvm18 and partially mixing it
with llvm17.
Copy link
Collaborator

@parth-07 parth-07 left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@vgvassilev vgvassilev merged commit db0a949 into master Jun 11, 2024
89 checks passed
@vgvassilev vgvassilev deleted the diff-req-nfc branch June 11, 2024 20:50
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