[PATCH] D75406: Avoid including FileManager.h from SourceManager.h

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 29 09:31:38 PST 2020


rnk created this revision.
rnk added reviewers: arphaman, hans.
Herald added subscribers: martong, usaxena95, jsji, kadircet, dexonsmith, jkorous, kbarton, nemanjai.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75406

Files:
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
  clang-tools-extra/clangd/Format.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/Basic/SanitizerBlacklist.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Basic/XRayLists.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Index/CommentToXML.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Lex/PPCallbacks.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75406.247448.patch
Type: text/x-patch
Size: 23534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200229/f74dd434/attachment-0001.bin>


More information about the cfe-commits mailing list