Skip to content
Closed
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
28 changes: 20 additions & 8 deletions clang/include/clang/AST/DeclarationName.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cstdint>
#include <cstring>
#include <string>
#include <type_traits>

namespace clang {

Expand Down Expand Up @@ -194,6 +195,14 @@ class DeclarationName {
"The various classes that DeclarationName::Ptr can point to"
" must be at least aligned to 8 bytes!");

static_assert(std::is_same<
std::underlying_type_t<StoredNameKind>,
std::underlying_type_t<detail::DeclarationNameExtra::ExtraKind>
>::value,
"The various enums used to compute values for NameKind should "
"all have the same underlying type"
);

public:
/// The kind of the name stored in this DeclarationName.
/// The first 7 enumeration values are stored inline and correspond
Expand All @@ -207,15 +216,18 @@ class DeclarationName {
CXXDestructorName = StoredCXXDestructorName,
CXXConversionFunctionName = StoredCXXConversionFunctionName,
CXXOperatorName = StoredCXXOperatorName,
CXXDeductionGuideName = UncommonNameKindOffset +
detail::DeclarationNameExtra::CXXDeductionGuideName,
CXXDeductionGuideName =
static_cast<std::underlying_type_t<StoredNameKind>>(UncommonNameKindOffset) +
static_cast<std::underlying_type_t<detail::DeclarationNameExtra::ExtraKind>>(detail::DeclarationNameExtra::CXXDeductionGuideName),
CXXLiteralOperatorName =
UncommonNameKindOffset +
detail::DeclarationNameExtra::CXXLiteralOperatorName,
CXXUsingDirective = UncommonNameKindOffset +
detail::DeclarationNameExtra::CXXUsingDirective,
ObjCMultiArgSelector = UncommonNameKindOffset +
detail::DeclarationNameExtra::ObjCMultiArgSelector
static_cast<std::underlying_type_t<StoredNameKind>>(UncommonNameKindOffset) +
static_cast<std::underlying_type_t<detail::DeclarationNameExtra::ExtraKind>>(detail::DeclarationNameExtra::CXXLiteralOperatorName),
CXXUsingDirective =
static_cast<std::underlying_type_t<StoredNameKind>>(UncommonNameKindOffset) +
static_cast<std::underlying_type_t<detail::DeclarationNameExtra::ExtraKind>>(detail::DeclarationNameExtra::CXXUsingDirective),
ObjCMultiArgSelector =
static_cast<std::underlying_type_t<StoredNameKind>>(UncommonNameKindOffset) +
static_cast<std::underlying_type_t<detail::DeclarationNameExtra::ExtraKind>>(detail::DeclarationNameExtra::ObjCMultiArgSelector),
};

private:
Expand Down
41 changes: 40 additions & 1 deletion llvm/include/llvm/ADT/StringRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace llvm {
return ::memcmp(Lhs,Rhs,Length);
}

protected:
// Constexpr version of std::strlen.
static constexpr size_t strLen(const char *Str) {
#if __cplusplus > 201402L
Expand All @@ -91,6 +92,13 @@ namespace llvm {
#endif
}

#if __cpp_char8_t
// Constexpr version of std::strlen for char8_t
static constexpr size_t strLen(const char8_t *Str) {
return std::char_traits<char8_t>::length(Str);
}
#endif

public:
/// @name Constructors
/// @{
Expand All @@ -106,10 +114,22 @@ namespace llvm {
/*implicit*/ constexpr StringRef(const char *Str)
: Data(Str), Length(Str ? strLen(Str) : 0) {}

#if __cpp_char8_t
/// Construct a string ref from a cstring.
/*implicit*/ StringRef(const char8_t *Str)
: StringRef(reinterpret_cast<const char *>(Str)) {}
#endif

/// Construct a string ref from a pointer and length.
/*implicit*/ constexpr StringRef(const char *data, size_t length)
: Data(data), Length(length) {}

#if __cpp_char8_t
/// Construct a string ref from a pointer and length.
/*implicit*/ StringRef(const char8_t *data, size_t length)
: StringRef(reinterpret_cast<const char *>(data), length) {}
#endif

/// Construct a string ref from an std::string.
/*implicit*/ StringRef(const std::string &Str)
: Data(Str.data()), Length(Str.length()) {}
Expand Down Expand Up @@ -874,19 +894,38 @@ namespace llvm {
constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) {
}

#if __cpp_char8_t
StringLiteral(const char8_t *Str, size_t N) : StringRef(Str, N) {
}
#endif

public:
template <size_t N>
constexpr StringLiteral(const char (&Str)[N])
#if defined(__clang__) && __has_attribute(enable_if)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
__attribute((enable_if(__builtin_strlen(Str) == N - 1,
__attribute((enable_if(strLen(Str) == N - 1,
"invalid string literal")))
#pragma clang diagnostic pop
#endif
: StringRef(Str, N - 1) {
}

#if __cpp_char8_t
template <size_t N>
StringLiteral(const char8_t (&Str)[N])
#if defined(__clang__) && __has_attribute(enable_if)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
__attribute((enable_if(strLen(Str) == N - 1,
"invalid string literal")))
#pragma clang diagnostic pop
#endif
: StringRef(Str, N - 1) {
}
#endif

// Explicit construction for strings like "foo\0bar".
template <size_t N>
static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/IteratedDominanceFrontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ChildrenGetterTy<BasicBlock, IsPostDom>::get(const NodeRef &N) {
return {Children.begin(), Children.end()};
}

return GD->template getChildren<IsPostDom>(N);
return GD->template getChildren<IsPostDom, DTIdentityView>(N);
}

} // end of namespace IDFCalculatorDetail
Expand Down
11 changes: 10 additions & 1 deletion llvm/include/llvm/Analysis/LoopInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ class MDNode;
class MemorySSAUpdater;
class ScalarEvolution;
class raw_ostream;
template <class N, bool IsPostDom> class DominatorTreeBase;

template<typename X>
using DTIdentityView = X;

template <typename NodeT, bool IsPostDom, template<typename> class View>
class DominatorTreeOnView;

template <typename NodeT, bool IsPostDom>
using DominatorTreeBase = DominatorTreeOnView<NodeT, IsPostDom, DTIdentityView>;

template <class N, class M> class LoopInfoBase;
template <class N, class M> class LoopBase;

Expand Down
9 changes: 8 additions & 1 deletion llvm/include/llvm/CodeGen/LiveIntervalCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@

namespace llvm {

template <class NodeT> class DomTreeNodeBase;
template<typename X>
using DTIdentityView = X;

template <typename NodeT, template<typename> class View>
class DomTreeNodeOnView;

template <typename NodeT>
using DomTreeNodeBase = DomTreeNodeOnView<NodeT, DTIdentityView>;

using MachineDomTreeNode = DomTreeNodeBase<MachineBasicBlock>;

Expand Down
14 changes: 11 additions & 3 deletions llvm/include/llvm/CodeGen/LiveRangeCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,21 @@

namespace llvm {

template <class NodeT> class DomTreeNodeBase;
template<typename X>
using DTIdentityView = X;

template <typename NodeT, template<typename> class View>
class DomTreeNodeOnView;

template <typename NodeT>
using DomTreeNodeBase = DomTreeNodeOnView<NodeT, DTIdentityView>;

using MachineDomTreeNode = DomTreeNodeBase<MachineBasicBlock>;

class MachineDominatorTree;
class MachineFunction;
class MachineRegisterInfo;

using MachineDomTreeNode = DomTreeNodeBase<MachineBasicBlock>;

class LiveRangeCalc {
const MachineFunction *MF = nullptr;
const MachineRegisterInfo *MRI = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/CodeGen/MachineDominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ inline void DominatorTreeBase<MachineBasicBlock, false>::addRoot(
this->Roots.push_back(MBB);
}

extern template class DomTreeNodeBase<MachineBasicBlock>;
extern template class DominatorTreeBase<MachineBasicBlock, false>; // DomTree
extern template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTree
extern template class DomTreeNodeOnView<MachineBasicBlock, DTIdentityView>;
extern template class DominatorTreeOnView<MachineBasicBlock, false, DTIdentityView>; // DomTree
extern template class DominatorTreeOnView<MachineBasicBlock, true, DTIdentityView>; // PostDomTree

using MachineDomTreeNode = DomTreeNodeBase<MachineBasicBlock>;

Expand Down
81 changes: 44 additions & 37 deletions llvm/include/llvm/IR/Dominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,57 @@ class Instruction;
class Module;
class raw_ostream;

extern template class DomTreeNodeBase<BasicBlock>;
extern template class DominatorTreeBase<BasicBlock, false>; // DomTree
extern template class DominatorTreeBase<BasicBlock, true>; // PostDomTree
extern template class DomTreeNodeOnView<BasicBlock, DTIdentityView>;
extern template class DominatorTreeOnView<BasicBlock, false, DTIdentityView>; // DomTree
extern template class DominatorTreeOnView<BasicBlock, true, DTIdentityView>; // PostDomTree

extern template class cfg::Update<BasicBlock *>;

namespace DomTreeBuilder {
using BBDomTree = DomTreeBase<BasicBlock>;
using BBPostDomTree = PostDomTreeBase<BasicBlock>;
template<template<typename> class View>
using BBDomTreeOnView = DomTreeOnView<BasicBlock, View>;

using BBDomTree = DomTreeOnView<BasicBlock, DTIdentityView>;

template<template<typename> class View>
using BBPostDomTreeOnView = PostDomTreeOnView<BasicBlock, View>;

using BBPostDomTree = PostDomTreeOnView<BasicBlock, DTIdentityView>;

using BBUpdates = ArrayRef<llvm::cfg::Update<BasicBlock *>>;

using BBDomTreeGraphDiff = GraphDiff<BasicBlock *, false>;
using BBPostDomTreeGraphDiff = GraphDiff<BasicBlock *, true>;

extern template void Calculate<BBDomTree>(BBDomTree &DT);
extern template void CalculateWithUpdates<BBDomTree>(BBDomTree &DT,
BBUpdates U);

extern template void Calculate<BBPostDomTree>(BBPostDomTree &DT);

extern template void InsertEdge<BBDomTree>(BBDomTree &DT, BasicBlock *From,
BasicBlock *To);
extern template void InsertEdge<BBPostDomTree>(BBPostDomTree &DT,
BasicBlock *From,
BasicBlock *To);

extern template void DeleteEdge<BBDomTree>(BBDomTree &DT, BasicBlock *From,
BasicBlock *To);
extern template void DeleteEdge<BBPostDomTree>(BBPostDomTree &DT,
BasicBlock *From,
BasicBlock *To);

extern template void ApplyUpdates<BBDomTree>(BBDomTree &DT,
BBDomTreeGraphDiff &,
BBDomTreeGraphDiff *);
extern template void ApplyUpdates<BBPostDomTree>(BBPostDomTree &DT,
BBPostDomTreeGraphDiff &,
BBPostDomTreeGraphDiff *);

extern template bool Verify<BBDomTree>(const BBDomTree &DT,
BBDomTree::VerificationLevel VL);
extern template bool Verify<BBPostDomTree>(const BBPostDomTree &DT,
BBPostDomTree::VerificationLevel VL);
using BBDomTreeGraphDiff = GraphDiff<BBDomTree::NodePtr, false>;
using BBPostDomTreeGraphDiff = GraphDiff<BBPostDomTree::NodePtr, true>;

extern template void Calculate<BasicBlock, false, DTIdentityView>(BBDomTree &DT);
extern template void
CalculateWithUpdates<BasicBlock, false, DTIdentityView>(BBDomTree &DT, BBUpdates U);

extern template void Calculate<BasicBlock, true, DTIdentityView>(BBPostDomTree &DT);

extern template void
InsertEdge<BasicBlock, false, DTIdentityView>(BBDomTree &DT, BasicBlock *From, BasicBlock *To);
extern template void
InsertEdge<BasicBlock, true, DTIdentityView>(BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);

extern template void
DeleteEdge<BasicBlock, false, DTIdentityView>(BBDomTree &DT, BasicBlock *From, BasicBlock *To);
extern template void
DeleteEdge<BasicBlock, true, DTIdentityView>(BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);

extern template void
ApplyUpdates<BasicBlock, false, DTIdentityView>(BBDomTree &DT,
BBDomTreeGraphDiff &,
BBDomTreeGraphDiff *);
extern template void
ApplyUpdates<BasicBlock, true, DTIdentityView>(BBPostDomTree &DT,
BBPostDomTreeGraphDiff &,
BBPostDomTreeGraphDiff *);

extern template bool
Verify<BasicBlock, false, DTIdentityView>(const BBDomTree &DT, BBDomTree::VerificationLevel VL);
extern template bool
Verify<BasicBlock, true, DTIdentityView>(const BBPostDomTree &DT, BBPostDomTree::VerificationLevel VL);
} // namespace DomTreeBuilder

using DomTreeNode = DomTreeNodeBase<BasicBlock>;
Expand Down
9 changes: 5 additions & 4 deletions llvm/include/llvm/Support/CFGDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ template <typename NodePtr, bool InverseGraph = false> class GraphDiff {
}

using VectRet = SmallVector<NodePtr, 8>;
template <bool InverseEdge> VectRet getChildren(NodePtr N) const {
template <bool InverseEdge, template <typename> class View> VectRet getChildren(NodePtr N) const {
using DirectedNodeT =
std::conditional_t<InverseEdge, Inverse<NodePtr>, NodePtr>;
auto R = children<DirectedNodeT>(N);
VectRet Res = VectRet(detail::reverse_if<!InverseEdge>(R));
std::conditional_t<InverseEdge, Inverse<View<NodePtr>>, View<NodePtr>>;
VectRet Res = VectRet(children<DirectedNodeT>(N));
if (not InverseEdge)
std::reverse(Res.begin(), Res.end());

// Remove nullptr children for clang.
llvm::erase_value(Res, nullptr);
Expand Down
Loading