There are a few expressions containing impersonal 'it' which are used as reporting clauses before 'that'-clauses to indicate that someone suddenly thought of something: 'It occurred to me', 'It struck me', and 'It crossed my mind'.
It occurred to himthat he hadn't eaten anything since the night before his capture.
It crossed my mindthat somebody must have been keeping things secret.