qqiangwu / cppsafe

Cpp lifetime safety profile static analyzer
MIT License
45 stars 1 forks source link

Owers with derefType Pointers should be classified as Pointers? #14

Open qqiangwu opened 7 months ago

qqiangwu commented 7 months ago
qqiangwu commented 7 months ago
ColumnFamilyData* DBImpl::PickCompactionFromQueue(
    std::unique_ptr<TaskLimiterToken>* token, LogBuffer* log_buffer) {
  assert(!compaction_queue_.empty());
  assert(*token == nullptr);
  autovector<ColumnFamilyData*> throttled_candidates;
  ColumnFamilyData* cfd = nullptr;
  while (!compaction_queue_.empty()) {
    // pset(compaction_queue_) = {*this}
    // pset(compaction_queue_.begin()) = {*this}
    // pset(*compaction_queue_.begin()) = {**this}
    auto first_cfd = *compaction_queue_.begin();
    compaction_queue_.pop_front();
    assert(first_cfd->queued_for_compaction());

    // RequestCompactionToken is a non-const member function so `first_cfd` is invalidated
    if (!RequestCompactionToken(first_cfd, false, token, log_buffer)) {
      // pset(first_cfd) = {invalid}
      throttled_candidates.push_back(first_cfd);
      continue;
    }
    cfd = first_cfd;
    cfd->set_queued_for_compaction(false);
    break;
  }
  // Add throttled compaction candidates back to queue in the original order.
  for (auto iter = throttled_candidates.rbegin();
       iter != throttled_candidates.rend(); ++iter) {
    compaction_queue_.push_front(*iter);
  }
  return cfd;
}