[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

Ilya Biryukov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 5 01:25:02 PDT 2024


ilya-biryukov wrote:

Sorry for the delay, I had an emergency and took a week off.
We have hit some form of OOM (an infinite loop or some exponential computation allocating memory?)  on the following small example (ready as a test case, also in [this commit](https://github.com/ilya-biryukov/llvm-project/commit/6e2f55a1d1fa90b325ca2891c2a101bc79a32b9d)):

```cpp
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/type_traits.cppm -emit-module-interface -o %t/type_traits.pcm
// RUN: %clang_cc1 -std=c++20 %t/test.cpp -fprebuilt-module-path=%t -verify

//--- type_traits.cppm
export module type_traits;

export template <typename T>
constexpr bool is_pod_v = __is_pod(T);

//--- test.cpp
import type_traits;
// Base is either void or wrapper<T>.
template <class Base> struct wrapper : Base {};
template <> struct wrapper<void> {};

// wrap<0>::type<T> is wrapper<T>, wrap<1>::type<T> is wrapper<wrapper<T>>,
// and so on.
template <int N>
struct wrap {
  template <class Base>
  using type = wrapper<typename wrap<N-1>::template type<Base>>;
};

template <>
struct wrap<0> {
  template <class Base>
  using type = wrapper<Base>;
};

inline constexpr int kMaxRank = 40;
template <int N, class Base = void>
using rank = typename wrap<N>::template type<Base>;
using rank_selector_t = rank<40>;

static_assert(is_pod_v<rank_selector_t>, "Must be POD");
```

There might be more problems as this one has been caught early and blocked further progress.

https://github.com/llvm/llvm-project/pull/83237


More information about the llvm-branch-commits mailing list