Page MenuHomePhabricator

SourceManager: Clarify that FileInfo always has a ContentCache, NFC

Authored by dexonsmith on Oct 16 2020, 7:45 AM.



It turns out that FileInfo *always* has a ContentCache. Clarify that
in the code:

  • Update the private version of SourceManager::createFileID to take a ContentCache& instead of ContentCache*, and rename it to createFileIDImpl for clarity.
  • Change FileInfo::getContentCache to return a reference.

Diff Detail

Event Timeline

dexonsmith created this revision.Oct 16 2020, 7:45 AM
martong removed a subscriber: martong.Oct 20 2020, 6:53 AM
shafik added inline comments.Oct 21 2020, 9:26 AM

Is the const_cast just for this line? Maybe we can localize the cast to this line then?

dexonsmith added inline comments.Oct 21 2020, 2:01 PM

Good idea, or we could sink it into ComputeLineNumbers, or we could make NumLines and SourceLineCache mutable.

In any case I don't want to make this patch more noisy (it's unrelated to this change, the const_cast was already here), but I'll write a follow up patch to clean this up.

dexonsmith added inline comments.Oct 21 2020, 7:47 PM
JDevlieghere accepted this revision.Oct 22 2020, 10:37 PM

LGTM if Shafik is happy

This revision is now accepted and ready to land.Oct 22 2020, 10:37 PM
shafik accepted this revision.Oct 22 2020, 10:44 PM


Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2020, 9:39 AM