-
Notifications
You must be signed in to change notification settings - Fork 77
Add Banned7 package #1105
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
Open
jeongsoolee09
wants to merge
6
commits into
main
Choose a base branch
from
jeongsoolee09/MISRA-C++-2023-Banned7
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Banned7 package #1105
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
478a024
Add and fix stubs
jeongsoolee09 e91aca0
Add stubs
jeongsoolee09 ffb3e06
Fix wthe stubs
jeongsoolee09 997cb7a
Add package files
jeongsoolee09 dce0e80
Finalize draft of 21-6-1 and factor out duplicated code
jeongsoolee09 cd9a841
Fix formatting
jeongsoolee09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** Provides classes for modeling dynamic memory allocation and deallocation functions. */ | ||
|
|
||
| import cpp | ||
|
|
||
| /** | ||
| * An `operator new` or `operator new[]` allocation function called by a placement-new expression. | ||
| * | ||
| * The operator functions have a `std::size_t` as their first parameter and a | ||
| * `void*` parameter somewhere in the rest of the parameter list. | ||
| */ | ||
| class PlacementNewOrNewArrayAllocationFunction extends AllocationFunction { | ||
| PlacementNewOrNewArrayAllocationFunction() { | ||
| this.getName() in ["operator new", "operator new[]"] and | ||
| this.getParameter(0).getType().resolveTypedefs*() instanceof Size_t and | ||
| this.getAParameter().getUnderlyingType() instanceof VoidPointerType | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * A function that has namespace `std` and has name `allocate` or `deallocate`, including but | ||
| * not limited to: | ||
| * - `std::allocator<T>::allocate(std::size_t)` | ||
| * - `std::allocator<T>::deallocate(T*, std::size_t)` | ||
| * - `std::pmr::memory_resource::allocate(std::size_t, std::size_t)` | ||
| * - `std::pmr::memory_resource::deallocate(void*, std::size_t, std::size_t)` | ||
| */ | ||
| class AllocateOrDeallocateStdlibMemberFunction extends MemberFunction { | ||
| AllocateOrDeallocateStdlibMemberFunction() { | ||
| this.getName() in ["allocate", "deallocate"] and | ||
| this.getNamespace().getParentNamespace*() instanceof StdNamespace | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
cpp/common/src/codingstandards/cpp/exclusions/cpp/Banned7.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
|
|
||
| newtype Banned7Query = TDynamicMemoryShouldNotBeUsedQuery() | ||
|
|
||
| predicate isBanned7QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `dynamicMemoryShouldNotBeUsed` query | ||
| Banned7Package::dynamicMemoryShouldNotBeUsedQuery() and | ||
| queryId = | ||
| // `@id` for the `dynamicMemoryShouldNotBeUsed` query | ||
| "cpp/misra/dynamic-memory-should-not-be-used" and | ||
| ruleId = "RULE-21-6-1" and | ||
| category = "advisory" | ||
| } | ||
|
|
||
| module Banned7Package { | ||
| Query dynamicMemoryShouldNotBeUsedQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `dynamicMemoryShouldNotBeUsed` query | ||
| TQueryCPP(TBanned7PackageQuery(TDynamicMemoryShouldNotBeUsedQuery())) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <any.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #ifndef _GHLIBCPP_ANY | ||
| #define _GHLIBCPP_ANY | ||
| namespace std { | ||
|
|
||
| class any { | ||
| public: | ||
| any(); | ||
| any(const any &); | ||
| any(any &&); | ||
| template <typename T> any(T &&); | ||
| }; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_ANY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <bitset.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // stubs/bitset | ||
|
|
||
| #ifndef _GHLIBCPP_BITSET | ||
| #define _GHLIBCPP_BITSET | ||
|
|
||
| #include <cstddef> | ||
|
|
||
| namespace std { | ||
|
|
||
| template <std::size_t N> class bitset { | ||
| public: | ||
| bitset(); | ||
| bitset(unsigned long long); | ||
| }; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_BITSET |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <filesystem.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #ifndef _GHLIBCPP_FILESYSTEM | ||
| #define _GHLIBCPP_FILESYSTEM | ||
|
|
||
| namespace std { | ||
| namespace filesystem { | ||
|
|
||
| class path { | ||
| public: | ||
| path(); | ||
| path(const path&); | ||
| path(path&&); | ||
| path(const char*); | ||
|
|
||
| path operator/(const path&) const; | ||
| }; | ||
|
|
||
| } // namespace filesystem | ||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_FILESYSTEM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <forward_list.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #ifndef _GHLIBCPP_FORWARD_LIST | ||
| #define _GHLIBCPP_FORWARD_LIST | ||
|
|
||
| #include <initializer_list> | ||
| #include <memory> | ||
|
|
||
| namespace std { | ||
|
|
||
| template <typename T, typename Alloc = std::allocator<T>> class forward_list { | ||
| public: | ||
| forward_list(); | ||
| forward_list(const forward_list &); | ||
| forward_list(forward_list &&); | ||
| forward_list(std::initializer_list<T>); | ||
| }; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_FORWARD_LIST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <future.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #ifndef _GHLIBCPP_FUTURE | ||
| #define _GHLIBCPP_FUTURE | ||
|
|
||
| namespace std { | ||
|
|
||
| enum class launch { | ||
| async, | ||
| deferred | ||
| }; | ||
|
|
||
| template<typename T> | ||
| class future { | ||
| public: | ||
| future(); | ||
| future(const future&); | ||
| future(future&&); | ||
| }; | ||
|
|
||
| template<typename T> | ||
| class shared_future { | ||
| public: | ||
| shared_future(); | ||
| shared_future(const shared_future&); | ||
| shared_future(shared_future&&); | ||
| shared_future(future<T>&&); | ||
| }; | ||
|
|
||
| template<typename T> | ||
| class promise { | ||
| public: | ||
| promise(); | ||
| promise(const promise&); | ||
| promise(promise&&); | ||
| future<T> get_future(); | ||
| }; | ||
|
|
||
| template<typename Signature> | ||
| class packaged_task; | ||
|
|
||
| template<typename R, typename... Args> | ||
| class packaged_task<R(Args...)> { | ||
| public: | ||
| packaged_task(); | ||
| packaged_task(const packaged_task&); | ||
| packaged_task(packaged_task&&); | ||
| template<typename F> packaged_task(F&&); | ||
| }; | ||
|
|
||
| template<typename F, typename... Args> | ||
| auto async(F&&, Args&&...) -> future<decltype(declval<F>()(declval<Args>()...))>; | ||
|
|
||
| template<typename F, typename... Args> | ||
| auto async(launch, F&&, Args&&...) -> future<decltype(declval<F>()(declval<Args>()...))>; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_FUTURE | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <list.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #ifndef _GHLIBCPP_LIST | ||
|
|
||
| #define _GHLIBCPP_LIST | ||
|
|
||
| #include <initializer_list> | ||
| #include <memory> | ||
|
|
||
| namespace std { | ||
|
|
||
| template <typename T, typename Alloc = std::allocator<T>> class list { | ||
| public: | ||
| list(); | ||
| list(const list &); | ||
| list(list &&); | ||
| list(std::initializer_list<T>); | ||
| }; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_LIST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future.husesdeclvalin theasyncreturn type, but the header does not include<utility>(wherestd::declvalis declared in these stubs) nor provide its own forward declaration. This can make the stub header ill-formed when included before<utility>(as in the new RULE-21-6-1 test). Add#include <utility>or declaredeclvalbefore it is used.