[Lldb-commits] [PATCH] D112708: [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant arrays
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 28 05:06:16 PDT 2021
labath created this revision.
labath added reviewers: teemperor, shafik.
labath requested review of this revision.
Herald added a project: LLDB.
Unqualify (constant) arrays recursively, just like we do for pointers.
This allows for better pretty printer matching.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112708
Files:
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/unittests/Symbol/TestTypeSystemClang.cpp
Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===================================================================
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -912,6 +912,22 @@
EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo");
}
+TEST_F(TestTypeSystemClang, GetFullyUnqualifiedType) {
+ CompilerType bool_ = m_ast->GetBasicType(eBasicTypeBool);
+ CompilerType cv_bool = bool_.AddConstModifier().AddVolatileModifier();
+ EXPECT_EQ(bool_, cv_bool.GetFullyUnqualifiedType());
+ EXPECT_EQ(bool_.GetArrayType(47),
+ cv_bool.GetArrayType(47).GetFullyUnqualifiedType());
+ EXPECT_EQ(
+ bool_.GetArrayType(42).GetArrayType(47),
+ cv_bool.GetArrayType(42).GetArrayType(47).GetFullyUnqualifiedType());
+ EXPECT_EQ(bool_.GetPointerType(),
+ cv_bool.GetPointerType().GetFullyUnqualifiedType());
+ EXPECT_EQ(
+ bool_.GetPointerType().GetArrayType(47),
+ cv_bool.GetPointerType().GetArrayType(47).GetFullyUnqualifiedType());
+}
+
TEST(TestScratchTypeSystemClang, InferSubASTFromLangOpts) {
LangOptions lang_opts;
EXPECT_EQ(
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===================================================================
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4238,7 +4238,14 @@
if (qual_type->isPointerType())
qual_type = ast->getPointerType(
GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
- else
+ else if (const ConstantArrayType *arr =
+ ast->getAsConstantArrayType(qual_type)) {
+ arr->getElementType();
+ qual_type = ast->getConstantArrayType(
+ GetFullyUnqualifiedType_Impl(ast, arr->getElementType()),
+ arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
+ arr->getIndexTypeQualifiers().getAsOpaqueValue());
+ } else
qual_type = qual_type.getUnqualifiedType();
qual_type.removeLocalConst();
qual_type.removeLocalRestrict();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112708.382993.patch
Type: text/x-patch
Size: 2089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211028/1b96f8e9/attachment.bin>
More information about the lldb-commits
mailing list