Skip to content

Commit

Permalink
Do not copy the VisitorBase.
Browse files Browse the repository at this point in the history
This patch resolves a clang-tidy report that we are slicing the object when
trying to call cloneFunction.
  • Loading branch information
vgvassilev committed Aug 19, 2023
1 parent f3a7d33 commit 321bd32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/clad/Differentiator/DerivativeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace clad {
llvm::SmallVector<std::unique_ptr<ErrorEstimationHandler>, 4>
m_ErrorEstHandler;
DeclWithContext cloneFunction(const clang::FunctionDecl* FD,
clad::VisitorBase VB, clang::DeclContext* DC,
clad::VisitorBase& VB, clang::DeclContext* DC,
clang::Sema& m_Sema,
clang::ASTContext& m_Context,
clang::SourceLocation& noLoc,
Expand Down
4 changes: 2 additions & 2 deletions lib/Differentiator/DerivativeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace clad {

DeclWithContext
DerivativeBuilder::cloneFunction(const clang::FunctionDecl* FD,
clad::VisitorBase VD,
clad::VisitorBase& VB,
clang::DeclContext* DC,
clang::Sema& m_Sema,
clang::ASTContext& m_Context,
Expand All @@ -116,7 +116,7 @@ namespace clad {
returnedFD->setAccess(FD->getAccess());
} else {
assert (isa<FunctionDecl>(FD) && "Unexpected!");
enclosingNS = VD.RebuildEnclosingNamespaces(DC);
enclosingNS = VB.RebuildEnclosingNamespaces(DC);
returnedFD = FunctionDecl::Create(m_Context,
m_Sema.CurContext,
noLoc,
Expand Down

0 comments on commit 321bd32

Please sign in to comment.