Skip to content

A7-1-7: exclusions #634

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

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions change_notes/2024-07-05-fix-fp628-630.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `A7-1-7` - `IdentifierDeclarationAndInitializationNotOnSeparateLines.ql`:
- Fixes #628. Excludes Functions.
- Fixes #630. Excludes struct identifiers and variables on the same line when a typedef is used.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ class UniqueLineStmt extends Locatable {
this = d.getADeclarationEntry() and
not d instanceof Parameter and
not d instanceof TemplateParameter and
not d instanceof FunctionTemplateSpecialization and
// TODO - Needs to be enhanced to solve issues with
// templated inner classes.
not d instanceof MemberFunction and
not d instanceof Function and
not d.isFromTemplateInstantiation(_) and
not d.(Function).isCompilerGenerated() and
not d.(Variable).isCompilerGenerated() and
not exists(RangeBasedForStmt f | f.getADeclaration() = d) and
not exists(DeclStmt declStmt, ForStmt f |
Expand All @@ -52,6 +50,9 @@ where
DeclarationsPackage::identifierDeclarationAndInitializationNotOnSeparateLinesQuery()) and
not e1 = e2 and
not e1.(DeclarationEntry) = e2 and
//omit the cases where there is one struct identifier on a struct var line used with typedef
not exists(Struct s | s.getADeclarationEntry() = e1 and e1 instanceof TypeDeclarationEntry) and
not exists(Struct s | s.getATypeNameUse() = e1 and e1 instanceof TypeDeclarationEntry) and
exists(Location l1, Location l2 |
e1.getLocation() = l1 and
e2.getLocation() = l2 and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
| test.cpp:66:12:66:12 | definition of g | Expression statement and identifier are on the same line. |
| test.cpp:82:7:82:10 | definition of S3_a | Expression statement and identifier are on the same line. |
| test.cpp:82:17:82:20 | definition of S3_b | Expression statement and identifier are on the same line. |
| test.cpp:154:24:154:24 | definition of y | Expression statement and identifier are on the same line. |
6 changes: 6 additions & 0 deletions cpp/autosar/test/rules/A7-1-7/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ struct s_357 {
// clang-format on
}
};

void example_function() { f1(); } // COMPLIANT

// clang-format off
typedef struct x { int y; } z; //COMPLIANT - for struct typedef and struct var //NON_COMPLIANT - for struct all on one line
// clang-format on
Loading