[all-commits] [llvm/llvm-project] 444513: [clang][lex] Remark on search path usage

Jan Svoboda via All-commits all-commits at lists.llvm.org
Tue Oct 12 03:21:10 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 444513510999e4c1ea23253654196793834d53bf
      https://github.com/llvm/llvm-project/commit/444513510999e4c1ea23253654196793834d53bf
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-10-12 (Tue, 12 Oct 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticLexKinds.td
    M clang/include/clang/Lex/HeaderMap.h
    M clang/include/clang/Lex/HeaderSearch.h
    M clang/lib/Frontend/InitHeaderSearch.cpp
    M clang/lib/Lex/HeaderMap.cpp
    M clang/lib/Lex/HeaderSearch.cpp
    A clang/test/Preprocessor/Inputs/search-path-usage/FwA/FrameworkA.framework/Headers/FrameworkA.h
    A clang/test/Preprocessor/Inputs/search-path-usage/FwA/FrameworkA.framework/Modules/module.modulemap
    A clang/test/Preprocessor/Inputs/search-path-usage/FwB/FrameworkB.framework/Headers/FrameworkB.h
    A clang/test/Preprocessor/Inputs/search-path-usage/FwB/FrameworkB.framework/Modules/module.modulemap
    A clang/test/Preprocessor/Inputs/search-path-usage/a/a.h
    A clang/test/Preprocessor/Inputs/search-path-usage/a_next/a.h
    A clang/test/Preprocessor/Inputs/search-path-usage/b.hmap.json.template
    A clang/test/Preprocessor/Inputs/search-path-usage/b/b.h
    A clang/test/Preprocessor/Inputs/search-path-usage/d/d.h
    A clang/test/Preprocessor/Inputs/search-path-usage/modulemap_abs/module.modulemap.template
    A clang/test/Preprocessor/search-path-usage.m

  Log Message:
  -----------
  [clang][lex] Remark on search path usage

For dependency scanning, it would be useful to collect header search paths (provided on command-line via `-I` and friends) that were actually used during preprocessing. This patch adds that feature to `HeaderSearch` along with a new remark that reports such paths as they get used.

Previous version of this patch tried to use the existing `LookupFileCache` to report used paths via `HitIdx`. That doesn't work for `ComputeUserEntryUsage` (which is intended to be called *after* preprocessing), because it indexes used search paths by the file name. This means the values get overwritten when the code contains `#include_next`.

Note that `HeaderSearch` doesn't use `HeaderSearchOptions::UserEntries` directly. Instead, `InitHeaderSearch` pre-processes them (adds platform-specific paths, removes duplicates, removes paths that don't exist) and creates `DirectoryLookup` instances. This means we need a mechanism for translating between those two. It's not possible to go from `DirectoryLookup` back to the original `HeaderSearch`, so `InitHeaderSearch` now tracks the relationships explicitly.

Depends on D111557.

Reviewed By: dexonsmith

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




More information about the All-commits mailing list