Modify THROW macro to use a constexpr function for file name, instead of macro.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This prevents potential warnings (such as clang-tidy's "cppcoreguidelines-pro-bounds-pointer-arithmetic") from showing up when using this macro.
This commit is contained in:
parent
5fcebd4d4d
commit
edaa9f496d
|
@ -140,12 +140,21 @@ namespace ArbUt {
|
|||
};
|
||||
}
|
||||
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
static constexpr const char* file_name(const char* path) {
|
||||
const char* file = path;
|
||||
while (*path) {
|
||||
if (*path++ == '/') {
|
||||
file = path;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
#define THROW(message) \
|
||||
std::stringstream ___ss; \
|
||||
___ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \
|
||||
___ss << "[" << file_name(__FILE__) << ":" << __LINE__ << "] " << (message); \
|
||||
throw ArbUt::Exception(___ss.str());
|
||||
|
||||
#define NOT_REACHABLE THROW("Not reachable");
|
||||
#define NOT_IMPLEMENTED THROW("Not implemented");
|
||||
|
||||
|
|
Loading…
Reference in New Issue