Skip to content
Draft
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
26 changes: 26 additions & 0 deletions cpp/common/src/codingstandards/cpp/exclusions/cpp/Banned7.qll
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
Expand Up @@ -7,6 +7,7 @@ import Banned1
import Banned2
import Banned3
import Banned4
import Banned7
import BannedAPIs
import BannedFunctions
import BannedLibraries
Expand Down Expand Up @@ -104,6 +105,7 @@ newtype TCPPQuery =
TBanned2PackageQuery(Banned2Query q) or
TBanned3PackageQuery(Banned3Query q) or
TBanned4PackageQuery(Banned4Query q) or
TBanned7PackageQuery(Banned7Query q) or
TBannedAPIsPackageQuery(BannedAPIsQuery q) or
TBannedFunctionsPackageQuery(BannedFunctionsQuery q) or
TBannedLibrariesPackageQuery(BannedLibrariesQuery q) or
Expand Down Expand Up @@ -201,6 +203,7 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId, string cat
isBanned2QueryMetadata(query, queryId, ruleId, category) or
isBanned3QueryMetadata(query, queryId, ruleId, category) or
isBanned4QueryMetadata(query, queryId, ruleId, category) or
isBanned7QueryMetadata(query, queryId, ruleId, category) or
isBannedAPIsQueryMetadata(query, queryId, ruleId, category) or
isBannedFunctionsQueryMetadata(query, queryId, ruleId, category) or
isBannedLibrariesQueryMetadata(query, queryId, ruleId, category) or
Expand Down
1 change: 1 addition & 0 deletions cpp/common/test/includes/standard-library/any
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <any.h>
15 changes: 15 additions & 0 deletions cpp/common/test/includes/standard-library/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
1 change: 1 addition & 0 deletions cpp/common/test/includes/standard-library/bitset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <bitset.h>
18 changes: 18 additions & 0 deletions cpp/common/test/includes/standard-library/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
12 changes: 7 additions & 5 deletions cpp/common/test/includes/standard-library/deque.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef _GHLIBCPP_DEQUE
#define _GHLIBCPP_DEQUE
#include <iterator>
#include <string>
#include "memory.h"
#include <initializer_list>
#include <empty.h>
#include <initializer_list>
#include <iterator>
#include <string>

namespace std {
template <class T, class Allocator = std::allocator<T>> class deque {
Expand All @@ -14,7 +14,9 @@ template <class T, class Allocator = std::allocator<T>> class deque {
typedef value_type &reference;
typedef const value_type &const_reference;

deque() = default;
deque();
deque(const deque &);
deque(deque &&);
deque(std::initializer_list<T>, const Allocator & = Allocator());

typedef __iterator<T> iterator;
Expand All @@ -40,4 +42,4 @@ template <class T, class Allocator = std::allocator<T>> class deque {
};
} // namespace std

#endif // _GHLIBCPP_DEQUE
#endif // _GHLIBCPP_DEQUE
1 change: 1 addition & 0 deletions cpp/common/test/includes/standard-library/filesystem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <filesystem.h>
20 changes: 20 additions & 0 deletions cpp/common/test/includes/standard-library/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
1 change: 1 addition & 0 deletions cpp/common/test/includes/standard-library/forward_list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <forward_list.h>
19 changes: 19 additions & 0 deletions cpp/common/test/includes/standard-library/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
26 changes: 25 additions & 1 deletion cpp/common/test/includes/standard-library/fstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,36 @@ class basic_fstream : public std::basic_iostream<CharT, Traits> {
// constructors
basic_fstream();
explicit basic_fstream(const char *s);
basic_fstream(const basic_fstream &);
basic_fstream(basic_fstream &&);
// members
bool is_open() const;
void open(const string &s);
void close();
};

template <typename CharT, class Traits> class basic_ifstream {
public:
basic_ifstream();
basic_ifstream(const basic_ifstream &);
basic_ifstream(basic_ifstream &&);
basic_ifstream(const char *);
};

template <typename CharT, class Traits> class basic_ofstream {
public:
basic_ofstream();
basic_ofstream(const basic_ofstream &);
basic_ofstream(basic_ofstream &&);
basic_ofstream(const char *);
};

using fstream = basic_fstream<char>;
using wfstream = basic_fstream<wchar_t>;
using ifstream = basic_ifstream<char>;
using wifstream = basic_ifstream<wchar_t>;
using ofstream = basic_ofstream<char>;
using wofstream = basic_ofstream<wchar_t>;
} // namespace std

#endif // _GHLIBCPP_FSTREAM
#endif // _GHLIBCPP_FSTREAM
2 changes: 2 additions & 0 deletions cpp/common/test/includes/standard-library/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ template <class F, class T> binder1st<F> bind1st(const F &f, const T &x);
template <class F, class T> binder2nd<F> bind2nd(const F &f, const T &x);

template <class T> class reference_wrapper {
public:
reference_wrapper(T &ref) : ref(addressof(ref)) {}
reference_wrapper(const reference_wrapper&);
reference_wrapper(T &&ref) = delete;

operator T &() const { return *ref; }
Expand Down
1 change: 1 addition & 0 deletions cpp/common/test/includes/standard-library/future
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <future.h>
57 changes: 57 additions & 0 deletions cpp/common/test/includes/standard-library/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>()...))>;

} // namespace std

#endif // _GHLIBCPP_FUTURE
2 changes: 1 addition & 1 deletion cpp/common/test/includes/standard-library/istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ getline(basic_istream<charT, traits> &is,
typedef basic_istream<char> istream;
} // namespace std

#endif // _LIBCPP_ISTREAM
#endif // _LIBCPP_ISTREAM
1 change: 1 addition & 0 deletions cpp/common/test/includes/standard-library/list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <list.h>
20 changes: 20 additions & 0 deletions cpp/common/test/includes/standard-library/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
12 changes: 8 additions & 4 deletions cpp/common/test/includes/standard-library/map
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<_Key>>
class multimap {
public:
multimap();
multimap(const multimap&);
multimap(multimap&&);
multimap(std::initializer_list<std::pair<const _Key, _Tp>>);
typedef std::pair<const _Key, _Tp> value_type;
typedef std::__iterator<value_type> iterator;
typedef std::__iterator<value_type> const_iterator;
Expand All @@ -18,14 +22,16 @@ public:
iterator end();
const_iterator cbegin();
const_iterator cend();

multimap();
};

template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<_Key>>
class map {
public:
map();
map(const map&);
map(map&&);
map(std::initializer_list<std::pair<const _Key, _Tp>>);
typedef std::pair<const _Key, _Tp> value_type;
typedef std::__iterator<value_type> iterator;
typedef std::__iterator<value_type> const_iterator;
Expand All @@ -34,7 +40,5 @@ public:
iterator end();
const_iterator cbegin();
const_iterator cend();

map();
};
} // namespace std
Loading
Loading