Skip to content

Commit

Permalink
Remove redundant function from VisitorBase
Browse files Browse the repository at this point in the history
  • Loading branch information
vaithak committed Jul 19, 2024
1 parent 8fc2d5d commit 557a378
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 0 additions & 2 deletions include/clad/Differentiator/VisitorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> type
clang::Expr* BuildArrayRefSizeExpr(clang::Expr* Base);
/// Checks if the type is of clad::ValueAndPushforward<T,U> 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<T> type
clang::Expr*
Expand Down
8 changes: 4 additions & 4 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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");
Expand Down
5 changes: 0 additions & 5 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr*>& args) {
Expand Down

0 comments on commit 557a378

Please sign in to comment.