[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
Fri Oct 29 02:14:24 PDT 2021


This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rG3abd063fc793: [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant arrays (authored by labath).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112708/new/

https://reviews.llvm.org/D112708

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
  lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.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,32 @@
   EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo");
 }
 
+TEST_F(TestTypeSystemClang, GetFullyUnqualifiedType) {
+  CompilerType bool_ = m_ast->GetBasicType(eBasicTypeBool);
+  CompilerType cv_bool = bool_.AddConstModifier().AddVolatileModifier();
+
+  // const volatile bool -> bool
+  EXPECT_EQ(bool_, cv_bool.GetFullyUnqualifiedType());
+
+  // const volatile bool[47] -> bool[47]
+  EXPECT_EQ(bool_.GetArrayType(47),
+            cv_bool.GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool[47][42] -> bool[47][42]
+  EXPECT_EQ(
+      bool_.GetArrayType(42).GetArrayType(47),
+      cv_bool.GetArrayType(42).GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool * -> bool *
+  EXPECT_EQ(bool_.GetPointerType(),
+            cv_bool.GetPointerType().GetFullyUnqualifiedType());
+
+  // const volatile bool *[47] -> bool *[47]
+  EXPECT_EQ(
+      bool_.GetPointerType().GetArrayType(47),
+      cv_bool.GetPointerType().GetArrayType(47).GetFullyUnqualifiedType());
+}
+
 TEST(TestScratchTypeSystemClang, InferSubASTFromLangOpts) {
   LangOptions lang_opts;
   EXPECT_EQ(
Index: lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
===================================================================
--- lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -144,7 +144,8 @@
     cool_array[2].character = 'Q';
     
     int int_array[] = {1,2,3,4,5};
-    
+    const int const_int_array[] = {11, 12, 13, 14, 15};
+
     IWrapPointers wrapper;
         
     *int_array = -1;
Index: lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
===================================================================
--- lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -65,10 +65,12 @@
         self.runCmd("type summary clear")
 
         self.runCmd(
-            "type summary add --summary-string \"${var[]}\" -x \"int\\[[0-9]\\]")
+            "type summary add --summary-string \"${var[]}\" -x \"^int\\[[0-9]\\]")
 
         self.expect("frame variable int_array",
                     substrs=['1,2,3,4,5'])
+        self.expect("frame variable const_int_array",
+                    substrs=['11,12,13,14,15'])
 
         # this will fail if we don't do [] as regex correctly
         self.runCmd(
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,13 @@
   if (qual_type->isPointerType())
     qual_type = ast->getPointerType(
         GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
-  else
+  else if (const ConstantArrayType *arr =
+               ast->getAsConstantArrayType(qual_type)) {
+    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.383265.patch
Type: text/x-patch
Size: 3723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211029/3ae43832/attachment.bin>


More information about the lldb-commits mailing list