[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class. (PR #73467)
via lldb-commits
lldb-commits at lists.llvm.org
Sun Nov 26 16:27:07 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff a369a5946f99254d56455f3deb0031199562c1dd 70957429780c31c8981198967af254a4232ad3bc -- lldb/include/lldb/Symbol/CompilerType.h lldb/source/Symbol/CompilerType.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index e02dfeb08b..6239f190b7 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -223,8 +223,7 @@ public:
bool IsRecordType() const;
- bool IsVirtualBase(CompilerType target_base,
- CompilerType *virtual_base,
+ bool IsVirtualBase(CompilerType target_base, CompilerType *virtual_base,
bool carry_virtual = false) const;
bool IsContextuallyConvertibleToBool() const;
@@ -235,7 +234,7 @@ public:
bool CompareTypes(CompilerType rhs) const;
- const char * GetTypeTag();
+ const char *GetTypeTag();
uint32_t GetNumberOfNonEmptyBaseClasses();
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index f5c38a6f92..69f037bb59 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -323,7 +323,7 @@ bool CompilerType::IsSmartPtrType() const {
llvm::StringRef name = GetTypeName();
return k_libcxx_std_unique_ptr_regex.match(name) ||
k_libcxx_std_shared_ptr_regex.match(name) ||
- k_libcxx_std_weak_ptr_regex.match(name) ||
+ k_libcxx_std_weak_ptr_regex.match(name) ||
k_libcxx_std_unique_ptr_regex_2.match(name) ||
k_libcxx_std_shared_ptr_regex_2.match(name) ||
k_libcxx_std_weak_ptr_regex_2.match(name);
@@ -364,18 +364,16 @@ bool CompilerType::IsSigned() const {
bool CompilerType::IsNullPtrType() const {
return GetCanonicalType().GetBasicTypeEnumeration() ==
- lldb::eBasicTypeNullPtr;
+ lldb::eBasicTypeNullPtr;
}
bool CompilerType::IsBoolean() const {
- return GetCanonicalType().GetBasicTypeEnumeration() ==
- lldb::eBasicTypeBool;
+ return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool;
}
bool CompilerType::IsEnumerationIntegerTypeSigned() const {
if (IsValid()) {
- return GetEnumerationIntegerType().GetTypeInfo()
- & lldb::eTypeIsSigned;
+ return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned;
}
return false;
}
@@ -392,21 +390,21 @@ bool CompilerType::IsPromotableIntegerType() const {
}
switch (GetCanonicalType().GetBasicTypeEnumeration()) {
- case lldb::eBasicTypeBool:
- case lldb::eBasicTypeChar:
- case lldb::eBasicTypeSignedChar:
- case lldb::eBasicTypeUnsignedChar:
- case lldb::eBasicTypeShort:
- case lldb::eBasicTypeUnsignedShort:
- case lldb::eBasicTypeWChar:
- case lldb::eBasicTypeSignedWChar:
- case lldb::eBasicTypeUnsignedWChar:
- case lldb::eBasicTypeChar16:
- case lldb::eBasicTypeChar32:
- return true;
+ case lldb::eBasicTypeBool:
+ case lldb::eBasicTypeChar:
+ case lldb::eBasicTypeSignedChar:
+ case lldb::eBasicTypeUnsignedChar:
+ case lldb::eBasicTypeShort:
+ case lldb::eBasicTypeUnsignedShort:
+ case lldb::eBasicTypeWChar:
+ case lldb::eBasicTypeSignedWChar:
+ case lldb::eBasicTypeUnsignedWChar:
+ case lldb::eBasicTypeChar16:
+ case lldb::eBasicTypeChar32:
+ return true;
- default:
- return false;
+ default:
+ return false;
}
}
@@ -415,7 +413,7 @@ bool CompilerType::IsPointerToVoid() const {
return false;
return IsPointerType() &&
- GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid;
+ GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid;
}
bool CompilerType::IsRecordType() const {
@@ -423,7 +421,8 @@ bool CompilerType::IsRecordType() const {
return false;
return GetCanonicalType().GetTypeClass() &
- (lldb::eTypeClassClass | lldb::eTypeClassStruct | lldb::eTypeClassUnion);
+ (lldb::eTypeClassClass | lldb::eTypeClassStruct |
+ lldb::eTypeClassUnion);
}
// Checks whether `target_base` is a virtual base of `type` (direct or
@@ -465,19 +464,19 @@ bool CompilerType::IsVirtualBase(CompilerType target_base,
bool CompilerType::IsContextuallyConvertibleToBool() const {
return IsScalarType() || IsUnscopedEnumerationType() || IsPointerType() ||
- IsNullPtrType() || IsArrayType();
+ IsNullPtrType() || IsArrayType();
}
bool CompilerType::IsBasicType() const {
- return GetCanonicalType().GetBasicTypeEnumeration()
- != lldb::eBasicTypeInvalid;
+ return GetCanonicalType().GetBasicTypeEnumeration() !=
+ lldb::eBasicTypeInvalid;
}
std::string CompilerType::TypeDescription() {
auto name = GetTypeName();
auto canonical_name = GetCanonicalType().GetTypeName();
if (name.IsEmpty() || canonical_name.IsEmpty()) {
- return "''"; // should not happen
+ return "''"; // should not happen
}
if (name == canonical_name) {
return llvm::formatv("'{0}'", name);
@@ -494,16 +493,16 @@ bool CompilerType::CompareTypes(CompilerType rhs) const {
return name == rhs_name;
}
-const char * CompilerType::GetTypeTag() {
+const char *CompilerType::GetTypeTag() {
switch (GetTypeClass()) {
- // clang-format off
+ // clang-format off
case lldb::eTypeClassClass: return "class";
case lldb::eTypeClassEnumeration: return "enum";
case lldb::eTypeClassStruct: return "struct";
case lldb::eTypeClassUnion: return "union";
- // clang-format on
- default:
- return "unknown";
+ // clang-format on
+ default:
+ return "unknown";
}
}
@@ -523,23 +522,22 @@ uint32_t CompilerType::GetNumberOfNonEmptyBaseClasses() {
return ret;
}
-CompilerType CompilerType::GetTemplateArgumentType(uint32_t idx)
-{
+CompilerType CompilerType::GetTemplateArgumentType(uint32_t idx) {
CompilerType empty_type;
if (!IsValid())
return empty_type;
CompilerType type;
const bool expand_pack = true;
- switch(GetTemplateArgumentKind(idx, true)) {
- case lldb::eTemplateArgumentKindType:
- type = GetTypeTemplateArgument(idx, expand_pack);
- break;
- case lldb::eTemplateArgumentKindIntegral:
- type = GetIntegralTemplateArgument(idx, expand_pack)->type;
- break;
- default:
- break;
+ switch (GetTemplateArgumentKind(idx, true)) {
+ case lldb::eTemplateArgumentKindType:
+ type = GetTypeTemplateArgument(idx, expand_pack);
+ break;
+ case lldb::eTemplateArgumentKindIntegral:
+ type = GetIntegralTemplateArgument(idx, expand_pack)->type;
+ break;
+ default:
+ break;
}
if (type.IsValid())
return type;
``````````
</details>
https://github.com/llvm/llvm-project/pull/73467
More information about the lldb-commits
mailing list