forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable nested exception printing for Windows
Due to bug in the VS2013 C++ compiler, using std::rethrow_if_nested or std::nested_exception is not supported. This disables trying to unwrap the exception and just prints a warning saying the nested exceptionc couldn't be printed. Don't use noexcept directly, pull both part of the nested exception into a separate file to handle discrepancies.
- Loading branch information
thk123
committed
Apr 23, 2018
1 parent
b866015
commit 9d41b0c
Showing
6 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected] | |
#include "symex_target_equation.h" | ||
|
||
#include <util/std_expr.h> | ||
#include <util/throw_with_nested.h> | ||
#include <util/unwrap_nested_exception.h> | ||
|
||
#include <langapi/language_util.h> | ||
|
@@ -437,7 +438,7 @@ void symex_target_equationt::convert_guards( | |
} | ||
catch(const bitvector_conversion_exceptiont &conversion_exception) | ||
{ | ||
std::throw_with_nested(guard_conversion_exceptiont(step, ns)); | ||
util_throw_with_nested(guard_conversion_exceptiont(step, ns)); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/byte_operators.h> | ||
#include <util/endianness_map.h> | ||
#include <util/std_expr.h> | ||
#include <util/throw_with_nested.h> | ||
|
||
#include "bv_conversion_exceptions.h" | ||
#include "flatten_byte_extract_exceptions.h" | ||
|
@@ -51,7 +52,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr) | |
} | ||
catch(const flatten_byte_extract_exceptiont &byte_extract_flatten_exception) | ||
{ | ||
std::throw_with_nested( | ||
util_throw_with_nested( | ||
bitvector_conversion_exceptiont("Can't convert byte_extraction", expr)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*******************************************************************\ | ||
Module: util | ||
Author: Diffblue Ltd. | ||
\*******************************************************************/ | ||
|
||
#ifndef CPROVER_UTIL_THROW_WITH_NESTED_H | ||
#define CPROVER_UTIL_THROW_WITH_NESTED_H | ||
|
||
#include <exception> | ||
|
||
#ifdef _MSC_VER | ||
#include <stdexcept> | ||
// TODO(tkiley): Nested exception logging not supported on windows due to a bug | ||
// TODO(tkiley): in MSVC++ Compiler (diffblue/cbmc#2104): | ||
// TODO(tkiley): https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-update-2s-stl-is-c17-so-far-feature-complete | ||
|
||
#define DISABLE_NESTED_EXCEPTIONS | ||
|
||
class non_nested_exception_support : public std::runtime_error | ||
{ | ||
public: | ||
non_nested_exception_support() | ||
: std::runtime_error("Nested exception printing not supported on Windows") | ||
{ | ||
} | ||
}; | ||
|
||
#endif | ||
|
||
template <class T> | ||
#ifdef __GNUC__ | ||
__attribute__((noreturn)) | ||
#endif | ||
void util_throw_with_nested(T &&t) | ||
{ | ||
#ifndef DISABLE_NESTED_EXCEPTIONS | ||
std::throw_with_nested(t); | ||
#else | ||
throw t; | ||
#endif | ||
} | ||
|
||
template <class E> | ||
void util_rethrow_if_nested(const E &e) | ||
{ | ||
#ifndef DISABLE_NESTED_EXCEPTIONS | ||
std::rethrow_if_nested(e); | ||
#else | ||
// Check we've not already thrown the non_nested_support_exception | ||
if(!dynamic_cast<const non_nested_exception_support *>(&e)) | ||
{ | ||
throw non_nested_exception_support(); | ||
} | ||
#endif | ||
} | ||
|
||
#endif // CPROVER_UTIL_THROW_WITH_NESTED_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters