Hide noexcept condition

This commit is contained in:
Jonathan Müller 2017-07-17 16:36:59 +02:00
commit 495b82158d
3 changed files with 17 additions and 5 deletions

View file

@ -159,6 +159,7 @@ namespace cppast
exclude, //< Exclude the entire entity. exclude, //< Exclude the entire entity.
exclude_return, //< Exclude the return type of a function entity. exclude_return, //< Exclude the return type of a function entity.
exclude_target, //< Exclude the underlying entity of an alias (e.g. typedef). exclude_target, //< Exclude the underlying entity of an alias (e.g. typedef).
exclude_noexcept_condition, //< Exclude the condition of a noexcept.`
declaration, //< Only write declaration. declaration, //< Only write declaration.
/// For a macro, it won't show the replacement if this flag is set /// For a macro, it won't show the replacement if this flag is set
_flag_set_size, //< \exclude _flag_set_size, //< \exclude

View file

@ -500,6 +500,13 @@ namespace
else else
{ {
output << keyword("noexcept") << punctuation("(") << bracket_ws; output << keyword("noexcept") << punctuation("(") << bracket_ws;
// update check when expression gets exposed
if (cond.kind() == cpp_expression_kind::unexposed_t
&& static_cast<const cpp_unexposed_expression&>(cond).expression() == "false")
output << keyword("false");
else if (output.options().is_set(code_generator::exclude_noexcept_condition))
output.excluded(base);
else
detail::write_expression(output, cond); detail::write_expression(output, cond);
output << bracket_ws << punctuation(")"); output << bracket_ws << punctuation(")");
} }

View file

@ -162,7 +162,7 @@ struct foo{
else if (e.name() == "FOO") else if (e.name() == "FOO")
// don't show macro replacement // don't show macro replacement
return code_generator::declaration; return code_generator::declaration;
return {}; return code_generator::exclude_noexcept_condition;
} }
}; };
@ -174,7 +174,7 @@ void func(int a, int e, int c);
#define FOO hidden #define FOO hidden
template <typename e1, typename e2> template <typename e1, typename e2>
void tfunc(int a); void tfunc(int a) noexcept(false);
struct base {}; struct base {};
struct e_t {}; struct e_t {};
@ -198,13 +198,15 @@ public:
private: private:
int e3; int e3;
}; };
void func2() noexcept(0 == 1 && 42);
)"; )";
auto synopsis = R"(void func(int a,int c); auto synopsis = R"(void func(int a,int c);
#define FOO #define FOO
void tfunc(int a); void tfunc(int a)noexcept(false);
struct base{ struct base{
}; };
@ -221,6 +223,8 @@ class foo{
public: public:
int c; int c;
}; };
void func2()noexcept(excluded);
)"; )";
auto file = parse({}, "code_generator_exclude.cpp", code); auto file = parse({}, "code_generator_exclude.cpp", code);