This is an archive of the discontinued LLVM Phabricator instance.

Avoid including FileManager.h from SourceManager.h
ClosedPublic

Authored by rnk on Feb 29 2020, 9:25 AM.

Details

Summary

Most clients of SourceManager.h need to do things like turning source
locations into file & line number pairs, but this doesn't require
bringing in FileManager.h and LLVM's FS headers.

The main code change here is to sink SM::createFileID into the cpp file.
I reason that this is not performance critical because it doesn't happen
on the diagnostic path, it happens along the paths of macro expansion
(could be hot) and new includes (less hot).

Saves some includes:
$ diff -u thedeps-before.txt thedeps-after.txt | grep '^[-+] ' | sort | uniq -c | sort -nr

313 -    ../clang/include/clang/Basic/FileManager.h
300 -    ../clang/include/clang/Basic/FileSystemOptions.h
289 -    ../llvm/include/llvm/Support/VirtualFileSystem.h
280 -    ../llvm/include/llvm/Support/Path.h
274 -    ../llvm/include/llvm/Support/SourceMgr.h
273 -    ../llvm/include/llvm/Support/SMLoc.h
 12 -    ../llvm/include/llvm/ADT/PointerUnion.h

Diff Detail

Event Timeline

rnk created this revision.Feb 29 2020, 9:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 29 2020, 9:25 AM
rnk updated this revision to Diff 247479.Feb 29 2020, 8:14 PM
  • fixes on Linux
Herald added a project: Restricted Project. · View Herald TranscriptFeb 29 2020, 8:14 PM
hans accepted this revision.Mar 11 2020, 2:33 AM

lgtm

This revision is now accepted and ready to land.Mar 11 2020, 2:33 AM
This revision was automatically updated to reflect the committed changes.