[llvm] r243148 - DI: Clarify isUnsignedDIType(), NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Jul 24 12:42:12 PDT 2015
Author: dexonsmith
Date: Fri Jul 24 14:42:12 2015
New Revision: 243148
URL: http://llvm.org/viewvc/llvm-project?rev=243148&view=rev
Log:
DI: Clarify isUnsignedDIType(), NFC
Refactor `isUnsignedDIType()` to deal with `DICompositeType` explicitly.
Since `DW_TAG_subroutine_type` isn't handled here (the assertions about
tags rule it out), this allows strengthening the `dyn_cast` to
`DIDerivedType`.
Besides making the code clearer, this it removes a use of
`DIDerivedTypeBase`.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=243148&r1=243147&r2=243148&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Jul 24 14:42:12 2015
@@ -513,34 +513,35 @@ void DwarfUnit::addBlockByrefAddress(con
/// Return true if type encoding is unsigned.
static bool isUnsignedDIType(DwarfDebug *DD, const DIType *Ty) {
- if (auto *DTy = dyn_cast<DIDerivedTypeBase>(Ty)) {
+ if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
+ // FIXME: Enums without a fixed underlying type have unknown signedness
+ // here, leading to incorrectly emitted constants.
+ if (CTy->getTag() == dwarf::DW_TAG_enumeration_type)
+ return false;
+
+ // (Pieces of) aggregate types that get hacked apart by SROA may be
+ // represented by a constant. Encode them as unsigned bytes.
+ return true;
+ }
+
+ if (auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
dwarf::Tag T = (dwarf::Tag)Ty->getTag();
// Encode pointer constants as unsigned bytes. This is used at least for
// null pointer constant emission.
- // (Pieces of) aggregate types that get hacked apart by SROA may also be
- // represented by a constant. Encode them as unsigned bytes.
// FIXME: reference and rvalue_reference /probably/ shouldn't be allowed
// here, but accept them for now due to a bug in SROA producing bogus
// dbg.values.
- if (T == dwarf::DW_TAG_array_type ||
- T == dwarf::DW_TAG_class_type ||
- T == dwarf::DW_TAG_pointer_type ||
+ if (T == dwarf::DW_TAG_pointer_type ||
T == dwarf::DW_TAG_ptr_to_member_type ||
T == dwarf::DW_TAG_reference_type ||
- T == dwarf::DW_TAG_rvalue_reference_type ||
- T == dwarf::DW_TAG_structure_type ||
- T == dwarf::DW_TAG_union_type)
+ T == dwarf::DW_TAG_rvalue_reference_type)
return true;
assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||
T == dwarf::DW_TAG_volatile_type ||
- T == dwarf::DW_TAG_restrict_type ||
- T == dwarf::DW_TAG_enumeration_type);
- if (DITypeRef Deriv = DTy->getBaseType())
- return isUnsignedDIType(DD, DD->resolve(Deriv));
- // FIXME: Enums without a fixed underlying type have unknown signedness
- // here, leading to incorrectly emitted constants.
- assert(DTy->getTag() == dwarf::DW_TAG_enumeration_type);
- return false;
+ T == dwarf::DW_TAG_restrict_type);
+ DITypeRef Deriv = DTy->getBaseType();
+ assert(Deriv && "Expected valid base type");
+ return isUnsignedDIType(DD, DD->resolve(Deriv));
}
auto *BTy = cast<DIBasicType>(Ty);
More information about the llvm-commits
mailing list