[llvm] ae08734 - DWARFDie:DWARFTypePrinter: Add common utility function for checking where parentheses are required
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 18 22:58:14 PDT 2021
Author: David Blaikie
Date: 2021-09-18T22:54:57-07:00
New Revision: ae0873483d9393d35bd5bdbfcb2bfb843c335cd5
URL: https://github.com/llvm/llvm-project/commit/ae0873483d9393d35bd5bdbfcb2bfb843c335cd5
DIFF: https://github.com/llvm/llvm-project/commit/ae0873483d9393d35bd5bdbfcb2bfb843c335cd5.diff
LOG: DWARFDie:DWARFTypePrinter: Add common utility function for checking where parentheses are required
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index dc801fab1ea5..bd0bd7f4ac00 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -173,12 +173,13 @@ struct DWARFTypePrinter {
}
}
+ bool needsParens(DWARFDie D) {
+ return D && (D.getTag() == DW_TAG_subroutine_type || D.getTag() == DW_TAG_array_type);
+ }
+
void appendPointerLikeTypeBefore(DWARFDie D, DWARFDie Inner, StringRef Ptr) {
appendUnqualifiedNameBefore(Inner);
- bool NeedsParens =
- Inner && (Inner.getTag() == llvm::dwarf::DW_TAG_subroutine_type ||
- Inner.getTag() == llvm::dwarf::DW_TAG_array_type);
- if (NeedsParens)
+ if (needsParens(Inner))
OS << '(';
else if (Word)
OS << ' ';
@@ -227,10 +228,7 @@ struct DWARFTypePrinter {
break;
case DW_TAG_ptr_to_member_type: {
appendUnqualifiedNameBefore(Inner);
- bool NeedsParens =
- Inner && (Inner.getTag() == llvm::dwarf::DW_TAG_subroutine_type ||
- Inner.getTag() == llvm::dwarf::DW_TAG_array_type);
- if (NeedsParens)
+ if (needsParens(Inner))
OS << '(';
else if (Word)
OS << ' ';
@@ -285,10 +283,7 @@ struct DWARFTypePrinter {
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
case DW_TAG_pointer_type: {
- bool NeedsParens =
- Inner && (Inner.getTag() == llvm::dwarf::DW_TAG_subroutine_type ||
- Inner.getTag() == llvm::dwarf::DW_TAG_array_type);
- if (NeedsParens)
+ if (needsParens(Inner))
OS << ')';
appendUnqualifiedNameAfter(
Inner, D.getAttributeValueAsReferencedDie(DW_AT_type),
More information about the llvm-commits
mailing list