[compiler-rt] 16d3c0c - [test][asan] Limit scope of the var

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 16:45:54 PST 2022


Author: Vitaly Buka
Date: 2022-11-21T16:38:52-08:00
New Revision: 16d3c0c7a427a76a3886f4e93f796d81d536c27f

URL: https://github.com/llvm/llvm-project/commit/16d3c0c7a427a76a3886f4e93f796d81d536c27f
DIFF: https://github.com/llvm/llvm-project/commit/16d3c0c7a427a76a3886f4e93f796d81d536c27f.diff

LOG: [test][asan] Limit scope of the var

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/contiguous_container.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/contiguous_container.cpp b/compiler-rt/test/asan/TestCases/contiguous_container.cpp
index 5cc09ccf055d..2bd31f4a31f5 100644
--- a/compiler-rt/test/asan/TestCases/contiguous_container.cpp
+++ b/compiler-rt/test/asan/TestCases/contiguous_container.cpp
@@ -24,12 +24,11 @@ void TestContainer(size_t capacity, size_t off_begin, bool poison_buffer) {
   char *st_beg = buffer + off_begin;
   char *st_end = st_beg + capacity;
   char *end = poison_buffer ? st_beg : st_end;
-  char *old_end;
 
   for (int i = 0; i < 1000; i++) {
     size_t size = rand() % (capacity + 1);
     assert(size <= capacity);
-    old_end = end;
+    char *old_end = end;
     end = st_beg + size;
     __sanitizer_annotate_contiguous_container(st_beg, st_end, old_end, end);
 
@@ -51,7 +50,7 @@ void TestContainer(size_t capacity, size_t off_begin, bool poison_buffer) {
   }
 
   for (int i = 0; i <= capacity; i++) {
-    old_end = end;
+    char *old_end = end;
     end = st_beg + i;
     __sanitizer_annotate_contiguous_container(st_beg, st_end, old_end, end);
 


        


More information about the llvm-commits mailing list