[PATCH] D130331: [C++20] [Modules] Disable preferred_name when writing a C++20 Module interface

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 21 22:34:32 PDT 2022


ChuanqiXu added inline comments.


================
Comment at: clang/lib/Serialization/ASTWriter.cpp:4353
+  // https://github.com/llvm/llvm-project/issues/56490 for example.
+  if (!A || (isa<PreferredNameAttr>(A) && Writer->isWritingNamedModules()))
     return Record.push_back(0);
----------------
The `Writer->isWritingNamedModules()` part is necessary. Otherwise we would break the https://github.com/llvm/llvm-project/blob/main/clang/test/PCH/decl-attrs.cpp test. The reason why the bug is not found by the user of PCH or clang modules is that a header generally would be guarded by `#ifndef ... #define` fashion. And if we remove the guard, the compiler would emit an error for duplicated definition. So the problem only lives in C++20 Named Modules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130331



More information about the cfe-commits mailing list