Skip to content

Commit e8ee4f1

Browse files
committed
[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`.
1 parent 9caf018 commit e8ee4f1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOBJECT_H
1616

1717
#include "llvm/BinaryFormat/Dwarf.h"
18+
#include "llvm/Config/abi-breaking.h"
1819
#include "llvm/DebugInfo/CodeView/CodeView.h"
1920
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
2021
#include "llvm/DebugInfo/LogicalView/Core/LVSupport.h"
@@ -154,7 +155,7 @@ class LVObject {
154155
// copy constructor to create that object; it is used to print a reference
155156
// to another object and in the case of templates, to print its encoded args.
156157
LVObject(const LVObject &Object) {
157-
#ifndef NDEBUG
158+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
158159
incID();
159160
#endif
160161
Properties = Object.Properties;
@@ -165,7 +166,7 @@ class LVObject {
165166
Parent = Object.Parent;
166167
}
167168

168-
#ifndef NDEBUG
169+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
169170
// This is an internal ID used for debugging logical elements. It is used
170171
// for cases where an unique offset within the binary input file is not
171172
// available.
@@ -193,7 +194,7 @@ class LVObject {
193194

194195
public:
195196
LVObject() {
196-
#ifndef NDEBUG
197+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
197198
incID();
198199
#endif
199200
};
@@ -317,7 +318,7 @@ class LVObject {
317318

318319
uint64_t getID() const {
319320
return
320-
#ifndef NDEBUG
321+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
321322
ID;
322323
#else
323324
0;

llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace llvm::logicalview;
2121

2222
#define DEBUG_TYPE "Object"
2323

24-
#ifndef NDEBUG
24+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
2525
uint64_t LVObject::GID = 0;
2626
#endif
2727

0 commit comments

Comments
 (0)