Skip to content

Commit

Permalink
Remove macro guards for extern template instantiations.
Browse files Browse the repository at this point in the history
This is a C++11 feature that both GCC and MSVC have supported as ane extension
long before C++11 was approved.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242042 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Jul 13, 2015
1 parent ed5546e commit 0ed5091
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 92 deletions.
4 changes: 2 additions & 2 deletions include/llvm/Analysis/DominanceFrontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ class DominanceFrontier : public FunctionPass {
void dump() const;
};

EXTERN_TEMPLATE_INSTANTIATION(class DominanceFrontierBase<BasicBlock>);
EXTERN_TEMPLATE_INSTANTIATION(class ForwardDominanceFrontierBase<BasicBlock>);
extern template class DominanceFrontierBase<BasicBlock>;
extern template class ForwardDominanceFrontierBase<BasicBlock>;

} // End llvm namespace

Expand Down
8 changes: 2 additions & 6 deletions include/llvm/Analysis/LoopInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ raw_ostream& operator<<(raw_ostream &OS, const LoopBase<BlockT, LoopT> &Loop) {
}

// Implementation in LoopInfoImpl.h
#ifdef __GNUC__
__extension__ extern template class LoopBase<BasicBlock, Loop>;
#endif
extern template class LoopBase<BasicBlock, Loop>;

class Loop : public LoopBase<BasicBlock, Loop> {
public:
Expand Down Expand Up @@ -633,9 +631,7 @@ class LoopInfoBase {
};

// Implementation in LoopInfoImpl.h
#ifdef __GNUC__
__extension__ extern template class LoopInfoBase<BasicBlock, Loop>;
#endif
extern template class LoopInfoBase<BasicBlock, Loop>;

class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
typedef LoopInfoBase<BasicBlock, Loop> BaseT;
Expand Down
6 changes: 3 additions & 3 deletions include/llvm/Analysis/RegionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,9 @@ inline raw_ostream &operator<<(raw_ostream &OS,
return OS << Node.template getNodeAs<BlockT>()->getName();
}

EXTERN_TEMPLATE_INSTANTIATION(class RegionBase<RegionTraits<Function>>);
EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase<RegionTraits<Function>>);
EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase<RegionTraits<Function>>);
extern template class RegionBase<RegionTraits<Function>>;
extern template class RegionNodeBase<RegionTraits<Function>>;
extern template class RegionInfoBase<RegionTraits<Function>>;

} // End llvm namespace
#endif
4 changes: 2 additions & 2 deletions include/llvm/CodeGen/MachineDominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ inline void DominatorTreeBase<MachineBasicBlock>::addRoot(MachineBasicBlock* MBB
this->Roots.push_back(MBB);
}

EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
EXTERN_TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
extern template class DomTreeNodeBase<MachineBasicBlock>;
extern template class DominatorTreeBase<MachineBasicBlock>;

typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode;

Expand Down
9 changes: 2 additions & 7 deletions include/llvm/CodeGen/MachineLoopInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@
namespace llvm {

// Implementation in LoopInfoImpl.h
#ifdef __GNUC__
class MachineLoop;
__extension__ extern template class LoopBase<MachineBasicBlock, MachineLoop>;
#endif
extern template class LoopBase<MachineBasicBlock, MachineLoop>;

class MachineLoop : public LoopBase<MachineBasicBlock, MachineLoop> {
public:
Expand All @@ -65,10 +63,7 @@ class MachineLoop : public LoopBase<MachineBasicBlock, MachineLoop> {
};

// Implementation in LoopInfoImpl.h
#ifdef __GNUC__
__extension__ extern template
class LoopInfoBase<MachineBasicBlock, MachineLoop>;
#endif
extern template class LoopInfoBase<MachineBasicBlock, MachineLoop>;

class MachineLoopInfo : public MachineFunctionPass {
LoopInfoBase<MachineBasicBlock, MachineLoop> LI;
Expand Down
7 changes: 3 additions & 4 deletions include/llvm/CodeGen/MachineRegionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ template <> struct GraphTraits<MachineRegionInfoPass*>
}
};

EXTERN_TEMPLATE_INSTANTIATION(class RegionBase<RegionTraits<MachineFunction>>);
EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase<RegionTraits<MachineFunction>>);
EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase<RegionTraits<MachineFunction>>);

extern template class RegionBase<RegionTraits<MachineFunction>>;
extern template class RegionNodeBase<RegionTraits<MachineFunction>>;
extern template class RegionInfoBase<RegionTraits<MachineFunction>>;
}

#endif
20 changes: 8 additions & 12 deletions include/llvm/IR/Dominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,14 @@ namespace llvm {
template <typename IRUnitT> class AnalysisManager;
class PreservedAnalyses;

EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase<BasicBlock>);
EXTERN_TEMPLATE_INSTANTIATION(class DominatorTreeBase<BasicBlock>);

#define LLVM_COMMA ,
EXTERN_TEMPLATE_INSTANTIATION(void Calculate<Function LLVM_COMMA BasicBlock *>(
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT LLVM_COMMA
Function &F));
EXTERN_TEMPLATE_INSTANTIATION(
void Calculate<Function LLVM_COMMA Inverse<BasicBlock *> >(
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *> >::NodeType> &DT
LLVM_COMMA Function &F));
#undef LLVM_COMMA
extern template class DomTreeNodeBase<BasicBlock>;
extern template class DominatorTreeBase<BasicBlock>;

extern template void Calculate<Function, BasicBlock *>(
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT, Function &F);
extern template void Calculate<Function, Inverse<BasicBlock *>>(
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *>>::NodeType> &DT,
Function &F);

typedef DomTreeNodeBase<BasicBlock> DomTreeNode;

Expand Down
28 changes: 14 additions & 14 deletions include/llvm/Support/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ template <> class parser<bool> final : public basic_parser<bool> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<bool>);
extern template class basic_parser<bool>;

//--------------------------------------------------
// parser<boolOrDefault>
Expand All @@ -816,7 +816,7 @@ class parser<boolOrDefault> final : public basic_parser<boolOrDefault> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
extern template class basic_parser<boolOrDefault>;

//--------------------------------------------------
// parser<int>
Expand All @@ -838,7 +838,7 @@ template <> class parser<int> final : public basic_parser<int> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<int>);
extern template class basic_parser<int>;

//--------------------------------------------------
// parser<unsigned>
Expand All @@ -860,7 +860,7 @@ template <> class parser<unsigned> final : public basic_parser<unsigned> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned>);
extern template class basic_parser<unsigned>;

//--------------------------------------------------
// parser<unsigned long long>
Expand All @@ -885,7 +885,7 @@ class parser<unsigned long long> final
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>);
extern template class basic_parser<unsigned long long>;

//--------------------------------------------------
// parser<double>
Expand All @@ -907,7 +907,7 @@ template <> class parser<double> final : public basic_parser<double> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<double>);
extern template class basic_parser<double>;

//--------------------------------------------------
// parser<float>
Expand All @@ -929,7 +929,7 @@ template <> class parser<float> final : public basic_parser<float> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<float>);
extern template class basic_parser<float>;

//--------------------------------------------------
// parser<std::string>
Expand All @@ -954,7 +954,7 @@ template <> class parser<std::string> final : public basic_parser<std::string> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<std::string>);
extern template class basic_parser<std::string>;

//--------------------------------------------------
// parser<char>
Expand All @@ -979,7 +979,7 @@ template <> class parser<char> final : public basic_parser<char> {
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<char>);
extern template class basic_parser<char>;

//--------------------------------------------------
// PrintOptionDiff
Expand Down Expand Up @@ -1254,11 +1254,11 @@ class opt : public Option,
}
};

EXTERN_TEMPLATE_INSTANTIATION(class opt<unsigned>);
EXTERN_TEMPLATE_INSTANTIATION(class opt<int>);
EXTERN_TEMPLATE_INSTANTIATION(class opt<std::string>);
EXTERN_TEMPLATE_INSTANTIATION(class opt<char>);
EXTERN_TEMPLATE_INSTANTIATION(class opt<bool>);
extern template class opt<unsigned>;
extern template class opt<int>;
extern template class opt<std::string>;
extern template class opt<char>;
extern template class opt<bool>;

//===----------------------------------------------------------------------===//
// list_storage class
Expand Down
13 changes: 0 additions & 13 deletions include/llvm/Support/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,6 @@
#define LLVM_UNLIKELY(EXPR) (EXPR)
#endif

// C++ doesn't support 'extern template' of template specializations. GCC does,
// but requires __extension__ before it. In the header, use this:
// EXTERN_TEMPLATE_INSTANTIATION(class foo<bar>);
// in the .cpp file, use this:
// TEMPLATE_INSTANTIATION(class foo<bar>);
#ifdef __GNUC__
#define EXTERN_TEMPLATE_INSTANTIATION(X) __extension__ extern template X
#define TEMPLATE_INSTANTIATION(X) template X
#else
#define EXTERN_TEMPLATE_INSTANTIATION(X)
#define TEMPLATE_INSTANTIATION(X)
#endif

/// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so,
/// mark a method "not for inlining".
#if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0)
Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/MachineDominators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
using namespace llvm;

namespace llvm {
TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
template class DomTreeNodeBase<MachineBasicBlock>;
template class DominatorTreeBase<MachineBasicBlock>;
}

char MachineDominatorTree::ID = 0;
Expand Down
20 changes: 8 additions & 12 deletions lib/IR/Dominators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,14 @@ bool BasicBlockEdge::isSingleEdge() const {
//
//===----------------------------------------------------------------------===//

TEMPLATE_INSTANTIATION(class llvm::DomTreeNodeBase<BasicBlock>);
TEMPLATE_INSTANTIATION(class llvm::DominatorTreeBase<BasicBlock>);

#define LLVM_COMMA ,
TEMPLATE_INSTANTIATION(void llvm::Calculate<Function LLVM_COMMA BasicBlock *>(
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT LLVM_COMMA
Function &F));
TEMPLATE_INSTANTIATION(
void llvm::Calculate<Function LLVM_COMMA Inverse<BasicBlock *> >(
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *> >::NodeType> &DT
LLVM_COMMA Function &F));
#undef LLVM_COMMA
template class llvm::DomTreeNodeBase<BasicBlock>;
template class llvm::DominatorTreeBase<BasicBlock>;

template void llvm::Calculate<Function, BasicBlock *>(
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT, Function &F);
template void llvm::Calculate<Function, Inverse<BasicBlock *>>(
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *>>::NodeType> &DT,
Function &F);

// dominates - Return true if Def dominates a use in User. This performs
// the special checks necessary if Def and User are in the same basic block.
Expand Down
30 changes: 15 additions & 15 deletions lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ using namespace cl;
//
namespace llvm {
namespace cl {
TEMPLATE_INSTANTIATION(class basic_parser<bool>);
TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
TEMPLATE_INSTANTIATION(class basic_parser<int>);
TEMPLATE_INSTANTIATION(class basic_parser<unsigned>);
TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>);
TEMPLATE_INSTANTIATION(class basic_parser<double>);
TEMPLATE_INSTANTIATION(class basic_parser<float>);
TEMPLATE_INSTANTIATION(class basic_parser<std::string>);
TEMPLATE_INSTANTIATION(class basic_parser<char>);

TEMPLATE_INSTANTIATION(class opt<unsigned>);
TEMPLATE_INSTANTIATION(class opt<int>);
TEMPLATE_INSTANTIATION(class opt<std::string>);
TEMPLATE_INSTANTIATION(class opt<char>);
TEMPLATE_INSTANTIATION(class opt<bool>);
template class basic_parser<bool>;
template class basic_parser<boolOrDefault>;
template class basic_parser<int>;
template class basic_parser<unsigned>;
template class basic_parser<unsigned long long>;
template class basic_parser<double>;
template class basic_parser<float>;
template class basic_parser<std::string>;
template class basic_parser<char>;

template class opt<unsigned>;
template class opt<int>;
template class opt<std::string>;
template class opt<char>;
template class opt<bool>;
}
} // end namespace llvm::cl

Expand Down

0 comments on commit 0ed5091

Please sign in to comment.