Skip to content

[llvm-debuginfo-analyzer] Use LLVM_BUILD_DEBUG in class definitions #140265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir
set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix
if( uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
set(LLVM_BUILD_DEBUG ON)
else()
set(LLVM_BUILD_DEBUG OFF)
endif()


# Note: LLVM_CMAKE_DIR does not include generated files
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
/* Define to 1 if you have the <sysexits.h> header file. */
#cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H}

/* Define if this LLVM build is a Debug build */
#cmakedefine LLVM_BUILD_DEBUG

/* Define if building libLLVM shared library */
#cmakedefine LLVM_BUILD_LLVM_DYLIB

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVCompare.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class LVCompare final {
void printItem(LVElement *Element, LVComparePass Pass);
void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class 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)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const override { print(dbgs()); }
#endif
};
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LVOperation final {

void print(raw_ostream &OS, bool Full = true) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() { print(dbgs()); }
#endif
};
Expand Down Expand Up @@ -159,7 +159,7 @@ class 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)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const override { print(dbgs()); }
#endif
};
Expand Down
11 changes: 6 additions & 5 deletions llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOBJECT_H

#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/LogicalView/Core/LVSupport.h"
Expand Down Expand Up @@ -154,7 +155,7 @@ class 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
#ifdef LLVM_BUILD_DEBUG
incID();
#endif
Properties = Object.Properties;
Expand All @@ -165,7 +166,7 @@ class LVObject {
Parent = Object.Parent;
}

#ifndef NDEBUG
#ifdef LLVM_BUILD_DEBUG
// 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.
Expand Down Expand Up @@ -193,7 +194,7 @@ class LVObject {

public:
LVObject() {
#ifndef NDEBUG
#ifdef LLVM_BUILD_DEBUG
incID();
#endif
};
Expand Down Expand Up @@ -311,13 +312,13 @@ class LVObject {
// (class attributes, debug ranges, files, directories, etc).
virtual void printExtra(raw_ostream &OS, bool Full = true) const {}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
virtual void dump() const { print(dbgs()); }
#endif

uint64_t getID() const {
return
#ifndef NDEBUG
#ifdef LLVM_BUILD_DEBUG
ID;
#else
0;
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class LVOptions {

void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down Expand Up @@ -632,7 +632,7 @@ class LVPatterns final {

void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class 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)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const override { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class LVReader {
void print(raw_ostream &OS) const;
virtual void printRecords(raw_ostream &OS) const {}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class LVScope : public LVElement {
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)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const override { print(dbgs()); }
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class LVStringPool {
}
}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVSymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class 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)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const override { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVType.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class 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)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const override { print(dbgs()); }
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/LVReaderHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class LVReaderHandler {

void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class LVBinaryReader : public LVReader {

void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class LVCodeViewReader final : public LVBinaryReader {
LogicalVisitor.printRecords(OS);
};

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class LVDWARFReader final : public LVBinaryReader {

void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#if defined(LLVM_BUILD_DEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const { print(dbgs()); }
#endif
};
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace llvm::logicalview;

#define DEBUG_TYPE "Object"

#ifndef NDEBUG
#ifdef LLVM_BUILD_DEBUG
uint64_t LVObject::GID = 0;
#endif

Expand Down Expand Up @@ -137,7 +137,7 @@ void LVObject::printAttributes(raw_ostream &OS, bool Full, StringRef Name,
}

void LVObject::printAttributes(raw_ostream &OS, bool Full) const {
#ifndef NDEBUG
#ifdef LLVM_BUILD_DEBUG
if (options().getInternalID())
OS << hexSquareString(getID());
#endif
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,14 @@ void LVOptions::resolveDependencies() {

calculateIndentationSize();

#ifdef LLVM_BUILD_DEBUG
// Print collected command line options.
LLVM_DEBUG({ dump(); });
#endif
}

void LVOptions::calculateIndentationSize() {
#ifndef NDEBUG
#ifdef LLVM_BUILD_DEBUG
if (getInternalID()) {
std::string String = hexSquareString(0);
IndentationSize += String.length();
Expand Down