Author: Chuanqi Xu Date: 2024-01-15T17:00:49+08:00 New Revision: 7bc170a261ae0daaddcc1abeacf7e9e0f1f66d02
URL: https://github.com/llvm/llvm-project/commit/7bc170a261ae0daaddcc1abeacf7e9e0f1f66d02 DIFF: https://github.com/llvm/llvm-project/commit/7bc170a261ae0daaddcc1abeacf7e9e0f1f66d02.diff LOG: [C++20] [Modules] [Serialization] Don't record '#pragma once' information in named modules Close https://github.com/llvm/llvm-project/issues/77995 The cause of the issue is that straight forward that we recorded the '#pragma once' information in named modules, which is an overlook. I tried to not record the header's information completely within named modules. But the tests look not happy with some diagnosing problems, which needs to be looked in details. Added: clang/test/Modules/pr77995.cppm Modified: clang/lib/Serialization/ASTWriter.cpp Removed: ################################################################################ diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 9950fa9c08faaa..a3fa99c3d7e49f 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1897,7 +1897,8 @@ namespace { unsigned char Flags = (Data.AlreadyIncluded << 6) | (Data.HFI.isImport << 5) - | (Data.HFI.isPragmaOnce << 4) + | (Writer.isWritingStdCXXNamedModules() ? 0 : + Data.HFI.isPragmaOnce << 4) | (Data.HFI.DirInfo << 1) | Data.HFI.IndexHeaderMapHeader; LE.write<uint8_t>(Flags); diff --git a/clang/test/Modules/pr77995.cppm b/clang/test/Modules/pr77995.cppm new file mode 100644 index 00000000000000..26442dacac4fb6 --- /dev/null +++ b/clang/test/Modules/pr77995.cppm @@ -0,0 +1,25 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 %t/foo.cppm -emit-module-interface -o %t/foo.pcm +// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=foo=%t/foo.pcm -verify -fsyntax-only + +//--- a.hpp +#pragma once +#define A 43 + +//--- foo.cppm +module; +#include "a.hpp" +export module foo; +export constexpr auto B = A; + +//--- use.cpp +// expected-no-diagnostics +import foo; +#include "a.hpp" + +static_assert(A == 43); +static_assert(B == 43); + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits