Skip to content

Commit

Permalink
Fix seg fault for catch(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaithak committed Jan 18, 2024
1 parent d8ef790 commit a307338
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Differentiator/StmtClone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ VarDecl* StmtClone::CloneDeclOrNull(VarDecl* Node) {
}

Decl* StmtClone::CloneDecl(Decl* Node) {
if (!Node)
return nullptr;
// we support only exactly this class, so no visitor is needed (yet?)
if (Node->getKind() == Decl::Var) {
VarDecl* VD = static_cast<VarDecl*>(Node);
Expand Down
5 changes: 5 additions & 0 deletions test/FirstDerivative/DiffInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ int f_try_catch(int x)
catch (int) {
return 0;
}
catch (...) {
return 1;
}

// CHECK: int f_try_catch_darg0(int x) {
// CHECK-NEXT: int _d_x = 1;
// CHECK-NEXT: try {
// CHECK-NEXT: return x;
// CHECK-NEXT: } catch (int) {
// CHECK-NEXT: return 0;
// CHECK-NEXT: } catch (...) {
// CHECK-NEXT: return 1;
// CHECK-NEXT: }
// CHECK-NEXT: }

Expand Down

0 comments on commit a307338

Please sign in to comment.