Skip to content

Commit a77d44d

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 1456a4f commit a77d44d

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"
@@ -155,7 +156,7 @@ class LLVM_ABI LVObject {
155156
// copy constructor to create that object; it is used to print a reference
156157
// to another object and in the case of templates, to print its encoded args.
157158
LVObject(const LVObject &Object) {
158-
#ifndef NDEBUG
159+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
159160
incID();
160161
#endif
161162
Properties = Object.Properties;
@@ -166,7 +167,7 @@ class LLVM_ABI LVObject {
166167
Parent = Object.Parent;
167168
}
168169

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

195196
public:
196197
LVObject() {
197-
#ifndef NDEBUG
198+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
198199
incID();
199200
#endif
200201
};
@@ -318,7 +319,7 @@ class LLVM_ABI LVObject {
318319

319320
uint64_t getID() const {
320321
return
321-
#ifndef NDEBUG
322+
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
322323
ID;
323324
#else
324325
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)