[PATCH] D121588: [C++20][Modules][Driver][HU 1/N] Initial handling for -xc++-{system,user}-header.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 14 04:34:19 PDT 2022


iains created this revision.
Herald added a project: All.
iains added reviewers: rsmith, urnathan, ChuanqiXu.
iains added a subscriber: clang-modules.
iains published this revision for review.
iains added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a set of 4 patches that adds the driver-side support for C++20 header modules.

We use the same user-facing options as the existing implementation in GCC (there seems no engineering reason to deviate from this and it makes things easier for users and build system alike).

1/4 - this patch introduces file types for header unit headers to be searched for in the user or system paths (or to be given an absolute pathname).
2/4 - adds the -fmoduke-header{.=} command line options
3/4 - is a user-convenience change that allows "foo.h" without complaining about C code used in C++ compilations (since we know that the user has already specified the intent).
4/4 - adds the -fdirectives-only command that produces pre-processor output which retains the macro definitions/undefs that will be present in the built header unit.


This adds file types and handling for three input types, representing a C++20
header unit source:

1. When provided with a complete pathname for the header.
2. For a header to be looked up (by the frontend) in the user search paths
3. For a header to be looked up in the system search paths.

We also add a pre-processed file type (although that is a single type, regardless
of the original input type).

These types may be specified with -xc++-{user,system,header-unit}-header xxxx.

These types allow us to disambiguate header unit jobs from PCH ones, and thus
we handle these differently from other header jobs in two ways:

1. The job construction is altered to build a C++20 header unit (rather than a PCH file, as would be the case for other headers).
2. When the type is "user" or "system" we defer checking for the file until the front end is run, since we need to look up the header in the relevant paths which are not known at this point.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121588

Files:
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/FrontendOptions.cpp
  clang/test/Driver/Inputs/header-unit-01.hh
  clang/test/Driver/cxx20-header-units-01.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121588.415054.patch
Type: text/x-patch
Size: 6988 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220314/6a8cc998/attachment-0001.bin>


More information about the cfe-commits mailing list