Skip to content

Commit 9d95e55

Browse files
committed
Replace assertions with exceptions
1 parent 7f1ebd4 commit 9d95e55

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bindgen/ir/TypeDef.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "../Utils.h"
33
#include "Enum.h"
44
#include "Struct.h"
5+
#include <stdexcept>
56

67
TypeDef::TypeDef(std::string name, std::shared_ptr<const Type> type,
78
std::shared_ptr<Location> location)
@@ -48,9 +49,10 @@ bool TypeDef::operator==(const Type &other) const {
4849

4950
std::shared_ptr<Location> TypeDef::getLocation() const {
5051
if (!type) {
51-
assert(false && "This method should not be called on typedef that "
52-
"references an opaque type because location cannot be "
53-
"defined.");
52+
throw std::logic_error(
53+
"TypeDef::getLocation method should not be called on typedef that "
54+
"references an opaque type because location cannot be "
55+
"defined.");
5456
}
5557
if (location) {
5658
/* if typedef is not generated */
@@ -65,8 +67,8 @@ std::shared_ptr<Location> TypeDef::getLocation() const {
6567
if (enumPointer) {
6668
return enumPointer->getLocation();
6769
}
68-
assert(false &&
69-
"Generated typedef may reference only struct, union or enum");
70+
throw std::logic_error(
71+
"Generated typedef may reference only struct, union or enum");
7072
}
7173

7274
bool TypeDef::hasLocation() const { return location || type; }

0 commit comments

Comments
 (0)