Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / tag-ptr.cpp
blob87a07e311b17ed4ff2df6ef7757914ee4d411aae
1 // RUN: %clangxx_hwasan -O0 %s -o %t && %run %t
3 #include <assert.h>
4 #include <memory>
5 #include <sanitizer/hwasan_interface.h>
6 #include <set>
7 #include <stdio.h>
9 int main() {
10 auto p = std::make_unique<char>();
11 std::set<void *> ptrs;
12 for (unsigned i = 0;; ++i) {
13 void *ptr = __hwasan_tag_pointer(p.get(), i);
14 if (!ptrs.insert(ptr).second)
15 break;
16 fprintf(stderr, "%p, %u, %u\n", ptr, i, __hwasan_get_tag_from_pointer(ptr));
17 assert(__hwasan_get_tag_from_pointer(ptr) == i);
19 #ifdef __x86_64__
20 assert(ptrs.size() == 8 || ptrs.size() == 64);
21 #else
22 assert(ptrs.size() == 256);
23 #endif