Skip to content

Commit

Permalink
Move if-stmt invariant code outside, fix a compiler warning. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvassilev committed Dec 7, 2023
1 parent 232d17b commit d68f437
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ jobs:
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# When debugging increase to a suitable value!
timeout-minutes: ${{ github.event.pull_request && 100 || 20 }}
timeout-minutes: ${{ github.event.pull_request && 1 || 20 }}
- name: Prepare code coverage report
if: ${{ success() && (matrix.coverage == true) }}
run: |
Expand Down
14 changes: 4 additions & 10 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,24 +1304,18 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
}

StmtDiff ReverseModeVisitor::VisitDeclRefExpr(const DeclRefExpr* DRE) {
DeclRefExpr* clonedDRE = nullptr;
DeclRefExpr* clonedDRE = cast<DeclRefExpr>(Clone(DRE));
// Check if referenced Decl was "replaced" with another identifier inside
// the derivative
if (const auto* VD = dyn_cast<VarDecl>(DRE->getDecl())) {
clonedDRE = cast<DeclRefExpr>(Clone(DRE));
if (auto* VD = dyn_cast<VarDecl>(clonedDRE->getDecl())) {
// If current context is different than the context of the original
// declaration (e.g. we are inside lambda), rebuild the DeclRefExpr
// with Sema::BuildDeclRefExpr. This is required in some cases, e.g.
// Sema::BuildDeclRefExpr is responsible for adding captured fields
// to the underlying struct of a lambda.
if (clonedDRE->getDecl()->getDeclContext() != m_Sema.CurContext) {
auto* referencedDecl = cast<VarDecl>(clonedDRE->getDecl());
clonedDRE = cast<DeclRefExpr>(BuildDeclRef(referencedDecl));
}
} else
clonedDRE = cast<DeclRefExpr>(Clone(DRE));
if (VD->getDeclContext() != m_Sema.CurContext)
clonedDRE = cast<DeclRefExpr>(BuildDeclRef(VD));

if (auto* decl = dyn_cast<VarDecl>(clonedDRE->getDecl())) {
if (isVectorValued) {
if (m_VectorOutput.size() <= outputArrayCursor)
return StmtDiff(clonedDRE);
Expand Down

0 comments on commit d68f437

Please sign in to comment.