Bug 1511319 - Ensure that tools/clang-tidy/test doesn't get reformatted using clang-format; r=sylvestre a=Aryx

Reformatting this directory can break some of the tests here.

Differential Revision: https://phabricator.services.mozilla.com/D13518
This commit is contained in:
Ehsan Akhgari 2018-11-30 06:32:29 -05:00
parent 3fb831e8a1
commit 6b07492159
66 changed files with 293 additions and 234 deletions

View File

@ -62,6 +62,10 @@ widget/gtk/wayland/gtk-primary-selection-protocol.c
# and reformatting them can break generating that wrapper.
config/windows-h-.*.h
# Exclude tools/clang-tidy/test from automatic reformatting, since it can
# break some of the tests in that directory.
tools/clang-tidy/test/.*
# The XPTCall stubs files have some inline assembly macros
# that get reformatted badly. See bug 1510781.
xpcom/reflect/xptcall/md/win32/.*

View File

@ -1,4 +1,6 @@
// bugprone-argument-comment
void f(int x, int y);
void g() { f(/*y=*/0, /*z=*/0); }
void g() {
f(/*y=*/0, /*z=*/0);
}

View File

@ -1,16 +1,17 @@
// https://clang.llvm.org/extra/clang-tidy/checks/bugprone-bool-pointer-implicit-conversion.html
bool test(bool* pointer_to_bool, int* pointer_to_int) {
if (pointer_to_bool) { // warning for pointer to bool
bool test(bool* pointer_to_bool, int* pointer_to_int)
{
if (pointer_to_bool) { // warning for pointer to bool
}
if (pointer_to_int) { // no warning for pointer to int
if (pointer_to_int) { // no warning for pointer to int
}
if (!pointer_to_bool) { // no warning, but why not??
if (!pointer_to_bool) { // no warning, but why not??
}
if (pointer_to_bool != nullptr) { // no warning for nullptr comparison
if (pointer_to_bool != nullptr) { // no warning for nullptr comparison
}
// no warning on return, but why not??

View File

@ -1,7 +1,3 @@
namespace na {
struct A;
}
namespace nb {
struct A {};
} // namespace nb
namespace na { struct A; }
namespace nb { struct A {}; }
nb::A a;

View File

@ -1,4 +1,5 @@
void f1() {
void f1()
{
double d;
int x;

View File

@ -1,5 +1,5 @@
float f() {
int a = 2;
int b = 10;
return a / b;
return a/b;
}

View File

@ -1,5 +1,5 @@
#define BAD1 -1
#define BAD2 1 + 2
#define BAD3(A) (A + 1)
#define BAD4(x) ((unsigned char)(x & 0xff))
#define BAD5(X) A* B = (C*)X + 2
#define BAD1 -1
#define BAD2 1+2
#define BAD3(A) (A+1)
#define BAD4(x) ((unsigned char)(x & 0xff))
#define BAD5(X) A*B=(C*)X+2

View File

@ -5,22 +5,24 @@
static int g;
int function_with_side_effects(int i) {
int function_with_side_effects(int i)
{
g += i;
return g;
}
void test() {
void test()
{
int i;
i = MACRO_WITHOUT_REPEATED_ARG(1); // OK
i = MACRO_WITH_REPEATED_ARG(1); // OK
i = MACRO_WITHOUT_REPEATED_ARG(1); // OK
i = MACRO_WITH_REPEATED_ARG(1); // OK
i = MACRO_WITHOUT_REPEATED_ARG(i); // OK
i = MACRO_WITH_REPEATED_ARG(i); // OK
i = MACRO_WITHOUT_REPEATED_ARG(i); // OK
i = MACRO_WITH_REPEATED_ARG(i); // OK
i = MACRO_WITHOUT_REPEATED_ARG(function_with_side_effects(i)); // OK
i = MACRO_WITH_REPEATED_ARG(function_with_side_effects(i)); // NO WARNING
i = MACRO_WITHOUT_REPEATED_ARG(function_with_side_effects(i)); // OK
i = MACRO_WITH_REPEATED_ARG(function_with_side_effects(i)); // NO WARNING
i = MACRO_WITHOUT_REPEATED_ARG(i++); // OK
i = MACRO_WITH_REPEATED_ARG(i++); // WARNING
i = MACRO_WITHOUT_REPEATED_ARG(i++); // OK
i = MACRO_WITH_REPEATED_ARG(i++); // WARNING
}

View File

@ -1 +1,3 @@
long f(int x) { return (long)(x * 1000); }
long f(int x) {
return (long)(x * 1000);
}

View File

@ -5,5 +5,6 @@ void F();
F()
void positives() {
if (1) BAD_MACRO(1);
if (1)
BAD_MACRO(1);
}

View File

@ -2,15 +2,16 @@
#include "structures.h"
void test() {
void test()
{
// A common mistake is to swap parameters to the fill string-constructor.
std::string str('x', 50); // should be str(50, 'x')
std::string str('x', 50); // should be str(50, 'x')
// Calling the string-literal constructor with a length bigger than the
// literal is suspicious and adds extra random characters to the string.
std::string("test", 200); // Will include random characters after "test".
std::string("test", 200); // Will include random characters after "test".
// Creating an empty string from constructors with parameters is considered
// suspicious. The programmer should use the empty constructor instead.
std::string("test", 0); // Creation of an empty string.
std::string("test", 0); // Creation of an empty string.
}

View File

@ -2,24 +2,27 @@
#include "structures.h"
void test_int() {
void test_int()
{
// Numeric types can be implicitly casted to character types.
std::string s;
int x = 5965;
s = 6; // warning
s = x; // warning
s = 6; // warning
s = x; // warning
}
void test_conversion() {
void test_conversion()
{
// Use the appropriate conversion functions or character literals.
std::string s;
int x = 5965;
s = '6'; // OK
s = std::to_string(x); // OK
s = '6'; // OK
s = std::to_string(x); // OK
}
void test_cast() {
void test_cast()
{
// In order to suppress false positives, use an explicit cast.
std::string s;
s = static_cast<char>(6); // OK
s = static_cast<char>(6); // OK
}

View File

@ -2,20 +2,21 @@
#include "structures.h"
void test(int* ip, char* cp) {
void test(int* ip, char* cp)
{
// Case 1: Fill value is a character '0' instead of NUL '\0'.
memset(ip, '0', 1); // WARNING: suspicious for non-char pointers
memset(cp, '0', 1); // OK for char pointers
memset(ip, '0', 1); // WARNING: suspicious for non-char pointers
memset(cp, '0', 1); // OK for char pointers
// Case 2: Fill value is truncated.
memset(ip, 0xabcd, 1); // WARNING: fill value gets truncated
memset(ip, 0x00cd, 1); // OK because value 0xcd is not truncated.
memset(ip, 0x00, 1); // OK because value is not truncated.
memset(ip, 0xabcd, 1); // WARNING: fill value gets truncated
memset(ip, 0x00cd, 1); // OK because value 0xcd is not truncated.
memset(ip, 0x00, 1); // OK because value is not truncated.
// Case 3: Byte count is zero.
memset(ip, sizeof(int), 0); // WARNING: zero length, potentially swapped
memset(ip, sizeof(int), 1); // OK with non-zero length
memset(ip, sizeof(int), 0); // WARNING: zero length, potentially swapped
memset(ip, sizeof(int), 1); // OK with non-zero length
// See clang bug https://bugs.llvm.org/show_bug.cgi?id=38098
memset(ip, 8, 0); // OK with zero length without sizeof
memset(ip, 8, 0); // OK with zero length without sizeof
}

View File

@ -1,9 +1,9 @@
const char* Cartoons[] = {
"Bugs Bunny",
"Homer Simpson",
"Mickey Mouse",
"Bart Simpson",
"Charlie Brown" // There is a missing comma here.
"Fred Flintstone",
"Popeye",
"Bugs Bunny",
"Homer Simpson",
"Mickey Mouse",
"Bart Simpson",
"Charlie Brown" // There is a missing comma here.
"Fred Flintstone",
"Popeye",
};

View File

@ -1,9 +1,8 @@
// bugprone-suspicious-semicolon
void nop();
void fail1() {
int x = 0;
if (x > 5)
;
nop();
void fail1()
{
int x = 0;
if(x > 5); nop();
}

View File

@ -3,5 +3,6 @@ static const char A[] = "abc";
int strcmp(const char *, const char *);
int test_warning_patterns() {
if (strcmp(A, "a")) return 0;
if (strcmp(A, "a"))
return 0;
}

View File

@ -5,21 +5,22 @@ void test_d_i_i(double d, int i, int ii);
void test_i_d(int i, double d);
void test_i_i_d(int i, int ii, double d);
void test() {
void test()
{
double d = 1;
int i = 1;
test_d_i(d, i); // OK
test_d_i(i, d); // WARNING
test_d_i(d, i); // OK
test_d_i(i, d); // WARNING
test_i_d(i, d); // OK
test_i_d(d, i); // WARNING
test_i_d(i, d); // OK
test_i_d(d, i); // WARNING
test_i_i_d(i, i, d); // OK
test_i_i_d(i, d, i); // WARNING
test_i_i_d(d, i, i); // NO WARNING after second parameter
test_i_i_d(i, i, d); // OK
test_i_i_d(i, d, i); // WARNING
test_i_i_d(d, i, i); // NO WARNING after second parameter
test_d_i_i(d, i, i); // OK
test_d_i_i(i, d, i); // WARNING
test_d_i_i(i, i, d); // NO WARNING after second parameter
test_d_i_i(d, i, i); // OK
test_d_i_i(i, d, i); // WARNING
test_d_i_i(i, i, d); // NO WARNING after second parameter
}

View File

@ -1,22 +1,25 @@
// https://clang.llvm.org/extra/clang-tidy/checks/bugprone-unused-raii.html
struct scoped_lock {
struct scoped_lock
{
scoped_lock() {}
~scoped_lock() {}
};
#define SCOPED_LOCK_MACRO(m) scoped_lock()
struct trivial_scoped_lock {
struct trivial_scoped_lock
{
trivial_scoped_lock() {}
};
scoped_lock test() {
scoped_lock(); // misc-unused-raii warning!
scoped_lock test()
{
scoped_lock(); // misc-unused-raii warning!
SCOPED_LOCK_MACRO(); // no warning for macros
SCOPED_LOCK_MACRO(); // no warning for macros
trivial_scoped_lock(); // no warning for trivial objects without destructors
trivial_scoped_lock(); // no warning for trivial objects without destructors
return scoped_lock(); // no warning for return values
return scoped_lock(); // no warning for return values
}

View File

@ -9,7 +9,7 @@ struct unique_ptr {
void reset(T *ptr);
T &operator*() const;
T *operator->() const;
T &operator[](size_t i) const;
T& operator[](size_t i) const;
};
template <typename>
@ -34,10 +34,10 @@ template <typename _Tp>
constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept {
return static_cast<typename remove_reference<_Tp>::type &&>(__t);
}
} // namespace std
}
class A {
public:
public:
A();
A(const A &);
A(A &&);

View File

@ -1,3 +1,4 @@
void test(int z) {
if (z == 0) int x = 1 / z;
if (z == 0)
int x = 1 / z;
}

View File

@ -1,5 +1,6 @@
int f(int *p) __attribute__((nonnull));
void test(int *p) {
if (!p) f(p); // warn
if (!p)
f(p); // warn
}

View File

@ -1,5 +1,5 @@
class C {
public:
public:
int x;
};

View File

@ -2,43 +2,49 @@
void use(int *p);
void test_use_parameter_after_delete(int *p) {
void test_use_parameter_after_delete(int *p)
{
delete p;
use(p); // warning: use after free
use(p); // warning: use after free
}
class SomeClass {
public:
public:
void f();
};
void test_use_local_after_delete() {
void test_use_local_after_delete()
{
SomeClass *c = new SomeClass;
delete c;
c->f(); // warning: use after free
c->f(); // warning: use after free
}
// XXX clang documentation says this should cause a warning but it doesn't!
void test_delete_alloca() {
void test_delete_alloca()
{
int *p = (int *)__builtin_alloca(sizeof(int));
delete p; // NO warning: deleting memory allocated by alloca
delete p; // NO warning: deleting memory allocated by alloca
}
void test_double_free() {
void test_double_free()
{
int *p = new int;
delete p;
delete p; // warning: attempt to free released
delete p; // warning: attempt to free released
}
void test_delete_local() {
void test_delete_local()
{
int i;
delete &i; // warning: delete address of local
delete &i; // warning: delete address of local
}
// XXX clang documentation says this should cause a warning but it doesn't!
void test_delete_offset() {
void test_delete_offset()
{
int *p = new int[1];
delete[](++p);
// NO warning: argument to 'delete[]' is offset by 4 bytes
// from the start of memory allocated by 'new[]'
delete[] (++p);
// NO warning: argument to 'delete[]' is offset by 4 bytes
// from the start of memory allocated by 'new[]'
}

View File

@ -1,3 +1,6 @@
// https://clang-analyzer.llvm.org/available_checks.html
void test() { int *p = new int; } // warning
void test()
{
int *p = new int;
} // warning

View File

@ -2,5 +2,6 @@
// clang-analyzer-deadcode.DeadStores
void test() {
int x;
x = 1; // warn
x = 1; // warn
}

View File

@ -1,4 +1,3 @@
void test() {
for (float x = 0.1f; x <= 1.0f; x += 0.1f) {
}
for (float x = 0.1f; x <= 1.0f; x += 0.1f) {}
}

View File

@ -1,3 +1,5 @@
#include "structures.h"
void test() { setuid(1); }
void test() {
setuid(1);
}

View File

@ -1,3 +1,5 @@
#include "structures.h"
int test_bcmp(void *a, void *b, size_t n) { return bcmp(a, b, n); }
int test_bcmp(void *a, void *b, size_t n) {
return bcmp(a, b, n);
}

View File

@ -1,3 +1,5 @@
#include "structures.h"
void test_bcopy(void *a, void *b, size_t n) { bcopy(a, b, n); }
void test_bcopy(void *a, void *b, size_t n) {
bcopy(a, b, n);
}

View File

@ -1,3 +1,6 @@
#include "structures.h"
void test_bzero(void *a, size_t n) { bzero(a, n); }
void test_bzero(void *a, size_t n) {
bzero(a, n);
}

View File

@ -1,3 +1,5 @@
#include "structures.h"
void test() { mkstemp("XX"); }
void test() {
mkstemp("XX");
}

View File

@ -1,3 +1,5 @@
#include "structures.h"
void test() { char *x = mktemp("/tmp/zxcv"); }
void test() {
char *x = mktemp("/tmp/zxcv");
}

View File

@ -1,2 +1,4 @@
#include <stdlib.h>
void test() { random(); }
void test() {
random();
}

View File

@ -1,3 +1,5 @@
#include "structures.h"
void test() { vfork(); }
void test() {
vfork();
}

View File

@ -2,30 +2,36 @@
#include "structures.h"
void test_malloc() {
int *p = (int *)malloc(1);
void test_malloc()
{
int *p = (int*) malloc(1);
free(p);
free(p); // warning: attempt to free released memory
free(p); // warning: attempt to free released memory
}
void test_use_after_free() {
int *p = (int *)malloc(sizeof(int));
void test_use_after_free()
{
int *p = (int*) malloc(sizeof(int));
free(p);
*p = 1; // warning: use after free
*p = 1; // warning: use after free
}
void test_leak() {
int *p = (int *)malloc(1);
if (p) return; // warning: memory is never released
void test_leak()
{
int *p = (int*) malloc(1);
if (p)
return; // warning: memory is never released
}
void test_free_local() {
int a[] = {1};
free(a); // warning: argument is not allocated by malloc
void test_free_local()
{
int a[] = { 1 };
free(a); // warning: argument is not allocated by malloc
}
void test_free_offset() {
int *p = (int *)malloc(sizeof(char));
void test_free_offset()
{
int *p = (int*) malloc(sizeof(char));
p = p - 1;
free(p); // warning: argument to free() is offset by -4 bytes
free(p); // warning: argument to free() is offset by -4 bytes
}

View File

@ -2,7 +2,8 @@
#include "structures.h"
void test() {
void test()
{
char dest[3];
strncat(dest, "***", sizeof(dest)); // warning : potential buffer overflow
strncat(dest, "***", sizeof(dest)); // warning : potential buffer overflow
}

View File

@ -2,11 +2,13 @@
#include "structures.h"
int my_strlen(const char* s) {
return strlen(s); // warning
int my_strlen(const char* s)
{
return strlen(s); // warning
}
int bad_caller() {
int bad_caller()
{
const char* s = nullptr;
return my_strlen(s);
}

View File

@ -1,6 +1,5 @@
namespace std {
typedef struct FILE {
} FILE;
} // namespace std
typedef struct FILE {} FILE;
}
void g(std::FILE f);

View File

@ -1,15 +1,18 @@
// https://clang.llvm.org/extra/clang-tidy/checks/misc-unused-alias-decls.html
namespace n1 {
namespace n2 {
namespace n3 {
int qux = 42;
namespace n2 {
namespace n3 {
int qux = 42;
}
}
}
} // namespace n2
} // namespace n1
namespace n1_unused = ::n1; // WARNING
namespace n12_unused = n1::n2; // WARNING
namespace n123 = n1::n2::n3; // OK
int test() { return n123::qux; }
int test()
{
return n123::qux;
}

View File

@ -1,6 +1,4 @@
// misc-unused-using-decls
namespace n {
class C;
}
namespace n { class C; }
using n::C;

View File

@ -1,4 +1,6 @@
#include "structures.h"
int add(int x, int y) { return x + y; }
void f_bind() { auto clj = std::bind(add, 2, 2); }
void f_bind() {
auto clj = std::bind(add, 2, 2);
}

View File

@ -1,3 +1,5 @@
// modernize-redundant-void-arg
int foo(void) { return 0; }
int foo(void) {
return 0;
}

View File

@ -5,6 +5,7 @@ void func() {
std::vector<int> my_container;
for (std::vector<int>::iterator I = my_container.begin(),
E = my_container.end();
I != E; ++I) {
I != E;
++I) {
}
}

View File

@ -1,6 +1,6 @@
class IL {
public:
public:
IL() {}
~IL() {}
};

View File

@ -1,5 +1,5 @@
struct PositivePrivate {
private:
private:
PositivePrivate();
PositivePrivate(const PositivePrivate &);
PositivePrivate &operator=(PositivePrivate &&);

View File

@ -1,5 +1,5 @@
#define NULL 0
void f(void) {
char *str = NULL; // ok
char *str = NULL; // ok
(void)str;
}

View File

@ -1,5 +1,5 @@
class Base {
public:
public:
virtual void foo() = 0;
};

View File

@ -1,12 +1,12 @@
template <typename T>
struct Iterator {
void operator++() {}
const T &operator*() {
static T *TT = new T();
const T& operator*() {
static T* TT = new T();
return *TT;
}
bool operator!=(const Iterator &) { return false; }
typedef const T &const_reference;
typedef const T& const_reference;
};
template <typename T>
struct View {

View File

@ -37,10 +37,7 @@ struct SimpleClass {
typedef View<Iterator<SimpleClass>> SimpleView;
void ImplicitSimpleClassIterator() {
for (const ImplicitWrapper<SimpleClass>& foo : SimpleView()) {
}
for (const ImplicitWrapper<SimpleClass> foo : SimpleView()) {
}
for (ImplicitWrapper<SimpleClass> foo : SimpleView()) {
}
for (const ImplicitWrapper<SimpleClass>& foo : SimpleView()) {}
for (const ImplicitWrapper<SimpleClass> foo : SimpleView()) {}
for (ImplicitWrapper<SimpleClass> foo : SimpleView()) {}
}

View File

@ -1,18 +1,15 @@
namespace std {
template <typename T>
struct less {
template <typename T> struct less {
bool operator()(const T &lhs, const T &rhs) { return lhs < rhs; }
};
template <typename T>
struct greater {
template <typename T> struct greater {
bool operator()(const T &lhs, const T &rhs) { return lhs > rhs; }
};
struct iterator_type {};
template <typename K, typename Cmp = less<K>>
struct set {
template <typename K, typename Cmp = less<K>> struct set {
typedef iterator_type iterator;
iterator find(const K &k);
unsigned count(const K &k);
@ -24,13 +21,10 @@ struct set {
};
template <typename FwIt, typename K>
FwIt find(FwIt, FwIt end, const K &) {
return end;
FwIt find(FwIt, FwIt end, const K &) { return end; }
}
} // namespace std
template <typename T>
void f(const T &t) {
template <typename T> void f(const T &t) {
std::set<int> s;
find(s.begin(), s.end(), 46);
}

View File

@ -1,6 +1,7 @@
#include "structures.h"
void foo() {
void foo()
{
std::vector<int> v;
int n = 100;
for (int i = 0; i < n; ++i) {

View File

@ -8,7 +8,7 @@ template <typename _Tp>
constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
}
} // namespace std
} // namespace std
struct TriviallyCopyable {
int i;

View File

@ -1,6 +1,6 @@
struct B {
B() {}
B(const B &) {}
B(const B&) {}
B(B &&) {}
};

View File

@ -1,6 +1,7 @@
double acos(double);
void check_all_fns() {
void check_all_fns()
{
float a;
acos(a);
}

View File

@ -2,4 +2,6 @@
extern const std::string& constReference();
void foo() { const std::string UnnecessaryCopy = constReference(); }
void foo() {
const std::string UnnecessaryCopy = constReference();
}

View File

@ -1,3 +1,4 @@
#include "structures.h"
void f(const std::string Value) {}
void f(const std::string Value) {
}

View File

@ -1,17 +1,14 @@
void do_something(const char *) {}
bool cond(const char *) { return false; }
bool cond(const char *) {
return false;
}
void test() {
if (cond("if0") /*comment*/) do_something("same-line");
if (cond("if0") /*comment*/) do_something("same-line");
}
void foo() {
if (1)
while (2)
if (3)
for (;;) do
;
while (false) /**/; /**/
if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
}

View File

@ -2,5 +2,6 @@
void foo() {
std::string a;
if (a.size()) return;
if (a.size())
return;
}

View File

@ -1,4 +1,6 @@
void f() {}
void f() {
}
void foo() {
if (true)

View File

@ -43,19 +43,13 @@ void f() {
int exp = (int)true;
if (x == b) {
}
if (x != b) {
}
if (x == b) {}
if (x != b) {}
if (b == exp) {
}
if (exp == b) {
}
if (b == exp) {}
if (exp == b) {}
char* ptr;
// Shouldn't trigger a checker warning since we are using
// AllowPointerConditions
if (ptr) {
}
// Shouldn't trigger a checker warning since we are using AllowPointerConditions
if (ptr) {}
}

View File

@ -2,4 +2,5 @@ struct S {
void f(int x);
};
void S::f(int y) {}
void S::f(int y) {
}

View File

@ -1,9 +1,11 @@
void f() {}
void f()
{
}
void foo() {
if (1)
if (0)
f();
else
f();
else
f();
}

View File

@ -9,8 +9,12 @@ struct unique_ptr {
T* get() const;
explicit operator bool() const noexcept;
};
} // namespace std
}
struct A {};
struct A {
};
void foo() {
A& b2 = *std::unique_ptr<A>().get();
}
void foo() { A& b2 = *std::unique_ptr<A>().get(); }

View File

@ -1,3 +1,5 @@
#include "structures.h"
int foo() { std::string a = ""; }
int foo() {
std::string a = "";
}

View File

@ -6,4 +6,6 @@ int C::x = 0;
// Expressions with side effects
C &f(int, int, int, int);
void g() { f(1, 2, 3, 4).x; }
void g() {
f(1, 2, 3, 4).x;
}

View File

@ -1,5 +1,4 @@
// Proxy file in order to define generic data types, to avoid binding with
// system headers
// Proxy file in order to define generic data types, to avoid binding with system headers
typedef __SIZE_TYPE__ size_t;
@ -10,27 +9,26 @@ typedef size_t size_t;
template <class T>
class vector {
public:
typedef T *iterator;
typedef const T *const_iterator;
typedef T &reference;
typedef const T &const_reference;
typedef T* iterator;
typedef const T* const_iterator;
typedef T& reference;
typedef const T& const_reference;
typedef size_t size_type;
explicit vector();
explicit vector(size_type n);
void swap(vector &other);
void push_back(const T &val);
void push_back(const T& val);
template <class... Args>
void emplace_back(Args &&... args);
template <class... Args> void emplace_back(Args &&... args);
void reserve(size_t n);
void resize(size_t n);
size_t size();
const_reference operator[](size_type) const;
reference operator[](size_type);
const_reference operator[] (size_type) const;
reference operator[] (size_type);
const_iterator begin() const;
const_iterator end() const;
@ -38,7 +36,7 @@ class vector {
template <typename T>
class basic_string {
public:
public:
typedef basic_string<T> _Type;
basic_string() {}
basic_string(const T *p);
@ -47,13 +45,12 @@ class basic_string {
~basic_string() {}
size_t size() const;
bool empty() const;
size_t find(const char *s, size_t pos = 0) const;
size_t find (const char* s, size_t pos = 0) const;
const T *c_str() const;
_Type &assign(const T *s);
_Type& assign(const T *s);
basic_string<T> &operator=(T ch);
basic_string<T> *operator+=(const basic_string<T> &) {}
friend basic_string<T> operator+(const basic_string<T> &,
const basic_string<T> &) {}
friend basic_string<T> operator+(const basic_string<T> &, const basic_string<T> &) {}
};
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
@ -68,10 +65,10 @@ class unique_ptr {
public:
unique_ptr();
~unique_ptr();
explicit unique_ptr(T *);
explicit unique_ptr(T*);
template <typename U, typename E>
unique_ptr(unique_ptr<U, E> &&);
T *release();
unique_ptr(unique_ptr<U, E>&&);
T* release();
};
template <class Fp, class... Arguments>
@ -79,7 +76,7 @@ class bind_rt {};
template <class Fp, class... Arguments>
bind_rt<Fp, Arguments...> bind(Fp &&, Arguments &&...);
} // namespace std
}
typedef unsigned int uid_t;
typedef unsigned int pid_t;
@ -98,8 +95,9 @@ pid_t vfork(void);
int abort() { return 0; }
#define assert(x) \
if (!(x)) (void)abort()
#define assert(x) \
if (!(x)) \
(void)abort()
size_t strlen(const char *s);
char *strncat(char *s1, const char *s2, size_t);