From 0ed5091742d9e6603b30e7270a8eab0350e962dd Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 13 Jul 2015 17:21:31 +0000 Subject: [PATCH] Remove macro guards for extern template instantiations. 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 --- include/llvm/Analysis/DominanceFrontier.h | 4 +-- include/llvm/Analysis/LoopInfo.h | 8 ++---- include/llvm/Analysis/RegionInfo.h | 6 ++--- include/llvm/CodeGen/MachineDominators.h | 4 +-- include/llvm/CodeGen/MachineLoopInfo.h | 9 ++----- include/llvm/CodeGen/MachineRegionInfo.h | 7 +++--- include/llvm/IR/Dominators.h | 20 ++++++--------- include/llvm/Support/CommandLine.h | 28 ++++++++++----------- include/llvm/Support/Compiler.h | 13 ---------- lib/CodeGen/MachineDominators.cpp | 4 +-- lib/IR/Dominators.cpp | 20 ++++++--------- lib/Support/CommandLine.cpp | 30 +++++++++++------------ 12 files changed, 61 insertions(+), 92 deletions(-) diff --git a/include/llvm/Analysis/DominanceFrontier.h b/include/llvm/Analysis/DominanceFrontier.h index 996700efdb6..fb730054a8e 100644 --- a/include/llvm/Analysis/DominanceFrontier.h +++ b/include/llvm/Analysis/DominanceFrontier.h @@ -202,8 +202,8 @@ public: void dump() const; }; -EXTERN_TEMPLATE_INSTANTIATION(class DominanceFrontierBase); -EXTERN_TEMPLATE_INSTANTIATION(class ForwardDominanceFrontierBase); +extern template class DominanceFrontierBase; +extern template class ForwardDominanceFrontierBase; } // End llvm namespace diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index bbcde8d9721..3ec83f2c21f 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -347,9 +347,7 @@ raw_ostream& operator<<(raw_ostream &OS, const LoopBase &Loop) { } // Implementation in LoopInfoImpl.h -#ifdef __GNUC__ -__extension__ extern template class LoopBase; -#endif +extern template class LoopBase; class Loop : public LoopBase { public: @@ -633,9 +631,7 @@ public: }; // Implementation in LoopInfoImpl.h -#ifdef __GNUC__ -__extension__ extern template class LoopInfoBase; -#endif +extern template class LoopInfoBase; class LoopInfo : public LoopInfoBase { typedef LoopInfoBase BaseT; diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h index 7ceb086ee0a..8560f1f6716 100644 --- a/include/llvm/Analysis/RegionInfo.h +++ b/include/llvm/Analysis/RegionInfo.h @@ -902,9 +902,9 @@ inline raw_ostream &operator<<(raw_ostream &OS, return OS << Node.template getNodeAs()->getName(); } -EXTERN_TEMPLATE_INSTANTIATION(class RegionBase>); -EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase>); -EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase>); +extern template class RegionBase>; +extern template class RegionNodeBase>; +extern template class RegionInfoBase>; } // End llvm namespace #endif diff --git a/include/llvm/CodeGen/MachineDominators.h b/include/llvm/CodeGen/MachineDominators.h index 4428fa618fb..735dd069cf7 100644 --- a/include/llvm/CodeGen/MachineDominators.h +++ b/include/llvm/CodeGen/MachineDominators.h @@ -29,8 +29,8 @@ inline void DominatorTreeBase::addRoot(MachineBasicBlock* MBB this->Roots.push_back(MBB); } -EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase); -EXTERN_TEMPLATE_INSTANTIATION(class DominatorTreeBase); +extern template class DomTreeNodeBase; +extern template class DominatorTreeBase; typedef DomTreeNodeBase MachineDomTreeNode; diff --git a/include/llvm/CodeGen/MachineLoopInfo.h b/include/llvm/CodeGen/MachineLoopInfo.h index 438ef2e3725..4868b7363f8 100644 --- a/include/llvm/CodeGen/MachineLoopInfo.h +++ b/include/llvm/CodeGen/MachineLoopInfo.h @@ -37,10 +37,8 @@ namespace llvm { // Implementation in LoopInfoImpl.h -#ifdef __GNUC__ class MachineLoop; -__extension__ extern template class LoopBase; -#endif +extern template class LoopBase; class MachineLoop : public LoopBase { public: @@ -65,10 +63,7 @@ private: }; // Implementation in LoopInfoImpl.h -#ifdef __GNUC__ -__extension__ extern template -class LoopInfoBase; -#endif +extern template class LoopInfoBase; class MachineLoopInfo : public MachineFunctionPass { LoopInfoBase LI; diff --git a/include/llvm/CodeGen/MachineRegionInfo.h b/include/llvm/CodeGen/MachineRegionInfo.h index cf49c297c28..df9823f741d 100644 --- a/include/llvm/CodeGen/MachineRegionInfo.h +++ b/include/llvm/CodeGen/MachineRegionInfo.h @@ -172,10 +172,9 @@ template <> struct GraphTraits } }; -EXTERN_TEMPLATE_INSTANTIATION(class RegionBase>); -EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase>); -EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase>); - +extern template class RegionBase>; +extern template class RegionNodeBase>; +extern template class RegionInfoBase>; } #endif diff --git a/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h index c1f208e3d72..27d989b0344 100644 --- a/include/llvm/IR/Dominators.h +++ b/include/llvm/IR/Dominators.h @@ -36,18 +36,14 @@ namespace llvm { template class AnalysisManager; class PreservedAnalyses; -EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase); -EXTERN_TEMPLATE_INSTANTIATION(class DominatorTreeBase); - -#define LLVM_COMMA , -EXTERN_TEMPLATE_INSTANTIATION(void Calculate( - DominatorTreeBase::NodeType> &DT LLVM_COMMA - Function &F)); -EXTERN_TEMPLATE_INSTANTIATION( - void Calculate >( - DominatorTreeBase >::NodeType> &DT - LLVM_COMMA Function &F)); -#undef LLVM_COMMA +extern template class DomTreeNodeBase; +extern template class DominatorTreeBase; + +extern template void Calculate( + DominatorTreeBase::NodeType> &DT, Function &F); +extern template void Calculate>( + DominatorTreeBase>::NodeType> &DT, + Function &F); typedef DomTreeNodeBase DomTreeNode; diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index ed809211ea9..379d06a6574 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -790,7 +790,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -816,7 +816,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -838,7 +838,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -860,7 +860,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -885,7 +885,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -907,7 +907,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -929,7 +929,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -954,7 +954,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // parser @@ -979,7 +979,7 @@ public: void anchor() override; }; -EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +extern template class basic_parser; //-------------------------------------------------- // PrintOptionDiff @@ -1254,11 +1254,11 @@ public: } }; -EXTERN_TEMPLATE_INSTANTIATION(class opt); -EXTERN_TEMPLATE_INSTANTIATION(class opt); -EXTERN_TEMPLATE_INSTANTIATION(class opt); -EXTERN_TEMPLATE_INSTANTIATION(class opt); -EXTERN_TEMPLATE_INSTANTIATION(class opt); +extern template class opt; +extern template class opt; +extern template class opt; +extern template class opt; +extern template class opt; //===----------------------------------------------------------------------===// // list_storage class diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 67ef23d43c9..141639839cc 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -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); -// in the .cpp file, use this: -// TEMPLATE_INSTANTIATION(class foo); -#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) diff --git a/lib/CodeGen/MachineDominators.cpp b/lib/CodeGen/MachineDominators.cpp index 467a2e4eb42..3f04bb0b532 100644 --- a/lib/CodeGen/MachineDominators.cpp +++ b/lib/CodeGen/MachineDominators.cpp @@ -19,8 +19,8 @@ using namespace llvm; namespace llvm { -TEMPLATE_INSTANTIATION(class DomTreeNodeBase); -TEMPLATE_INSTANTIATION(class DominatorTreeBase); +template class DomTreeNodeBase; +template class DominatorTreeBase; } char MachineDominatorTree::ID = 0; diff --git a/lib/IR/Dominators.cpp b/lib/IR/Dominators.cpp index e3258895ea5..b6a8bbcbe5f 100644 --- a/lib/IR/Dominators.cpp +++ b/lib/IR/Dominators.cpp @@ -62,18 +62,14 @@ bool BasicBlockEdge::isSingleEdge() const { // //===----------------------------------------------------------------------===// -TEMPLATE_INSTANTIATION(class llvm::DomTreeNodeBase); -TEMPLATE_INSTANTIATION(class llvm::DominatorTreeBase); - -#define LLVM_COMMA , -TEMPLATE_INSTANTIATION(void llvm::Calculate( - DominatorTreeBase::NodeType> &DT LLVM_COMMA - Function &F)); -TEMPLATE_INSTANTIATION( - void llvm::Calculate >( - DominatorTreeBase >::NodeType> &DT - LLVM_COMMA Function &F)); -#undef LLVM_COMMA +template class llvm::DomTreeNodeBase; +template class llvm::DominatorTreeBase; + +template void llvm::Calculate( + DominatorTreeBase::NodeType> &DT, Function &F); +template void llvm::Calculate>( + DominatorTreeBase>::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. diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index dcaacf6248d..17fba95ebb2 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -46,21 +46,21 @@ using namespace cl; // namespace llvm { namespace cl { -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); -TEMPLATE_INSTANTIATION(class basic_parser); - -TEMPLATE_INSTANTIATION(class opt); -TEMPLATE_INSTANTIATION(class opt); -TEMPLATE_INSTANTIATION(class opt); -TEMPLATE_INSTANTIATION(class opt); -TEMPLATE_INSTANTIATION(class opt); +template class basic_parser; +template class basic_parser; +template class basic_parser; +template class basic_parser; +template class basic_parser; +template class basic_parser; +template class basic_parser; +template class basic_parser; +template class basic_parser; + +template class opt; +template class opt; +template class opt; +template class opt; +template class opt; } } // end namespace llvm::cl -- 2.34.1