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

Commitcc527b1

Browse files
authored
Merge pull request#62 from mbaluda-org/issue11-A13-2-2
Issue 11: A13-2-2 distinguish stream operators from binary shift
2 parents5ba5f3a +eb5616d commitcc527b1

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-`A13-2-2` -`BinaryOperatorAndBitwiseOperatorReturnAPrvalue.ql`:
2+
- Remove findings related to stream operators.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
| test.cpp:16:9:16:17 | operator- | User-defined bitwise or arithmetic operator operator-(const A &, int) -> const A does not return a prvalue. |
22
| test.cpp:20:4:20:12 | operator\| | User-defined bitwise or arithmetic operator operator\|(const A &, const A &) -> A * does not return a prvalue. |
3-
| test.cpp:29:6:29:14 | operator+ | User-defined bitwise or arithmetic operator NS_C::operator+(const C &, const C &) -> int & does not return a prvalue. |
3+
| test.cpp:24:9:24:18 | operator<< | User-defined bitwise or arithmetic operator operator<<(const A &, const A &) -> const A does not return a prvalue. |
4+
| test.cpp:34:6:34:14 | operator+ | User-defined bitwise or arithmetic operator NS_C::operator+(const C &, const C &) -> int & does not return a prvalue. |

‎cpp/autosar/test/rules/A13-2-2/test.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ A *operator|(A const &a1, A const &a2) noexcept { // NON_COMPLIANT
2121
returnnewA();
2222
}
2323

24+
const Aoperator<<(Aconst &, Aconst &)noexcept// NON_COMPLIANT
25+
{
26+
return A{};
27+
}
28+
2429
classC {
2530
C &operator=(const C &rhs);
2631
};
@@ -31,3 +36,10 @@ int &operator+(const C &lhs, const C &rhs) { // NON_COMPLIANT
3136
return slocal;
3237
}
3338
}// namespace NS_C
39+
40+
#include<iostream>
41+
structTest {};
42+
std::ostream &operator<<(std::ostream &os,const Test &) {// COMPLIANT
43+
os <<"test";
44+
return os;
45+
}

‎cpp/common/src/codingstandards/cpp/Operator.qll‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ class UserBitwiseOperator extends Function {
170170
opin["&","|","^","~","%","<<",">>"]
171171
)and
172172
notthis.isCompilerGenerated()and
173-
notthis.getType().hasName("ostream")and
174-
notthis.getType().hasName("istream")
173+
notthis.getType().(ReferenceType).getBaseType().hasName("ostream")and
174+
notthis.getType().(ReferenceType).getBaseType().hasName("istream")
175175
}
176176
}
177177

‎cpp/common/test/includes/standard-library/ostream.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef _GHLIBCPP_OSTREAM
22
#define_GHLIBCPP_OSTREAM
33
#include"string.h"
4+
#include<ios>
45

56
namespacestd {
67
template<classcharT,classtraits>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp