-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #11691: FP throwInNoexceptFunction with if constexpr in template #6962
base: main
Are you sure you want to change the base?
Conversation
tok = tok->astParent(); | ||
const Token *condTok = tok->astOperand2(); | ||
// check if condition is possibly false, since template arguments are not set to known | ||
if (isPossibleBool(condTok, false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow we should check if the possible values are template arguments. You can check Token::templateArg
for "possible" operands .
If the condition is false you skip the if-body but if the condition is true you do nothing, you should skip the else
body then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The utility function I introduce in #7045 would be useful for this, so maybe I should wait for that one.
if (Token::simpleMatch(tok, "{")) | ||
tok = tok->link(); | ||
else while (tok && !Token::simpleMatch(tok, ";")) | ||
tok = tok->next(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not seem to be formatted properly. we have the runformat
script in the cppcheck folder could you run that..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this seems to be what uncrustify wants. But I could add braces to make it more readable.
|
||
// #11691: FP throwInNoexceptFunction with if constexpr in template | ||
check("template<bool IsNoThrow>\n" | ||
"static void* MyNew(size_t Size) noexcept(IsNoThrow) {\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test case can be reduced:
template<bool IsNoThrow>
static void foo(size_t Size) noexcept(IsNoThrow) {
if constexpr (!IsNoThrow) {
throw std::bad_alloc();
}
}
foo<true>(123);
No description provided.