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

Issue 11: A13-2-2 distinguish stream operators from binary shift#62

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lcartey merged 2 commits intogithub:mainfrommbaluda-org:issue11-A13-2-2
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionschange_notes/2022-08-17-fix-reported-fp-for-a13-2-2.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
- `A13-2-2` - `BinaryOperatorAndBitwiseOperatorReturnAPrvalue.ql`:
- Remove findings related to stream operators.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
| test.cpp:16:9:16:17 | operator- | User-defined bitwise or arithmetic operator operator-(const A &, int) -> const A does not return a prvalue. |
| test.cpp:20:4:20:12 | operator\| | User-defined bitwise or arithmetic operator operator\|(const A &, const A &) -> A * does not return a prvalue. |
| 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. |
| 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. |
| 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. |
12 changes: 12 additions & 0 deletionscpp/autosar/test/rules/A13-2-2/test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,11 @@ A *operator|(A const &a1, A const &a2) noexcept { // NON_COMPLIANT
return new A();
}

const A operator<<(A const &, A const &) noexcept // NON_COMPLIANT
{
return A{};
}

class C {
C &operator=(const C &rhs);
};
Expand All@@ -31,3 +36,10 @@ int &operator+(const C &lhs, const C &rhs) { // NON_COMPLIANT
return slocal;
}
} // namespace NS_C

#include <iostream>
struct Test {};
std::ostream &operator<<(std::ostream &os, const Test &) { // COMPLIANT
os << "test";
return os;
}
4 changes: 2 additions & 2 deletionscpp/common/src/codingstandards/cpp/Operator.qll
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -170,8 +170,8 @@ class UserBitwiseOperator extends Function {
op in ["&", "|", "^", "~", "%", "<<", ">>"]
) and
not this.isCompilerGenerated() and
not this.getType().hasName("ostream") and
not this.getType().hasName("istream")
not this.getType().(ReferenceType).getBaseType().hasName("ostream") and
not this.getType().(ReferenceType).getBaseType().hasName("istream")
}
}

Expand Down
1 change: 1 addition & 0 deletionscpp/common/test/includes/standard-library/ostream.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
#ifndef _GHLIBCPP_OSTREAM
#define _GHLIBCPP_OSTREAM
#include "string.h"
#include <ios>

namespace std {
template <class charT, class traits>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp