[PATCH] D88665: [ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 1 08:49:18 PDT 2020
martong created this revision.
martong added reviewers: balazske, teemperor, shafik, a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.
martong requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88665
Files:
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp
Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===================================================================
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -976,6 +976,12 @@
EXPECT_FALSE(testStructuralMatch(t));
}
+TEST_F(StructuralEquivalenceTemplateTest, DependentFieldDecl) {
+ const char *Code = "template <class T> class foo { int a : sizeof(T); };";
+ auto t = makeNamedDecls(Code, Code, Lang_CXX03);
+ EXPECT_TRUE(testStructuralMatch(t));
+}
+
TEST_F(StructuralEquivalenceTemplateTest, ExplicitBoolSame) {
auto Decls = makeNamedDecls(
"template <bool b> struct foo {explicit(b) foo(int);};",
Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===================================================================
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1280,6 +1280,10 @@
}
if (Field1->isBitField()) {
+ bool isVD1 = Field1->getBitWidth()->isValueDependent();
+ bool isVD2 = Field2->getBitWidth()->isValueDependent();
+ if (isVD1 || isVD2)
+ return isVD1 && isVD2;
// Make sure that the bit-fields are the same length.
unsigned Bits1 = Field1->getBitWidthValue(Context.FromCtx);
unsigned Bits2 = Field2->getBitWidthValue(Context.ToCtx);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88665.295585.patch
Type: text/x-patch
Size: 1336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201001/51b8316c/attachment.bin>
More information about the cfe-commits
mailing list