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

M8-0-1/A7-1-5: Exclude compiler generated DeclStmts#322

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 4 commits intomainfromlcartey/fix-range-based-for-loops
Aug 1, 2023
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/2023-07-04-remove-compiler-generated-vars.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
* `A7-1-5` - exclude compiler generated variables, such as those generated by for loops.
* `M8-0-1` - exclude compiler generated variables, such as those generated by for loops.
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,8 @@ where
v.getInitializer().getExpr()instanceofLambdaExpression
or
v.getInitializer().getExpr()instanceofClassAggregateLiteral
)
)and
// Exclude compiler generated variables
notv.isCompilerGenerated()
selectv,
"Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer."
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,5 +20,7 @@ import codingstandards.cpp.autosar
from DeclStmt ds
where
not isExcluded(ds, InitializationPackage::multipleLocalDeclaratorsQuery()) and
count(ds.getADeclaration()) > 1
count(Declaration d | d = ds.getADeclaration()) > 1 and
// Not a compiler generated `DeclStmt`, such as in the range-based for loop
not ds.isCompilerGenerated()
select ds, "Declaration list contains more than one declaration."
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,3 +4,4 @@
| test.cpp:27:8:27:8 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
| test.cpp:28:8:28:8 | b | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
| test.cpp:81:10:81:10 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
| test.cpp:111:19:111:19 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
6 changes: 6 additions & 0 deletionscpp/autosar/test/rules/A7-1-5/test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,4 +105,10 @@ void instantiate() {
Test_381<int> t381;
t381.test_381_1();
t381.test_381_2();
}

voidtest_loop() {
for (constauto a : {8,9,10}) {
a;
}
}
7 changes: 7 additions & 0 deletionscpp/autosar/test/rules/M8-0-1/test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,3 +15,10 @@ class ClassA {
int m1, m2; // NON_COMPLIANT
int m3; // COMPLIANT
};

#include <vector>
void test_loop(std::vector<ClassA> v) {
for (const auto b : v) { // COMPLIANT - DeclStmt is compiler generated
b;
}
}

[8]ページ先頭

©2009-2025 Movatter.jp