[all-commits] [llvm/llvm-project] 056318: [llvm] properly guard dump methods in Support lib ...

Andrew Rogers via All-commits all-commits at lists.llvm.org
Wed May 14 13:49:07 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0563186a76ddf51b8a7b6eaf0357c224f2625df8
      https://github.com/llvm/llvm-project/commit/0563186a76ddf51b8a7b6eaf0357c224f2625df8
  Author: Andrew Rogers <andrurogerz at gmail.com>
  Date:   2025-05-14 (Wed, 14 May 2025)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
    M llvm/include/llvm/ADT/APFixedPoint.h
    M llvm/include/llvm/ADT/APFloat.h
    M llvm/include/llvm/ADT/APInt.h
    M llvm/include/llvm/ADT/DynamicAPInt.h
    M llvm/include/llvm/ADT/SlowDynamicAPInt.h
    M llvm/include/llvm/ADT/TrieRawHashMap.h
    M llvm/include/llvm/ADT/Twine.h
    M llvm/include/llvm/Support/BranchProbability.h
    M llvm/include/llvm/Support/DebugCounter.h
    M llvm/include/llvm/Support/KnownBits.h
    M llvm/include/llvm/Support/SMTAPI.h
    M llvm/include/llvm/Support/ScaledNumber.h
    M llvm/lib/Support/APFixedPoint.cpp
    M llvm/lib/Support/DebugCounter.cpp
    M llvm/lib/Support/DynamicAPInt.cpp
    M llvm/lib/Support/KnownBits.cpp
    M llvm/lib/Support/ScaledNumber.cpp
    M llvm/lib/Support/SlowDynamicAPInt.cpp
    M llvm/lib/Support/Z3Solver.cpp

  Log Message:
  -----------
  [llvm] properly guard dump methods in Support lib classes (#139938)

## Purpose
Add proper preprocessor guards for all `dump()` methods in the LLVM
support library. This change ensures these methods are not part of the
public ABI for release builds.

## Overview
* Annotates all `dump` methods in Support and ADT source with the
`LLVM_DUMP_METHOD` macro.
* Conditionally includes all `dump` method definitions in Support and
ADT source so they are only present on debug/assert builds and when
`LLVM_ENABLE_DUMP` is explicitly defined.

NOTE: For many of these `dump` methods, the implementation was already
properly guarded but the declaration in the header file was not.

## Background
This PR is a redo of #139804 with some changes to fix clang and unit
test build breaks.

This issue was raised in comments on #136629. I am addressing it as a
separate change since it is independent from the changes being made in
that PR.

According to [this
documentation](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Compiler.h#L637),
`dump` methods should be annotated with `LLVM_DUMP_METHOD` and
conditionally included as follows:
```
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void dump() const;
#endif
```

## Validation
* Local release build succeeds.
* CI



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list