Skip to content

Commit f5fcc30

Browse files
committed
Fix formatting
1 parent 257cba6 commit f5fcc30

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

compiler-rt/test/asan/TestCases/stack_container_dynamic_lib.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
// Test to demonstrate compile-time disabling of container-overflow checks
1+
// Test to demonstrate compile-time disabling of container-overflow checks
22
// in order to handle uninstrumented libraries
33

44
// Mimic a closed-source library compiled without ASan
55
// RUN: %clangxx_asan -fno-sanitize=address -DSHARED_LIB %s -fPIC -shared -o %t-so.so
66

7-
// RUN: %clangxx_asan %s %libdl -o %t
7+
// RUN: %clangxx_asan %s %libdl -o %t
88
// RUN: not %run %t 2>&1 | FileCheck %s
99

10-
// RUN: %clangxx_asan %s %libdl -D__ASAN_DISABLE_CONTAINER_OVERFLOW__ -o %t
10+
// RUN: %clangxx_asan %s %libdl -D__ASAN_DISABLE_CONTAINER_OVERFLOW__ -o %t
1111
// RUN: %run %t 2>&1 | FileCheck --check-prefix=CHECK-NO-CONTAINER-OVERFLOW %s
1212

13-
#include <stdio.h>
1413
#include <assert.h>
1514
#include <sanitizer/common_interface_defs.h>
15+
#include <stdio.h>
1616

17-
template <typename T>
18-
class Stack {
17+
template <typename T> class Stack {
1918
private:
2019
T data[5];
2120
size_t size;
@@ -30,14 +29,16 @@ class Stack {
3029

3130
~Stack() {
3231
#if __has_feature(address_sanitizer) && !__ASAN_DISABLE_CONTAINER_OVERFLOW__
33-
__sanitizer_annotate_contiguous_container(data, data + 5, data + size, data + 5);
32+
__sanitizer_annotate_contiguous_container(data, data + 5, data + size,
33+
data + 5);
3434
#endif
3535
}
3636

37-
void push(const T& value) {
37+
void push(const T &value) {
3838
assert(size < 5 && "Stack overflow");
3939
#if __has_feature(address_sanitizer) && !__ASAN_DISABLE_CONTAINER_OVERFLOW__
40-
__sanitizer_annotate_contiguous_container(data, data + 5, data + size, data + size + 1);
40+
__sanitizer_annotate_contiguous_container(data, data + 5, data + size,
41+
data + size + 1);
4142
#endif
4243
data[size++] = value;
4344
}
@@ -46,7 +47,8 @@ class Stack {
4647
assert(size > 0 && "Cannot pop from empty stack");
4748
T result = data[--size];
4849
#if __has_feature(address_sanitizer) && !__ASAN_DISABLE_CONTAINER_OVERFLOW__
49-
__sanitizer_annotate_contiguous_container(data, data + 5, data + size + 1, data + size);
50+
__sanitizer_annotate_contiguous_container(data, data + 5, data + size + 1,
51+
data + size);
5052
#endif
5153
return result;
5254
}
@@ -55,15 +57,13 @@ class Stack {
5557
#ifdef SHARED_LIB
5658
// Mimics a closed-source library compiled without ASan
5759

58-
extern "C" void push_value_to_stack(Stack<int>& stack) {
59-
stack.push(42);
60-
}
61-
#else // SHARED_LIB
60+
extern "C" void push_value_to_stack(Stack<int> &stack) { stack.push(42); }
61+
#else // SHARED_LIB
6262

63-
#include <dlfcn.h>
64-
#include <string>
63+
# include <dlfcn.h>
64+
# include <string>
6565

66-
typedef void (*push_func_t)(Stack<int>&);
66+
typedef void (*push_func_t)(Stack<int> &);
6767

6868
int main(int argc, char *argv[]) {
6969
std::string path = std::string(argv[0]) + "-so.so";
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
7979
push_value(stack);
8080

8181
// BOOM! uninstrumented library didn't update container bounds
82-
int value = stack.pop();
82+
int value = stack.pop();
8383
// CHECK: AddressSanitizer: container-overflow
8484
printf("Popped value: %d\n", value);
8585
assert(value == 42 && "Expected value 42");
@@ -90,4 +90,4 @@ int main(int argc, char *argv[]) {
9090
return 0;
9191
}
9292

93-
#endif // SHARED_LIB
93+
#endif // SHARED_LIB

compiler-rt/test/asan/TestCases/stack_container_dynamic_lib_redef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// Mimic a closed-source library compiled without ASan
1313
// RUN: %clangxx_asan -fno-sanitize=address -DSHARED_LIB %s -dynamiclib -o %t-closedsource.dylib
1414

15-
// Mimic multiple files being linked into a single executable,
15+
// Mimic multiple files being linked into a single executable,
1616
// %t-object.o and %t-main compiled seperately and then linked together
1717
//
1818
// -fsanitize=address with container overflow turned on (default)
@@ -49,7 +49,7 @@
4949
# define __sanitizer_annotate_contiguous_container(...)
5050
# else
5151

52-
// in this test match the extern "C" declaration as <string.h> pulls in copies of the
52+
// in this test match the extern "C" declaration as <string.h> pulls in copies of the
5353
// declarations
5454
extern "C" {
5555
# if USE_STATIC

0 commit comments

Comments
 (0)