[all-commits] [llvm/llvm-project] 53a24c: [clang][DebugInfo] Improve heuristic to determine ...

Michael Buch via All-commits all-commits at lists.llvm.org
Thu Nov 30 02:41:38 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 53a24c33f09b81b8f009afbabd05f7086db3f288
      https://github.com/llvm/llvm-project/commit/53a24c33f09b81b8f009afbabd05f7086db3f288
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2023-11-30 (Thu, 30 Nov 2023)

  Changed paths:
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M clang/test/CodeGenCXX/debug-info-static-inline-member.cpp
    M clang/test/CodeGenCXX/debug-info-static-member.cpp

  Log Message:
  -----------
  [clang][DebugInfo] Improve heuristic to determine whether to evaluate a static variable's initializer (#72974)

This patch extracts the logic to evaluate a C++ static data-member's
constant initializer. This logic will be re-used in an upcoming patch.

It also makes the check for whether we are dealing with a constant
initializer more robust/idiomatic, which revealed a bug in the
`debug-info-static-inline-member` test (which existed since its
introduction in https://github.com/llvm/llvm-project/pull/71780)

**Test changes**

* `debug-info-static-member.cpp`:
  * We added the check for `const_b` as part of the
    patch series in `638a8393615e911b729d5662096f60ef49f1c65e`.
The check for `isUsableAsConstantExpression` added in the current patch
doesn't support constant inline floats (since they are neither constexpr
nor
    integrals). This isn't a regression since before said patch series
    we wouldn't ever emit the definition for `const_b` anyway. Now
we just don't do it for `inline const float`s. This is consistent with
    GCC's behaviour starting with C++11.

* `debug-info-static-inline-member`:
  * This was just a bug which is now fixed. We shouldn't emit
    a `DW_AT_const_value` for a non-const static.




More information about the All-commits mailing list