diff --git a/lib/Differentiator/BaseForwardModeVisitor.cpp b/lib/Differentiator/BaseForwardModeVisitor.cpp index fec9cd6e3..2564683ca 100644 --- a/lib/Differentiator/BaseForwardModeVisitor.cpp +++ b/lib/Differentiator/BaseForwardModeVisitor.cpp @@ -1929,11 +1929,13 @@ StmtDiff BaseForwardModeVisitor::VisitCXXFunctionalCastExpr( SourceLocation fakeLoc = utils::GetValidSLoc(m_Sema); Expr* clonedFCE = m_Sema .BuildCXXFunctionalCastExpr( - FCE->getTypeInfoAsWritten(), FCE->getType(), fakeLoc, castExprDiff.getExpr(), fakeLoc) + FCE->getTypeInfoAsWritten(), FCE->getType(), + fakeLoc, castExprDiff.getExpr(), fakeLoc) .get(); Expr* derivedFCE = m_Sema .BuildCXXFunctionalCastExpr( - FCE->getTypeInfoAsWritten(), FCE->getType(), fakeLoc, castExprDiff.getExpr_dx(), fakeLoc) + FCE->getTypeInfoAsWritten(), FCE->getType(), + fakeLoc, castExprDiff.getExpr_dx(), fakeLoc) .get(); return {clonedFCE, derivedFCE}; } diff --git a/lib/Differentiator/DiffPlanner.cpp b/lib/Differentiator/DiffPlanner.cpp index 804671dd5..9105be5b4 100644 --- a/lib/Differentiator/DiffPlanner.cpp +++ b/lib/Differentiator/DiffPlanner.cpp @@ -562,9 +562,14 @@ namespace clad { // bitmask_opts is a template pack of unsigned integers, so we need to // do bitwise or of all the values to get the final value. unsigned bitmasked_opts_value = 0; - for (auto const& arg : - FD->getTemplateSpecializationArgs()->get(0).pack_elements()) { - bitmasked_opts_value |= arg.getAsIntegral().getExtValue(); + const auto template_arg = FD->getTemplateSpecializationArgs()->get(0); + if (template_arg.getKind() == TemplateArgument::Pack) { + for (const auto& arg : + FD->getTemplateSpecializationArgs()->get(0).pack_elements()) { + bitmasked_opts_value |= arg.getAsIntegral().getExtValue(); + } + } else { + bitmasked_opts_value = template_arg.getAsIntegral().getExtValue(); } unsigned derivative_order = clad::GetDerivativeOrder(bitmasked_opts_value); @@ -602,7 +607,7 @@ namespace clad { // bitmask_opts is a template pack of unsigned integers, so we need to // do bitwise or of all the values to get the final value. unsigned bitmasked_opts_value = 0; - for (auto const& arg : + for (const auto& arg : FD->getTemplateSpecializationArgs()->get(0).pack_elements()) { bitmasked_opts_value |= arg.getAsIntegral().getExtValue(); } diff --git a/lib/Differentiator/StmtClone.cpp b/lib/Differentiator/StmtClone.cpp index 214d753b1..a366ba000 100644 --- a/lib/Differentiator/StmtClone.cpp +++ b/lib/Differentiator/StmtClone.cpp @@ -83,7 +83,7 @@ Stmt* StmtClone::VisitDeclRefExpr(DeclRefExpr *Node) { Ctx, Node->getQualifierLoc(), Node->getTemplateKeywordLoc(), Node->getDecl(), Node->refersToEnclosingVariableOrCapture(), Node->getNameInfo(), CloneType(Node->getType()), Node->getValueKind(), - Node->getFoundDecl(), &TAListInfo); + Node->getFoundDecl(), &TAListInfo, Node->isNonOdrUse()); } DEFINE_CREATE_EXPR(IntegerLiteral, (Ctx, Node->getValue(), CloneType(Node->getType()), @@ -227,7 +227,9 @@ DEFINE_CLONE_EXPR(VAArgExpr, Node->getWrittenTypeInfo(), Node->getRParenLoc(), CloneType(Node->getType()), Node->isMicrosoftABI())) DEFINE_CLONE_EXPR(ImplicitValueInitExpr, (CloneType(Node->getType()))) -DEFINE_CLONE_EXPR(CXXScalarValueInitExpr, (CloneType(Node->getType()), Node->getTypeSourceInfo(), Node->getRParenLoc())) +DEFINE_CLONE_EXPR(CXXScalarValueInitExpr, + (CloneType(Node->getType()), Node->getTypeSourceInfo(), + Node->getRParenLoc())) DEFINE_CLONE_EXPR(ExtVectorElementExpr, (Node->getType(), Node->getValueKind(), Clone(Node->getBase()), Node->getAccessor(), Node->getAccessorLoc())) DEFINE_CLONE_EXPR(CXXBoolLiteralExpr, (Node->getValue(), Node->getType(), Node->getSourceRange().getBegin())) DEFINE_CLONE_EXPR(CXXNullPtrLiteralExpr, (Node->getType(), Node->getSourceRange().getBegin()))