[clang] [clang][bytecode] Use first FieldDecl instead of asserting (PR #104760)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 19 04:00:33 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
This assertion fails sometimes. We use the first decl for lookup later, so let's use the first decl here as well.
---
Full diff: https://github.com/llvm/llvm-project/pull/104760.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Program.cpp (+1-1)
- (modified) clang/test/Modules/merge-using-decls.cpp (+2-1)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 25b99115ddd777..a4f0df8bf6462e 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -329,7 +329,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
// Reserve space for fields.
Record::FieldList Fields;
for (const FieldDecl *FD : RD->fields()) {
- assert(FD == FD->getFirstDecl());
+ FD = FD->getFirstDecl();
// Note that we DO create fields and descriptors
// for unnamed bitfields here, even though we later ignore
// them everywhere. That's so the FieldDecl's getFieldIndex() matches.
diff --git a/clang/test/Modules/merge-using-decls.cpp b/clang/test/Modules/merge-using-decls.cpp
index e3bf977f054499..e9794a40837ef9 100644
--- a/clang/test/Modules/merge-using-decls.cpp
+++ b/clang/test/Modules/merge-using-decls.cpp
@@ -6,7 +6,8 @@
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=2
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=2
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++17 %s -DORDER=2
+
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++17 %s -DORDER=2
#if ORDER == 1
#include "a.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/104760
More information about the cfe-commits
mailing list