From c1f30f5aa5310dcc0dffc842abb57ce725366f43 Mon Sep 17 00:00:00 2001 From: Vaibhav Thakkar Date: Fri, 19 Jul 2024 13:25:50 +0200 Subject: [PATCH] Remove redundant function from VisitorBase --- include/clad/Differentiator/VisitorBase.h | 2 -- lib/Differentiator/ReverseModeVisitor.cpp | 8 ++++---- lib/Differentiator/VisitorBase.cpp | 5 ----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/clad/Differentiator/VisitorBase.h b/include/clad/Differentiator/VisitorBase.h index d61031f19..b68318f7b 100644 --- a/include/clad/Differentiator/VisitorBase.h +++ b/include/clad/Differentiator/VisitorBase.h @@ -561,8 +561,6 @@ namespace clad { /// Creates the expression Base.size() for the given Base expr. The Base /// expr must be of clad::array_ref type clang::Expr* BuildArrayRefSizeExpr(clang::Expr* Base); - /// Checks if the type is of clad::ValueAndPushforward type - bool isCladValueAndPushforwardType(clang::QualType QT); /// Creates the expression Base.slice(Args) for the given Base expr and Args /// array. The Base expr must be of clad::array_ref type clang::Expr* diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index 2f0638df6..507c96acd 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -1200,7 +1200,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, // a return type being class is in pushforwards. Hence a special case has // been made to to not do the StoreAndRef operation when return type is // ValueAndPushforward. - if (!isCladValueAndPushforwardType(type)) { + if (!utils::IsCladValueAndPushforwardType(type)) { if (m_ExternalSource) m_ExternalSource->ActBeforeFinalizingVisitReturnStmt(ExprDiff); } @@ -1260,8 +1260,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, return StmtDiff(clonedILE); } // Check if type is a CXXRecordDecl and a struct. - if (!isCladValueAndPushforwardType(ILEType) && ILEType->isRecordType() && - ILEType->getAsCXXRecordDecl()->isStruct()) { + if (!utils::IsCladValueAndPushforwardType(ILEType) && + ILEType->isRecordType() && ILEType->getAsCXXRecordDecl()->isStruct()) { for (unsigned i = 0, e = ILE->getNumInits(); i < e; i++) { // fetch ith field of the struct. auto field_iterator = ILEType->getAsCXXRecordDecl()->field_begin(); @@ -1278,7 +1278,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, // that represents a ValueAndPushforward type. Ideally this must be // differentiated at VisitCXXConstructExpr #ifndef NDEBUG - bool isValueAndPushforward = isCladValueAndPushforwardType(ILEType); + bool isValueAndPushforward = utils::IsCladValueAndPushforwardType(ILEType); assert(isValueAndPushforward && "Only InitListExpr that represents arrays or ValueAndPushforward " "Object initialization is supported"); diff --git a/lib/Differentiator/VisitorBase.cpp b/lib/Differentiator/VisitorBase.cpp index eb462a7fb..2d36e34ed 100644 --- a/lib/Differentiator/VisitorBase.cpp +++ b/lib/Differentiator/VisitorBase.cpp @@ -704,11 +704,6 @@ namespace clad { QT.getAsString().find("clad::array_ref") != std::string::npos; } - bool VisitorBase::isCladValueAndPushforwardType(clang::QualType QT) { - // FIXME: Replace this check with a clang decl check - return QT.getAsString().find("ValueAndPushforward") != std::string::npos; - } - Expr* VisitorBase::GetSingleArgCentralDiffCall( Expr* targetFuncCall, Expr* targetArg, unsigned targetPos, unsigned numArgs, llvm::SmallVectorImpl& args) {