Skip to content

Commit

Permalink
Enable throw-by-val/catch-by-ref check (#15981)
Browse files Browse the repository at this point in the history
### Ticket
#15123 

### Problem description
C++ should always throw exceptions by value and catch them by reference.

### What's changed
Enabled the check in clang-tidy.
Fixed the violations.
  • Loading branch information
afuller-TT authored Dec 12, 2024
1 parent e08a832 commit 660d249
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ Checks: >
-bugprone-unhandled-self-assignment,
-bugprone-unused-raii,
-cert-env33-c,
-cert-err09-cpp,
-cert-err33-c,
-cert-err34-c,
-cert-err58-cpp,
-cert-err61-cpp,
-cert-flp30-c,
-cert-msc30-c,
-cert-msc32-c,
Expand Down Expand Up @@ -121,7 +119,6 @@ Checks: >
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-redundant-expression,
-misc-throw-by-value-catch-by-reference,
-misc-unconventional-assign-operator,
-misc-uniqueptr-reset-release,
-misc-unused-parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ int main(int argc, char** argv) {
}
}
}
} catch (std::exception e) {
} catch (std::exception& e) {
test_fixture.TearDown();
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ int main(int argc, char** argv) {
}
}
}
} catch (std::exception e) {
} catch (std::exception& e) {
test_fixture.TearDown();
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ int main(int argc, char** argv) {
}
}
}
} catch (std::exception e) {
} catch (std::exception& e) {
test_fixture.TearDown();
return -1;
}
Expand Down

0 comments on commit 660d249

Please sign in to comment.