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

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 20:55:05 PDT 2022


vsapsai added a comment.

Sorry, I'm pretty ignorant in this area but based on

> 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).

I want to clarify. The goal is to allow mixing PCH and PCM files, right? I haven't double checked and maybe that have changed already but I think `-x c++-header` started building .pcm instead of .pch with `-std=c++20`. That's where my confusion about mixing PCH and PCM comes from.



================
Comment at: clang/include/clang/Driver/Types.def:66
 TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    "hh",     phases::Preprocess, phases::Precompile)
-TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii",  phases::Precompile)
+TYPE("c++-header-unit-cpp-output", PP_CXXHeaderUnit,INVALID,    "iih",    phases::Precompile)
+TYPE("c++-header-unit-header",   CXXHUHeader,  PP_CXXHeaderUnit,"hh",     phases::Preprocess, phases::Precompile)
----------------
Sorry, it's not really related to your change but do you have a rule where "ii" should go? It's just we have both "mii" and "iim" and I want to make sure it should be "iih" and not "hii". I haven't tried to find a pattern here myself, asking you first.


================
Comment at: clang/lib/Frontend/FrontendOptions.cpp:30-31
       .Case("cppm", Language::CXX)
+      .Case("iih", InputKind(Language::CXX).getPreprocessed())
       .Case("iim", InputKind(Language::CXX).getPreprocessed())
       .Case("cl", Language::OpenCL)
----------------
Given the other branches in this StringSwitch I would expect `.Cases("iih", "iim", InputKind(Language::CXX).getPreprocessed())`. Is there a reason not to do that (like differences between iih and iim) or is it accidental?


================
Comment at: clang/test/Driver/cxx20-header-units-01.cpp:7
+
+// RUN: %clang++ -### -std=c++20 -xc++-header-unit-header %S/Inputs/header-unit-01.hh 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ABS %s -DTDIR=%S/Inputs
----------------
What should happen in case of inconsistencies like `%clang++ -### -std=c++20 -xc++-system-header %S/Inputs/header-unit-01.hh`? Or `-xc++-system-header foo.h`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121588/new/

https://reviews.llvm.org/D121588



More information about the cfe-commits mailing list