-
Notifications
You must be signed in to change notification settings - Fork 122
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
Rev ref returns #601
Rev ref returns #601
Conversation
@PhrygianGates Can you please debug and fix the failing debug checks? |
Is the pull request ready for review? |
I'm not sure as it seems to go wrong when installing something. I'll push again to see what happens. |
This fails elsewhere due to some server outage it seems. We can ignore this for now. |
There was a problem hiding this 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 40. Check the log or trigger a new build to see more.
#include "llvm/ADT/SmallVector.h" | ||
|
||
namespace clad { | ||
class ReverseModeForwPassVisitor : public ReverseModeVisitor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: destructor of 'ReverseModeForwPassVisitor' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
class ReverseModeForwPassVisitor : public ReverseModeVisitor {
^
Additional context
include/clad/Differentiator/ReverseModeForwPassVisitor.h:12: make it public and virtual
class ReverseModeForwPassVisitor : public ReverseModeVisitor {
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise.
private: | ||
Stmts m_Globals; | ||
|
||
llvm::SmallVector<clang::QualType, 8> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
llvm::SmallVector<clang::QualType, 8>
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to suppress these by adding IgnorePowersOf2IntegerValues=true
in the clang-tidy config: https://clang.llvm.org/extra/clang-tidy/checks/readability/magic-numbers.html
llvm::SmallVector<clang::QualType, 8> | ||
ComputeParamTypes(const DiffParams& diffParams); | ||
clang::QualType ComputeReturnType(); | ||
llvm::SmallVector<clang::ParmVarDecl*, 8> BuildParams(DiffParams& diffParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
llvm::SmallVector<clang::ParmVarDecl*, 8> BuildParams(DiffParams& diffParams);
^
@@ -22,6 +22,9 @@ | |||
#include "clad/Differentiator/HessianModeVisitor.h" | |||
#include "clad/Differentiator/JacobianModeVisitor.h" | |||
#include "clad/Differentiator/ReverseModeVisitor.h" | |||
#include "clad/Differentiator/ReverseModeForwPassVisitor.h" | |||
|
|||
#include "clad/Differentiator/DiffPlanner.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: duplicate include [readability-duplicate-include]
lib/Differentiator/DerivativeBuilder.cpp:25:
-
- #include "clad/Differentiator/DiffPlanner.h"
|
||
llvm::SaveAndRestore<DeclContext*> saveContext(m_Sema.CurContext); | ||
llvm::SaveAndRestore<Scope*> saveScope(m_CurScope); | ||
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext()); |
There was a problem hiding this comment.
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]
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext());
^
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext()); | ||
|
||
DeclWithContext fnBuildRes = | ||
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: slicing object from type 'ReverseModeForwPassVisitor' to 'VisitorBase' discards 1096 bytes of state [cppcoreguidelines-slicing]
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema,
^
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext()); | ||
|
||
DeclWithContext fnBuildRes = | ||
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: slicing object from type 'ReverseModeForwPassVisitor' to 'VisitorBase' discards override 'VisitCompoundStmt' [cppcoreguidelines-slicing]
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema,
^
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext()); | ||
|
||
DeclWithContext fnBuildRes = | ||
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: slicing object from type 'ReverseModeForwPassVisitor' to 'VisitorBase' discards override 'VisitDeclRefExpr' [cppcoreguidelines-slicing]
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema,
^
There was a problem hiding this 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 31. Check the log or trigger a new build to see more.
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext()); | ||
|
||
DeclWithContext fnBuildRes = | ||
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: slicing object from type 'ReverseModeForwPassVisitor' to 'VisitorBase' discards override 'VisitReturnStmt' [cppcoreguidelines-slicing]
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema,
^
m_Sema.CurContext = const_cast<DeclContext*>(m_Function->getDeclContext()); | ||
|
||
DeclWithContext fnBuildRes = | ||
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: slicing object from type 'ReverseModeForwPassVisitor' to 'VisitorBase' discards override 'VisitStmt' [cppcoreguidelines-slicing]
m_Builder.cloneFunction(m_Function, *this, m_Sema.CurContext, m_Sema,
^
There was a problem hiding this 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 21. Check the log or trigger a new build to see more.
return T; | ||
} | ||
|
||
llvm::SmallVector<clang::ParmVarDecl*, 8> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
llvm::SmallVector<clang::ParmVarDecl*, 8>
^
|
||
llvm::SmallVector<clang::ParmVarDecl*, 8> | ||
ReverseModeForwPassVisitor::BuildParams(DiffParams& diffParams) { | ||
llvm::SmallVector<clang::ParmVarDecl*, 8> params, paramDerivatives; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
llvm::SmallVector<clang::ParmVarDecl*, 8> params, paramDerivatives;
^
There was a problem hiding this 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 11. Check the log or trigger a new build to see more.
There was a problem hiding this 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
|
||
llvm::SmallVector<clang::ParmVarDecl*, 8> | ||
ReverseModeForwPassVisitor::BuildParams(DiffParams& diffParams) { | ||
llvm::SmallVector<clang::ParmVarDecl*, 8> params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
llvm::SmallVector<clang::ParmVarDecl*, 8> params;
^
llvm::SmallVector<clang::ParmVarDecl*, 8> | ||
ReverseModeForwPassVisitor::BuildParams(DiffParams& diffParams) { | ||
llvm::SmallVector<clang::ParmVarDecl*, 8> params; | ||
llvm::SmallVector<clang::ParmVarDecl*, 8> paramDerivatives; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
llvm::SmallVector<clang::ParmVarDecl*, 8> paramDerivatives;
^
e2b5e5f
to
d087419
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the clang-tidy suggestions make sense. Could you incorporate them in the PR?
#include "llvm/ADT/SmallVector.h" | ||
|
||
namespace clad { | ||
class ReverseModeForwPassVisitor : public ReverseModeVisitor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise.
b6b52be
to
d89426c
Compare
There was a problem hiding this 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
#define CLAD_COMPAT_CLANG11_LangOptions_EtraParams Ctx.getLangOpts() | ||
#endif | ||
#define CLAD_COMPAT_CLANG11_Ctx_ExtraParams Ctx, | ||
#define CLAD_COMPAT_CREATE11(CLASS, CTORARGS) (CLASS::Create CTORARGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function-like macro 'CLAD_COMPAT_CREATE11' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define CLAD_COMPAT_CREATE11(CLASS, CTORARGS) (CLASS::Create CTORARGS)
^
tools/DerivedFnInfo.h
Outdated
DiffInputVarsInfo m_DiffVarsInfo; | ||
bool m_UsesEnzyme = false; | ||
|
||
DerivedFnInfo() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
DerivedFnInfo() {} | |
DerivedFnInfo() = default; |
1eebf49
to
fab409d
Compare
fab409d
to
771d709
Compare
3d5503b
to
cc04f13
Compare
0947893
to
f3a7d33
Compare
321bd32
to
49d9aca
Compare
There was a problem hiding this 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
clang::SourceLocation& noLoc, | ||
clang::DeclarationNameInfo name, | ||
clang::QualType functionType) { | ||
DeclWithContext DerivativeBuilder::cloneFunction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'cloneFunction' can be made static [readability-convert-member-functions-to-static]
include/clad/Differentiator/DerivativeBuilder.h:94:
- DeclWithContext cloneFunction(const clang::FunctionDecl* FD,
+ static DeclWithContext cloneFunction(const clang::FunctionDecl* FD,
There was a problem hiding this 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
@@ -93,7 +93,7 @@ namespace clad { | |||
llvm::SmallVector<std::unique_ptr<ErrorEstimationHandler>, 4> | |||
m_ErrorEstHandler; | |||
DeclWithContext cloneFunction(const clang::FunctionDecl* FD, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'clad::DerivativeBuilder::cloneFunction' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
DeclWithContext cloneFunction(const clang::FunctionDecl* FD,
^
Additional context
lib/Differentiator/DerivativeBuilder.cpp:93: the definition seen here
DeclWithContext DerivativeBuilder::cloneFunction(
^
include/clad/Differentiator/DerivativeBuilder.h:94: differing parameters are named here: ('VB'), in definition: ('VD')
DeclWithContext cloneFunction(const clang::FunctionDecl* FD,
^
17606c8
to
34a898d
Compare
89e33f9
to
0c0290e
Compare
There was a problem hiding this 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
@@ -427,7 +427,8 @@ static inline QualType getConstantArrayType(const ASTContext &Ctx, | |||
#if CLANG_VERSION_MAJOR < 10 | |||
#define CLAD_COMPAT_CLANG10_FunctionDecl_Create_ExtraParams(x) /**/ | |||
#elif CLANG_VERSION_MAJOR >= 10 | |||
#define CLAD_COMPAT_CLANG10_FunctionDecl_Create_ExtraParams(x) ,((x)?VD.Clone((x)):nullptr) | |||
#define CLAD_COMPAT_CLANG10_FunctionDecl_Create_ExtraParams(x) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function-like macro 'CLAD_COMPAT_CLANG10_FunctionDecl_Create_ExtraParams' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define CLAD_COMPAT_CLANG10_FunctionDecl_Create_ExtraParams(x) \
^
0c0290e
to
2c64861
Compare
2c64861
to
cd842da
Compare
There was a problem hiding this 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
90e383d
to
a90bfc6
Compare
Co-authored-by: Daemond <[email protected]>
a90bfc6
to
ea8b406
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
This PR rebase the #425 pull-request on top of master.