[all-commits] [llvm/llvm-project] e08464: Avoid including FileManager.h from SourceManager.h

Reid Kleckner via All-commits all-commits at lists.llvm.org
Wed Mar 11 13:58:08 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e08464fb450456881733c885267b32dc7339cf11
      https://github.com/llvm/llvm-project/commit/e08464fb450456881733c885267b32dc7339cf11
  Author: Reid Kleckner <rnk at google.com>
  Date:   2020-03-11 (Wed, 11 Mar 2020)

  Changed paths:
    M clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
    M clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
    M clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
    M clang-tools-extra/clangd/Format.cpp
    M clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
    M clang/include/clang/ASTMatchers/ASTMatchers.h
    M clang/include/clang/Basic/SourceManager.h
    M clang/include/clang/Frontend/CompilerInstance.h
    M clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
    M clang/include/clang/Lex/DirectoryLookup.h
    M clang/include/clang/Lex/ModuleMap.h
    M clang/include/clang/Lex/PPCallbacks.h
    M clang/lib/AST/ExternalASTSource.cpp
    M clang/lib/AST/MicrosoftMangle.cpp
    M clang/lib/Basic/SanitizerBlacklist.cpp
    M clang/lib/Basic/SourceManager.cpp
    M clang/lib/Basic/XRayLists.cpp
    M clang/lib/CodeGen/CGOpenMPRuntime.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/CodeGen/CoverageMappingGen.cpp
    M clang/lib/Frontend/CompilerInstance.cpp
    M clang/lib/Frontend/PrecompiledPreamble.cpp
    M clang/lib/Index/CommentToXML.cpp
    M clang/lib/Index/USRGeneration.cpp
    M clang/lib/Lex/ModuleMap.cpp
    M clang/lib/Lex/PPCallbacks.cpp
    M clang/lib/Lex/PPLexerChange.cpp
    M clang/lib/Parse/Parser.cpp
    M clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
    M clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
    M clang/tools/clang-import-test/clang-import-test.cpp
    M clang/tools/clang-refactor/TestSupport.cpp
    M clang/tools/libclang/CXSourceLocation.cpp
    M clang/unittests/Frontend/ASTUnitTest.cpp
    M clang/unittests/Frontend/CompilerInstanceTest.cpp
    M lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
    M lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp

  Log Message:
  -----------
  Avoid including FileManager.h from SourceManager.h

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:
    309 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileManager.h
    272 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileSystemOptions.h
    271 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/VirtualFileSystem.h
    267 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/FileSystem.h
    266 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Chrono.h

Differential Revision: https://reviews.llvm.org/D75406




More information about the All-commits mailing list