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

Consider "main()" with typedef'd int return type as MainFunction#647

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 10 commits intogithub:mainfromrak3-sh:rp/m0-1-10-646
Jul 26, 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-07-23-fix-fp-646-M0-1-10.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
- `M0-1-10` - `EncapsulatingFunctions.qll`:
- Fixes #646. Consider typedef'd `int` return types for `main()` function as MainFunction.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
| test.cpp:23:14:23:26 | uncalled_func | Function uncalled_func is never called. |
1 change: 1 addition & 0 deletionscpp/autosar/test/rules/M0-1-10.1/UnusedFunction.qlref
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
rules/M0-1-10/UnusedFunction.ql
39 changes: 39 additions & 0 deletionscpp/autosar/test/rules/M0-1-10.1/test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
#include <cstdint>

namespace mains {
static std::int32_t var;

// @brief namespace_func
static void
namespace_func(void) noexcept { // COMPLIANT: Called from "main" below.
mains::var = -1;
return;
}
} // namespace mains

std::int32_t func2() // COMPLIANT: Called from func1
{
return mains::var + 20;
}

std::int32_t func1() { // COMPLIANT: Called from main
return mains::var + func2(); // func2 called here.
}

std::int32_t uncalled_func() // NON_COMPLIANT: Not called.
{
return mains::var + func1(); // func1 called here.
}

// @brief main
// @return exit code
std::int32_t main(void) {
std::int32_t ret{0};
try {
ret = func1(); // func1 called here.
mains::var += ret;
} catch (...) {
mains::namespace_func(); // namespace_func called here.
}
return ret;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ abstract class EncapsulatingFunction extends Function { }
class MainFunction extends MainLikeFunction {
MainFunction() {
hasGlobalName("main") and
getType() instanceof IntType
getType().resolveTypedefs() instanceof IntType
}
}

Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
| test.cpp:5:9:5:12 | main |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
import cpp
import codingstandards.cpp.EncapsulatingFunctions

from MainFunction m
select m
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
typedef signed int int32_t;

// @brief main
// @return exit code
int32_t main(void) {
int32_t ret{0};
return ret;
}

[8]ページ先頭

©2009-2025 Movatter.jp