-
Notifications
You must be signed in to change notification settings - Fork 76
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
base: main
Are you sure you want to change the base?
Add Banned7 package #1105
Changes from 6 commits
478a024
e91aca0
ffb3e06
997cb7a
dce0e80
cd9a841
568daa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| } | ||
| } | ||
| 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())) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <any.h> |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <bitset.h> |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <filesystem.h> |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <forward_list.h> |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <future.h> |
| 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>()...))>; | ||
|
Comment on lines
+49
to
+53
|
||
|
|
||
| } // namespace std | ||
|
|
||
| #endif // _GHLIBCPP_FUTURE | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include <list.h> |
| 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 |
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.
Can we combine this with cpp/common/src/allocations/CustomOperatorNewDelete ?