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

#824 [Partial Fix] : A15-4-4 - Dont report on functions having a noexcept specification with a complex expression#825

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 3 commits intogithub:mainfromrak3-sh:rp/fix-824
Dec 28, 2024
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/2024-12-17-fix-fp-824-a15-4-4
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
- `A15-4-4` - `MissingNoExcept.ql`:
- Reduce false positives by not reporting on functions that have a noexcept specification with a complex expression or call other such functions.
36 changes: 36 additions & 0 deletionscpp/autosar/src/rules/A15-4-4/MissingNoExcept.ql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,36 @@ import codingstandards.cpp.autosar
import codingstandards.cpp.exceptions.ExceptionSpecifications
import codingstandards.cpp.exceptions.ExceptionFlow

// These functions have a noexcept specification that could not be resolved
// to noexcept(true). So either, they are noexcept(false) functions which
// means, they can throw an exception OR they have an expression which
// could not be resolved to "true" or "false". Even in this case, lets
// be more conservative and assume they may thrown an exception.
class FunctionWithUnknownNoExcept extends Function {
FunctionWithUnknownNoExcept() {
// Exists a noexcept specification but not noexcept(true)
exists(this.getADeclarationEntry().getNoExceptExpr()) and
not isNoExceptTrue(this)
}
}

// This predicate checks if a function can call to other functions
// that may have a noexcept specification which cannot be resolved to
// noexcept(true).
predicate mayCallThrowingFunctions(Function f) {
// Exists a call in this function
exists(Call fc |
fc.getEnclosingFunction() = f and
(
// Either this call is to a function with an unknown noexcept OR
fc.getTarget() instanceof FunctionWithUnknownNoExcept
or
// That function can further have calls to unknown noexcept functions.
mayCallThrowingFunctions(fc.getTarget())
)
)
}

from Function f
where
not isExcluded(f, Exceptions1Package::missingNoExceptQuery()) and
Expand All@@ -28,6 +58,12 @@ where
not isNoExceptTrue(f) and
// Not explicitly marked noexcept(false)
not isNoExceptExplicitlyFalse(f) and
// Not having a noexcept specification that
// could not be computed as true or false above.
not exists(f.getADeclarationEntry().getNoExceptExpr()) and
// Not calling function(s) which have a noexcept specification that
// could not be computed as true.
not mayCallThrowingFunctions(f) and
// Not compiler generated
not f.isCompilerGenerated() and
// The function is defined in this database
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp