module AdLint::Cc1::MemoryPoolMediator

Public Instance Methods

pointee_of(ptr) click to toggle source
# File lib/adlint/cc1/mediator.rb, line 70
def pointee_of(ptr)
  # FIXME: This method should return multiple objects, because domain of
  #        the pointer_value may have multiple address values.
  #
  # ptr.value.to_enum.map { |addr|
  #   mem = memory_at(addr) ? mem.binding.object : nil
  # }.compact

  if ptr.value.definite?
    if addr = ptr.value.to_enum.first and mem = memory_at(addr)
      obj = mem.binding.object
      if obj.variable? or
          obj.function? && ptr.type.unqualify.base_type.function?
        return obj
      end
    end
  end
  nil
end