-
Notifications
You must be signed in to change notification settings - Fork 60
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
Exclude rvalue references from const
in AUTOSAR rule 7-1-1.
#814
base: main
Are you sure you want to change the base?
Conversation
@fjatWbyT How about this test case? #include <utility>
void variadic_forwarding() {}
template <typename T, typename... Args>
void variadic_forwarding(T &&first, Args &&...rest) {
first;
variadic_forwarding(std::forward<Args>(rest)...);
}
int test_variadic_forwarding() { variadic_forwarding(1, 1.1, "a"); } |
Wow, nice one, @lcartey, thanks a lot for looking into it! With that test case I have indeed been able to reproduce the alert at the This is the snippet, composed of two independent test cases, I had used: #include <future>
#include <utility>
template<typename F, typename... Args>
constexpr decltype(auto) f(F&& func, Args&&... args)
{
return std::forward<F>(func)(std::forward<Args>(args)...);
}
class awaitable
{
awaitable(std::future<void>&& _future) : future(std::move(_future)) {}
private:
std::future<void> future;
};
int main()
{
} But didn't get alert for any of I will be updating the pull request shortly adding the test case. |
Ah, it may have to do with actually instantiating the template. So not for the case with |
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.
I verified the test failed without the change in the previous commit due to
+| test.cpp:93:47:93:50 | rest | Non-constant variable rest points to an object and is not modified. |
void fp_621() { recurse_var<true, true, true>; } | ||
|
||
#include <utility> |
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.
I added all at the end of the file to minimize updates to the expected files due to line numbers. But not sure if due to (auto) formatting rules or else it would be preferable otherwise.
Description
In the updated query for
A7-1-1
, unmodified objects (including arguments) that aren't declaredconst
are warned about missingconst
.I have observed the warning for rvalue references (in particular, for forwarding/universal references of variadic arguments) in utilities similar to
std::function
, although it isn't trivial to reproduce (i.e. not every universal reference to a variadic argument results in the warning).This change attempts to avoid that case of false positives by generally excluding rvalue references from being warned about a missing
const
.Change request type
.ql
,.qll
,.qls
or unit tests)Rules with added or modified queries
A7-1-1
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.