Skip to content

Commit a667d1a

Browse files
committed
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. llvm-svn: 242042
1 parent e448b5b commit a667d1a

12 files changed

+61
-92
lines changed

Diff for: llvm/include/llvm/Analysis/DominanceFrontier.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ class DominanceFrontier : public FunctionPass {
202202
void dump() const;
203203
};
204204

205-
EXTERN_TEMPLATE_INSTANTIATION(class DominanceFrontierBase<BasicBlock>);
206-
EXTERN_TEMPLATE_INSTANTIATION(class ForwardDominanceFrontierBase<BasicBlock>);
205+
extern template class DominanceFrontierBase<BasicBlock>;
206+
extern template class ForwardDominanceFrontierBase<BasicBlock>;
207207

208208
} // End llvm namespace
209209

Diff for: llvm/include/llvm/Analysis/LoopInfo.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ raw_ostream& operator<<(raw_ostream &OS, const LoopBase<BlockT, LoopT> &Loop) {
347347
}
348348

349349
// Implementation in LoopInfoImpl.h
350-
#ifdef __GNUC__
351-
__extension__ extern template class LoopBase<BasicBlock, Loop>;
352-
#endif
350+
extern template class LoopBase<BasicBlock, Loop>;
353351

354352
class Loop : public LoopBase<BasicBlock, Loop> {
355353
public:
@@ -633,9 +631,7 @@ class LoopInfoBase {
633631
};
634632

635633
// Implementation in LoopInfoImpl.h
636-
#ifdef __GNUC__
637-
__extension__ extern template class LoopInfoBase<BasicBlock, Loop>;
638-
#endif
634+
extern template class LoopInfoBase<BasicBlock, Loop>;
639635

640636
class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
641637
typedef LoopInfoBase<BasicBlock, Loop> BaseT;

Diff for: llvm/include/llvm/Analysis/RegionInfo.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,9 @@ inline raw_ostream &operator<<(raw_ostream &OS,
902902
return OS << Node.template getNodeAs<BlockT>()->getName();
903903
}
904904

905-
EXTERN_TEMPLATE_INSTANTIATION(class RegionBase<RegionTraits<Function>>);
906-
EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase<RegionTraits<Function>>);
907-
EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase<RegionTraits<Function>>);
905+
extern template class RegionBase<RegionTraits<Function>>;
906+
extern template class RegionNodeBase<RegionTraits<Function>>;
907+
extern template class RegionInfoBase<RegionTraits<Function>>;
908908

909909
} // End llvm namespace
910910
#endif

Diff for: llvm/include/llvm/CodeGen/MachineDominators.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ inline void DominatorTreeBase<MachineBasicBlock>::addRoot(MachineBasicBlock* MBB
2929
this->Roots.push_back(MBB);
3030
}
3131

32-
EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
33-
EXTERN_TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
32+
extern template class DomTreeNodeBase<MachineBasicBlock>;
33+
extern template class DominatorTreeBase<MachineBasicBlock>;
3434

3535
typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode;
3636

Diff for: llvm/include/llvm/CodeGen/MachineLoopInfo.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
namespace llvm {
3838

3939
// Implementation in LoopInfoImpl.h
40-
#ifdef __GNUC__
4140
class MachineLoop;
42-
__extension__ extern template class LoopBase<MachineBasicBlock, MachineLoop>;
43-
#endif
41+
extern template class LoopBase<MachineBasicBlock, MachineLoop>;
4442

4543
class MachineLoop : public LoopBase<MachineBasicBlock, MachineLoop> {
4644
public:
@@ -65,10 +63,7 @@ class MachineLoop : public LoopBase<MachineBasicBlock, MachineLoop> {
6563
};
6664

6765
// Implementation in LoopInfoImpl.h
68-
#ifdef __GNUC__
69-
__extension__ extern template
70-
class LoopInfoBase<MachineBasicBlock, MachineLoop>;
71-
#endif
66+
extern template class LoopInfoBase<MachineBasicBlock, MachineLoop>;
7267

7368
class MachineLoopInfo : public MachineFunctionPass {
7469
LoopInfoBase<MachineBasicBlock, MachineLoop> LI;

Diff for: llvm/include/llvm/CodeGen/MachineRegionInfo.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,9 @@ template <> struct GraphTraits<MachineRegionInfoPass*>
172172
}
173173
};
174174

175-
EXTERN_TEMPLATE_INSTANTIATION(class RegionBase<RegionTraits<MachineFunction>>);
176-
EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase<RegionTraits<MachineFunction>>);
177-
EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase<RegionTraits<MachineFunction>>);
178-
175+
extern template class RegionBase<RegionTraits<MachineFunction>>;
176+
extern template class RegionNodeBase<RegionTraits<MachineFunction>>;
177+
extern template class RegionInfoBase<RegionTraits<MachineFunction>>;
179178
}
180179

181180
#endif

Diff for: llvm/include/llvm/IR/Dominators.h

+8-12
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,14 @@ namespace llvm {
3636
template <typename IRUnitT> class AnalysisManager;
3737
class PreservedAnalyses;
3838

39-
EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase<BasicBlock>);
40-
EXTERN_TEMPLATE_INSTANTIATION(class DominatorTreeBase<BasicBlock>);
41-
42-
#define LLVM_COMMA ,
43-
EXTERN_TEMPLATE_INSTANTIATION(void Calculate<Function LLVM_COMMA BasicBlock *>(
44-
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT LLVM_COMMA
45-
Function &F));
46-
EXTERN_TEMPLATE_INSTANTIATION(
47-
void Calculate<Function LLVM_COMMA Inverse<BasicBlock *> >(
48-
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *> >::NodeType> &DT
49-
LLVM_COMMA Function &F));
50-
#undef LLVM_COMMA
39+
extern template class DomTreeNodeBase<BasicBlock>;
40+
extern template class DominatorTreeBase<BasicBlock>;
41+
42+
extern template void Calculate<Function, BasicBlock *>(
43+
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT, Function &F);
44+
extern template void Calculate<Function, Inverse<BasicBlock *>>(
45+
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *>>::NodeType> &DT,
46+
Function &F);
5147

5248
typedef DomTreeNodeBase<BasicBlock> DomTreeNode;
5349

Diff for: llvm/include/llvm/Support/CommandLine.h

+14-14
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ template <> class parser<bool> final : public basic_parser<bool> {
790790
void anchor() override;
791791
};
792792

793-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<bool>);
793+
extern template class basic_parser<bool>;
794794

795795
//--------------------------------------------------
796796
// parser<boolOrDefault>
@@ -816,7 +816,7 @@ class parser<boolOrDefault> final : public basic_parser<boolOrDefault> {
816816
void anchor() override;
817817
};
818818

819-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
819+
extern template class basic_parser<boolOrDefault>;
820820

821821
//--------------------------------------------------
822822
// parser<int>
@@ -838,7 +838,7 @@ template <> class parser<int> final : public basic_parser<int> {
838838
void anchor() override;
839839
};
840840

841-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<int>);
841+
extern template class basic_parser<int>;
842842

843843
//--------------------------------------------------
844844
// parser<unsigned>
@@ -860,7 +860,7 @@ template <> class parser<unsigned> final : public basic_parser<unsigned> {
860860
void anchor() override;
861861
};
862862

863-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned>);
863+
extern template class basic_parser<unsigned>;
864864

865865
//--------------------------------------------------
866866
// parser<unsigned long long>
@@ -885,7 +885,7 @@ class parser<unsigned long long> final
885885
void anchor() override;
886886
};
887887

888-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>);
888+
extern template class basic_parser<unsigned long long>;
889889

890890
//--------------------------------------------------
891891
// parser<double>
@@ -907,7 +907,7 @@ template <> class parser<double> final : public basic_parser<double> {
907907
void anchor() override;
908908
};
909909

910-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<double>);
910+
extern template class basic_parser<double>;
911911

912912
//--------------------------------------------------
913913
// parser<float>
@@ -929,7 +929,7 @@ template <> class parser<float> final : public basic_parser<float> {
929929
void anchor() override;
930930
};
931931

932-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<float>);
932+
extern template class basic_parser<float>;
933933

934934
//--------------------------------------------------
935935
// parser<std::string>
@@ -954,7 +954,7 @@ template <> class parser<std::string> final : public basic_parser<std::string> {
954954
void anchor() override;
955955
};
956956

957-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<std::string>);
957+
extern template class basic_parser<std::string>;
958958

959959
//--------------------------------------------------
960960
// parser<char>
@@ -979,7 +979,7 @@ template <> class parser<char> final : public basic_parser<char> {
979979
void anchor() override;
980980
};
981981

982-
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<char>);
982+
extern template class basic_parser<char>;
983983

984984
//--------------------------------------------------
985985
// PrintOptionDiff
@@ -1254,11 +1254,11 @@ class opt : public Option,
12541254
}
12551255
};
12561256

1257-
EXTERN_TEMPLATE_INSTANTIATION(class opt<unsigned>);
1258-
EXTERN_TEMPLATE_INSTANTIATION(class opt<int>);
1259-
EXTERN_TEMPLATE_INSTANTIATION(class opt<std::string>);
1260-
EXTERN_TEMPLATE_INSTANTIATION(class opt<char>);
1261-
EXTERN_TEMPLATE_INSTANTIATION(class opt<bool>);
1257+
extern template class opt<unsigned>;
1258+
extern template class opt<int>;
1259+
extern template class opt<std::string>;
1260+
extern template class opt<char>;
1261+
extern template class opt<bool>;
12621262

12631263
//===----------------------------------------------------------------------===//
12641264
// list_storage class

Diff for: llvm/include/llvm/Support/Compiler.h

-13
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,6 @@
174174
#define LLVM_UNLIKELY(EXPR) (EXPR)
175175
#endif
176176

177-
// C++ doesn't support 'extern template' of template specializations. GCC does,
178-
// but requires __extension__ before it. In the header, use this:
179-
// EXTERN_TEMPLATE_INSTANTIATION(class foo<bar>);
180-
// in the .cpp file, use this:
181-
// TEMPLATE_INSTANTIATION(class foo<bar>);
182-
#ifdef __GNUC__
183-
#define EXTERN_TEMPLATE_INSTANTIATION(X) __extension__ extern template X
184-
#define TEMPLATE_INSTANTIATION(X) template X
185-
#else
186-
#define EXTERN_TEMPLATE_INSTANTIATION(X)
187-
#define TEMPLATE_INSTANTIATION(X)
188-
#endif
189-
190177
/// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so,
191178
/// mark a method "not for inlining".
192179
#if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0)

Diff for: llvm/lib/CodeGen/MachineDominators.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
using namespace llvm;
2020

2121
namespace llvm {
22-
TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
23-
TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
22+
template class DomTreeNodeBase<MachineBasicBlock>;
23+
template class DominatorTreeBase<MachineBasicBlock>;
2424
}
2525

2626
char MachineDominatorTree::ID = 0;

Diff for: llvm/lib/IR/Dominators.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,14 @@ bool BasicBlockEdge::isSingleEdge() const {
6262
//
6363
//===----------------------------------------------------------------------===//
6464

65-
TEMPLATE_INSTANTIATION(class llvm::DomTreeNodeBase<BasicBlock>);
66-
TEMPLATE_INSTANTIATION(class llvm::DominatorTreeBase<BasicBlock>);
67-
68-
#define LLVM_COMMA ,
69-
TEMPLATE_INSTANTIATION(void llvm::Calculate<Function LLVM_COMMA BasicBlock *>(
70-
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT LLVM_COMMA
71-
Function &F));
72-
TEMPLATE_INSTANTIATION(
73-
void llvm::Calculate<Function LLVM_COMMA Inverse<BasicBlock *> >(
74-
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *> >::NodeType> &DT
75-
LLVM_COMMA Function &F));
76-
#undef LLVM_COMMA
65+
template class llvm::DomTreeNodeBase<BasicBlock>;
66+
template class llvm::DominatorTreeBase<BasicBlock>;
67+
68+
template void llvm::Calculate<Function, BasicBlock *>(
69+
DominatorTreeBase<GraphTraits<BasicBlock *>::NodeType> &DT, Function &F);
70+
template void llvm::Calculate<Function, Inverse<BasicBlock *>>(
71+
DominatorTreeBase<GraphTraits<Inverse<BasicBlock *>>::NodeType> &DT,
72+
Function &F);
7773

7874
// dominates - Return true if Def dominates a use in User. This performs
7975
// the special checks necessary if Def and User are in the same basic block.

Diff for: llvm/lib/Support/CommandLine.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ using namespace cl;
4646
//
4747
namespace llvm {
4848
namespace cl {
49-
TEMPLATE_INSTANTIATION(class basic_parser<bool>);
50-
TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
51-
TEMPLATE_INSTANTIATION(class basic_parser<int>);
52-
TEMPLATE_INSTANTIATION(class basic_parser<unsigned>);
53-
TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>);
54-
TEMPLATE_INSTANTIATION(class basic_parser<double>);
55-
TEMPLATE_INSTANTIATION(class basic_parser<float>);
56-
TEMPLATE_INSTANTIATION(class basic_parser<std::string>);
57-
TEMPLATE_INSTANTIATION(class basic_parser<char>);
58-
59-
TEMPLATE_INSTANTIATION(class opt<unsigned>);
60-
TEMPLATE_INSTANTIATION(class opt<int>);
61-
TEMPLATE_INSTANTIATION(class opt<std::string>);
62-
TEMPLATE_INSTANTIATION(class opt<char>);
63-
TEMPLATE_INSTANTIATION(class opt<bool>);
49+
template class basic_parser<bool>;
50+
template class basic_parser<boolOrDefault>;
51+
template class basic_parser<int>;
52+
template class basic_parser<unsigned>;
53+
template class basic_parser<unsigned long long>;
54+
template class basic_parser<double>;
55+
template class basic_parser<float>;
56+
template class basic_parser<std::string>;
57+
template class basic_parser<char>;
58+
59+
template class opt<unsigned>;
60+
template class opt<int>;
61+
template class opt<std::string>;
62+
template class opt<char>;
63+
template class opt<bool>;
6464
}
6565
} // end namespace llvm::cl
6666

0 commit comments

Comments
 (0)