This is an archive of the discontinued LLVM Phabricator instance.

SourceManager: Clarify that FileInfo always has a ContentCache, NFC
ClosedPublic

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

Details

Summary

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
clang/lib/Basic/SourceManager.cpp
1684

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
clang/lib/Basic/SourceManager.cpp
1684

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
clang/lib/Basic/SourceManager.cpp
1684
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

LGTM

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