[PATCH] D111971: [clang] Allocate 2 bits to store the constexpr specifier kind when serializing
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 17 20:30:32 PDT 2021
nridge created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
nridge requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.
Now that consteval and constinit are possible values, 1 bit
is no longer enough.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111971
Files:
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2260,7 +2260,7 @@
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Constexpr
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -672,6 +672,24 @@
ElementsAre(AllOf(Diag(Test.range(), "'main' must return 'int'"),
Not(WithFix(_)))));
}
+TEST(DiagnosticsTest, Consteval) {
+ Annotations Header(R"cpp(
+ struct Container {
+ consteval Container() {
+ Push();
+ }
+ consteval void Push() {}
+ };
+ )cpp");
+ Annotations Main(R"cpp(
+ #include "a.h"
+ constexpr Container c = Container();
+ )cpp");
+ TestTU TU = TestTU::withCode(Main.code());
+ TU.ExtraArgs.push_back("-std=c++20");
+ TU.AdditionalFiles = {{"a.h", std::string(Header.code())}};
+ EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
TEST(ClangdTest, MSAsm) {
// Parsing MS assembly tries to use the target MCAsmInfo, which we don't link.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111971.380274.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211018/0595bcdb/attachment.bin>
More information about the cfe-commits
mailing list