[llvm] [llvm-debuginfo-analyzer] Use `LLVM_BUILD_DEBUG` in class definitions (PR #140265)
Javier Lopez-Gomez via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 9 08:00:39 PDT 2025
https://github.com/jalopezg-git updated https://github.com/llvm/llvm-project/pull/140265
>From 35d3df257f0fb6914c709ad22f7c9d7d74c292d9 Mon Sep 17 00:00:00 2001
From: Javier Lopez-Gomez <javier.lopez.gomez at proton.me>
Date: Mon, 9 Jun 2025 16:59:50 +0200
Subject: [PATCH 1/2] [llvm-debuginfo-analyzer] Make LVObject::dump()
non-virtual (NFC)
`LVObject::dump()` does not need to be virtual as it relays to
`LVObject::print()` that is.
---
llvm/include/llvm/DebugInfo/LogicalView/Core/LVLine.h | 4 ----
llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h | 6 +-----
llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h | 2 +-
llvm/include/llvm/DebugInfo/LogicalView/Core/LVRange.h | 4 ----
llvm/include/llvm/DebugInfo/LogicalView/Core/LVScope.h | 4 ----
llvm/include/llvm/DebugInfo/LogicalView/Core/LVSymbol.h | 4 ----
llvm/include/llvm/DebugInfo/LogicalView/Core/LVType.h | 4 ----
7 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLine.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLine.h
index c979dc4a6be2e..3618ce7b0ecda 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLine.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLine.h
@@ -105,10 +105,6 @@ class LLVM_ABI LVLine : public LVElement {
void print(raw_ostream &OS, bool Full = true) const override;
void printExtra(raw_ostream &OS, bool Full = true) const override {}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() const override { print(dbgs()); }
-#endif
};
// Class to represent a DWARF line record object.
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h
index 7b466ae206e4e..0718e33f5645b 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h
@@ -51,7 +51,7 @@ class LVOperation final {
LLVM_ABI void print(raw_ostream &OS, bool Full = true) const;
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() { print(dbgs()); }
+ void dump() const { print(dbgs()); }
#endif
};
@@ -159,10 +159,6 @@ class LLVM_ABI LVLocation : public LVObject {
void print(raw_ostream &OS, bool Full = true) const override;
void printExtra(raw_ostream &OS, bool Full = true) const override;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() const override { print(dbgs()); }
-#endif
};
class LLVM_ABI LVLocationSymbol final : public LVLocation {
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
index ec02120e69b73..0ef8c78dab976 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
@@ -313,7 +313,7 @@ class LLVM_ABI LVObject {
virtual void printExtra(raw_ostream &OS, bool Full = true) const {}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- virtual void dump() const { print(dbgs()); }
+ void dump() const { print(dbgs()); }
#endif
uint64_t getID() const {
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVRange.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVRange.h
index 07d5813e5b19b..b5c833330e59e 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVRange.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVRange.h
@@ -87,10 +87,6 @@ class LLVM_ABI LVRange final : public LVObject {
void print(raw_ostream &OS, bool Full = true) const override;
void printExtra(raw_ostream &OS, bool Full = true) const override {}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() const override { print(dbgs()); }
-#endif
};
} // end namespace logicalview
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVScope.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVScope.h
index a64c72278bbfc..1f13f56979c54 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVScope.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVScope.h
@@ -325,10 +325,6 @@ class LLVM_ABI LVScope : public LVElement {
void printExtra(raw_ostream &OS, bool Full = true) const override;
virtual void printWarnings(raw_ostream &OS, bool Full = true) const {}
virtual void printMatchedElements(raw_ostream &OS, bool UseMatchedElements) {}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() const override { print(dbgs()); }
-#endif
};
// Class to represent a DWARF Union/Structure/Class.
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSymbol.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSymbol.h
index 93ca2a73d64dd..ec9017e16b659 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSymbol.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSymbol.h
@@ -183,10 +183,6 @@ class LLVM_ABI LVSymbol final : public LVElement {
void print(raw_ostream &OS, bool Full = true) const override;
void printExtra(raw_ostream &OS, bool Full = true) const override;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() const override { print(dbgs()); }
-#endif
};
} // end namespace logicalview
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVType.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVType.h
index cbce9cb65c920..59e6a92be8ce6 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVType.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVType.h
@@ -146,10 +146,6 @@ class LLVM_ABI LVType : public LVElement {
void print(raw_ostream &OS, bool Full = true) const override;
void printExtra(raw_ostream &OS, bool Full = true) const override;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- void dump() const override { print(dbgs()); }
-#endif
};
// Class to represent DW_TAG_typedef_type.
>From d06072e6260d1439889a152ad77fae30cdf966ce Mon Sep 17 00:00:00 2001
From: Javier Lopez-Gomez <javier.lopez.gomez at proton.me>
Date: Mon, 9 Jun 2025 16:59:51 +0200
Subject: [PATCH 2/2] [llvm-debuginfo-analyzer][debuginfologicalview] Fix ODR
violation in LVObject
Fix ODR violation in `LVObject` when `DebugInfoLogicalView` library
is used in a downstream project.
Depending solely on `NDEBUG` for exposing some data members may cause
trouble in downstream projects.
Enable such cases only if `LLVM_ENABLE_ABI_BREAKING_CHECKS`.
---
llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h | 9 +++++----
llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
index 0ef8c78dab976..645b0e79d1055 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
@@ -15,6 +15,7 @@
#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOBJECT_H
#include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/Config/abi-breaking.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/LogicalView/Core/LVSupport.h"
@@ -155,7 +156,7 @@ class LLVM_ABI LVObject {
// copy constructor to create that object; it is used to print a reference
// to another object and in the case of templates, to print its encoded args.
LVObject(const LVObject &Object) {
-#ifndef NDEBUG
+#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
incID();
#endif
Properties = Object.Properties;
@@ -166,7 +167,7 @@ class LLVM_ABI LVObject {
Parent = Object.Parent;
}
-#ifndef NDEBUG
+#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
// This is an internal ID used for debugging logical elements. It is used
// for cases where an unique offset within the binary input file is not
// available.
@@ -194,7 +195,7 @@ class LLVM_ABI LVObject {
public:
LVObject() {
-#ifndef NDEBUG
+#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
incID();
#endif
};
@@ -318,7 +319,7 @@ class LLVM_ABI LVObject {
uint64_t getID() const {
return
-#ifndef NDEBUG
+#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
ID;
#else
0;
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
index 75acbf3225e08..3d5c2b26fef15 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
@@ -21,7 +21,7 @@ using namespace llvm::logicalview;
#define DEBUG_TYPE "Object"
-#ifndef NDEBUG
+#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
uint64_t LVObject::GID = 0;
#endif
More information about the llvm-commits
mailing list