tsan_ignoreset.cpp 981 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //===-- tsan_ignoreset.cpp ------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is a part of ThreadSanitizer (TSan), a race detector.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "tsan_ignoreset.h"
  13. namespace __tsan {
  14. const uptr IgnoreSet::kMaxSize;
  15. IgnoreSet::IgnoreSet()
  16. : size_() {
  17. }
  18. void IgnoreSet::Add(StackID stack_id) {
  19. if (size_ == kMaxSize)
  20. return;
  21. for (uptr i = 0; i < size_; i++) {
  22. if (stacks_[i] == stack_id)
  23. return;
  24. }
  25. stacks_[size_++] = stack_id;
  26. }
  27. StackID IgnoreSet::At(uptr i) const {
  28. CHECK_LT(i, size_);
  29. CHECK_LE(size_, kMaxSize);
  30. return stacks_[i];
  31. }
  32. } // namespace __tsan