Skip to content
Merged
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
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ class Expr : public ValueStmt {
// PointerLikeTypeTraits is specialized so it can be used with a forward-decl of
// Expr. Verify that we got it right.
static_assert(llvm::PointerLikeTypeTraits<Expr *>::NumLowBitsAvailable <=
llvm::detail::ConstantLog2<alignof(Expr)>::value,
llvm::CTLog2<alignof(Expr)>(),
"PointerLikeTypeTraits<Expr*> assumes too much alignment.");

using ConstantExprKind = Expr::ConstantExprKind;
Expand Down
14 changes: 3 additions & 11 deletions llvm/include/llvm/Support/PointerLikeTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H

#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <type_traits>

namespace llvm {

Expand All @@ -25,12 +25,6 @@ namespace llvm {
template <typename T> struct PointerLikeTypeTraits;

namespace detail {
/// A tiny meta function to compute the log2 of a compile time constant.
template <size_t N>
struct ConstantLog2
: std::integral_constant<size_t, ConstantLog2<N / 2>::value + 1> {};
template <> struct ConstantLog2<1> : std::integral_constant<size_t, 0> {};

// Provide a trait to check if T is pointer-like.
template <typename T, typename U = void> struct HasPointerLikeTypeTraits {
static const bool value = false;
Expand All @@ -57,8 +51,7 @@ template <typename T> struct PointerLikeTypeTraits<T *> {
static inline void *getAsVoidPointer(T *P) { return P; }
static inline T *getFromVoidPointer(void *P) { return static_cast<T *>(P); }

static constexpr int NumLowBitsAvailable =
detail::ConstantLog2<alignof(T)>::value;
static constexpr int NumLowBitsAvailable = CTLog2<alignof(T)>();
};

template <> struct PointerLikeTypeTraits<void *> {
Expand Down Expand Up @@ -123,8 +116,7 @@ template <> struct PointerLikeTypeTraits<uintptr_t> {
/// potentially use alignment attributes on functions to satisfy that.
template <int Alignment, typename FunctionPointerT>
struct FunctionPointerLikeTypeTraits {
static constexpr int NumLowBitsAvailable =
detail::ConstantLog2<Alignment>::value;
static constexpr int NumLowBitsAvailable = CTLog2<Alignment>();
static inline void *getAsVoidPointer(FunctionPointerT P) {
assert((reinterpret_cast<uintptr_t>(P) &
~((uintptr_t)-1 << NumLowBitsAvailable)) == 0 &&
Expand Down