Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd1e151

Browse files
authored
Merge pull request#638 from knewbury01/knewbury01/fix-406
A13-3-1: exclude implicit copy/move ctors
2 parents2de0fcb +3521709 commitbd1e151

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-`A13-3-1` -`FunctionThatContainsForwardingReferenceAsItsArgumentOverloaded.ql`:
2+
- Fixes#406. Exclude detection of overloaded implicit copy/move constructors.

‎cpp/autosar/src/rules/A13-3-1/FunctionThatContainsForwardingReferenceAsItsArgumentOverloaded.ql‎

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,13 @@ where
3232
// allow for overloading with different number of parameters, because there is no
3333
// confusion on what function will be called.
3434
f.getNumberOfParameters()=c.getNumberOfParameters()and
35-
//build a dynamic select statement that guarantees to read that the overloading function is the explicit one
36-
if
37-
(finstanceofCopyConstructororfinstanceofMoveConstructor)and
38-
f.isCompilerGenerated()
39-
then(
40-
(
41-
finstanceofCopyConstructorand
42-
msg="implicit copy constructor"
43-
or
44-
finstanceofMoveConstructorand
45-
msg="implicit move constructor"
46-
)and
47-
firstMsgSegment=" with a forwarding reference parameter "and
48-
overloaded=fand
49-
overload=c
50-
)else(
51-
msg="function with a forwarding reference parameter"and
52-
firstMsgSegment=" "and
53-
overloaded=cand
54-
overload=f
55-
)
35+
//ignore implicit copy and move constructor overloads
36+
not(
37+
f.isCompilerGenerated()and
38+
(finstanceofCopyConstructororfinstanceofMoveConstructor)
39+
)and
40+
msg="function with a forwarding reference parameter"and
41+
firstMsgSegment=" "and
42+
overloaded=cand
43+
overload=f
5644
selectoverload,"Function"+firstMsgSegment+"overloads a $@.",overloaded,msg
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
| test.cpp:24:6:24:7 | F1 | Function overloads a $@. | test.cpp:27:25:27:26 | F1 | function with a forwarding reference parameter |
22
| test.cpp:50:3:50:3 | A | Function overloads a $@. | test.cpp:48:3:48:3 | A | function with a forwarding reference parameter |
33
| test.cpp:51:3:51:3 | A | Function overloads a $@. | test.cpp:48:3:48:3 | A | function with a forwarding reference parameter |
4-
| test.cpp:69:3:69:3 | B | Function with a forwarding reference parameter overloads a $@. | test.cpp:64:8:64:8 | B | implicit copy constructor |
5-
| test.cpp:69:3:69:3 | B | Function with a forwarding reference parameter overloads a $@. | test.cpp:64:8:64:8 | B | implicit move constructor |
6-
| test.cpp:77:25:77:25 | C | Function with a forwarding reference parameter overloads a $@. | test.cpp:74:7:74:7 | C | implicit copy constructor |
7-
| test.cpp:77:25:77:25 | C | Function with a forwarding reference parameter overloads a $@. | test.cpp:74:7:74:7 | C | implicit move constructor |

‎cpp/autosar/test/rules/A13-3-1/test.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ template <class T> void F1(T &&x) {} //
4040
classA {
4141
public:
4242
// COMPLIANT[FALSE_POSITIVE] - by exception, constrained to not match
43-
// copy/move ctors
43+
//explicitcopy/move ctors
4444
template<
4545
typename T,
4646
std::enable_if_t<!std::is_same<
@@ -66,13 +66,14 @@ struct B {
6666
typename T,
6767
std::enable_if_t<!std::is_same<
6868
std::remove_cv_t<std::remove_reference_t<T>>, A>::value> * =nullptr>
69-
B(T &&value) {}// COMPLIANT[FALSE_POSITIVE] - by exception
69+
B(T &&value) {}// COMPLIANT - by exception
7070
};
7171

7272
intmain() {}
7373

7474
classC {
7575
public:
7676
C() {}
77-
template<typename T>C(T &&) {}// NON_COMPLIANT
77+
template<typename T>
78+
C(T &&) {}// COMPLIANT - ignore overloads of implicit copy/move ctors
7879
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp