From 4f1bd9e9963239c119db70070db1d68286b3de7e Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 7 Jun 2006 22:00:26 +0000 Subject: For PR780: 1. Fix the macros in IncludeFile.h to put everything in the llvm namespace 2. Replace the previous explicit mechanism in all the .h and .cpp files with the macros in IncludeFile.h This gets us a consistent mechanism throughout LLVM for ensuring linkage. Next step is to make sure its used in enough places. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28715 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/AliasAnalysis.h | 9 ++++----- include/llvm/Analysis/CallGraph.h | 10 +++------- include/llvm/Analysis/Dominators.h | 6 +++--- include/llvm/Analysis/FindUsedTypes.h | 10 +++------- include/llvm/Analysis/LoopInfo.h | 8 +++----- include/llvm/Analysis/PostDominators.h | 10 +++------- include/llvm/Analysis/ValueNumbering.h | 7 +++---- include/llvm/IntrinsicInst.h | 9 ++++----- include/llvm/Support/IncludeFile.h | 8 +++++--- include/llvm/System/IncludeFile.h | 8 +++++--- 10 files changed, 36 insertions(+), 49 deletions(-) (limited to 'include/llvm') diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index d715e0880b..2fff77420a 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -318,14 +318,13 @@ public: } }; +} // End llvm namespace + // Because of the way .a files work, we must force the BasicAA implementation to // be pulled in if the AliasAnalysis header is included. Otherwise we run // the risk of AliasAnalysis being used, but the default implementation not // being linked into the tool that uses it. -// -extern int BasicAAStub; -static IncludeFile HDR_INCLUDE_BASICAA_CPP(&BasicAAStub); - -} // End llvm namespace +FORCE_DEFINING_FILE_TO_BE_LINKED(AliasAnalysis) +FORCE_DEFINING_FILE_TO_BE_LINKED(BasicAliasAnalysis) #endif diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index e51a3c7fb1..94cea10048 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -287,13 +287,9 @@ template<> struct GraphTraits : static nodes_iterator nodes_end (const CallGraph *CG) { return CG->end(); } }; -// Make sure that any clients of this file link in CallGraph.cpp -static IncludeFile -CALLGRAPH_INCLUDE_FILE(&CallGraph::stub); - -extern int BasicCallGraphStub; -static IncludeFile HDR_INCLUDE_CALLGRAPH_CPP(&BasicCallGraphStub); - } // End llvm namespace +// Make sure that any clients of this file link in CallGraph.cpp +FORCE_DEFINING_FILE_TO_BE_LINKED(CallGraph) + #endif diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 224e529915..31b8562f2c 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -652,9 +652,9 @@ private: }; -// Make sure that any clients of this file link in Dominators.cpp -static IncludeFile -DOMINATORS_INCLUDE_FILE(&DominatorSet::stub); } // End llvm namespace +// Make sure that any clients of this file link in Dominators.cpp +FORCE_DEFINING_FILE_TO_BE_LINKED(DominatorSet) + #endif diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index e16fe9d7c3..fbf41de7cb 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -53,15 +53,11 @@ public: virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } - - // stub - dummy function, just ignore it - static int stub; }; -// Make sure that any clients of this file link in PostDominators.cpp -static IncludeFile -FIND_USED_TYPES_INCLUDE_FILE(&FindUsedTypes::stub); - } // End llvm namespace +// Make sure that any clients of this file link in PostDominators.cpp +FORCE_DEFINING_FILE_TO_BE_LINKED(FindUsedTypes) + #endif diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 065ce31d8b..06b007cf3f 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -295,7 +295,6 @@ public: /// BasicBlocks to loops. void removeBlock(BasicBlock *BB); - static int stub; // Noop private: void Calculate(ETForest &EF); Loop *ConsiderForLoop(BasicBlock *BB, ETForest &EF); @@ -304,10 +303,6 @@ private: }; -// Make sure that any clients of this file link in LoopInfo.cpp -static IncludeFile -LOOP_INFO_INCLUDE_FILE(&LoopInfo::stub); - // Allow clients to walk the list of nested loops... template <> struct GraphTraits { typedef const Loop NodeType; @@ -337,4 +332,7 @@ template <> struct GraphTraits { } // End llvm namespace +// Make sure that any clients of this file link in LoopInfo.cpp +FORCE_DEFINING_FILE_TO_BE_LINKED(LoopInfo) + #endif diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index 1436be3037..4d8d140373 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -128,18 +128,14 @@ struct PostDominanceFrontier : public DominanceFrontierBase { AU.addRequired(); } - // stub - dummy function, just ignore it - static int stub; - private: const DomSetType &calculate(const PostDominatorTree &DT, const DominatorTree::Node *Node); }; -// Make sure that any clients of this file link in PostDominators.cpp -static IncludeFile -POST_DOMINATOR_INCLUDE_FILE(&PostDominanceFrontier::stub); - } // End llvm namespace +// Make sure that any clients of this file link in PostDominators.cpp +FORCE_DEFINING_FILE_TO_BE_LINKED(PostDominanceFrontier) + #endif diff --git a/include/llvm/Analysis/ValueNumbering.h b/include/llvm/Analysis/ValueNumbering.h index 2fc949766e..f708f48382 100644 --- a/include/llvm/Analysis/ValueNumbering.h +++ b/include/llvm/Analysis/ValueNumbering.h @@ -65,10 +65,9 @@ struct ValueNumbering { } }; -extern int BasicValueNumberingStub; -static IncludeFile -HDR_INCLUDE_VALUENUMBERING_CPP(&BasicValueNumberingStub); - } // End llvm namespace +// Force any file including this header to get the implementation as well +FORCE_DEFINING_FILE_TO_BE_LINKED(BasicValueNumbering) + #endif diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h index fbc3968f26..5b784fc2b9 100644 --- a/include/llvm/IntrinsicInst.h +++ b/include/llvm/IntrinsicInst.h @@ -314,11 +314,10 @@ namespace llvm { } }; -// A hack to ensure that the IntrinsicInst.cpp file gets added as a dependency -// of any file that -extern char LinkIntrinsicInstStub; -static IncludeFile LinkIntrinsicInst(&LinkIntrinsicInstStub); - } +// Ensure that the IntrinsicInst.cpp file gets added as a dependency of any +// file that includes this header +FORCE_DEFINING_FILE_TO_BE_LINKED(IntrinsicInst) + #endif diff --git a/include/llvm/Support/IncludeFile.h b/include/llvm/Support/IncludeFile.h index 8e96f7571f..798c6b454f 100644 --- a/include/llvm/Support/IncludeFile.h +++ b/include/llvm/Support/IncludeFile.h @@ -27,13 +27,15 @@ /// And, foo.cp would use:
/// DEFINING_FILE_FOR(foo)
#define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \ - extern char name ## LinkVar; \ - static IncludeFile name ## LinkObj ( &name ## LinkVar ) + namespace llvm { \ + extern char name ## LinkVar; \ + static IncludeFile name ## LinkObj ( &name ## LinkVar ); \ + } /// This macro is the counterpart to FORCE_DEFINING_FILE_TO_BE_LINKED. It should /// be used in a .cpp file to define the name referenced in a header file that /// will cause linkage of the .cpp file. It should only be used at extern level. -#define DEFINING_FILE_FOR(name) char name +#define DEFINING_FILE_FOR(name) namespace llvm { char name ## LinkVar; } namespace llvm { diff --git a/include/llvm/System/IncludeFile.h b/include/llvm/System/IncludeFile.h index 8e96f7571f..798c6b454f 100644 --- a/include/llvm/System/IncludeFile.h +++ b/include/llvm/System/IncludeFile.h @@ -27,13 +27,15 @@ /// And, foo.cp would use:
/// DEFINING_FILE_FOR(foo)
#define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \ - extern char name ## LinkVar; \ - static IncludeFile name ## LinkObj ( &name ## LinkVar ) + namespace llvm { \ + extern char name ## LinkVar; \ + static IncludeFile name ## LinkObj ( &name ## LinkVar ); \ + } /// This macro is the counterpart to FORCE_DEFINING_FILE_TO_BE_LINKED. It should /// be used in a .cpp file to define the name referenced in a header file that /// will cause linkage of the .cpp file. It should only be used at extern level. -#define DEFINING_FILE_FOR(name) char name +#define DEFINING_FILE_FOR(name) namespace llvm { char name ## LinkVar; } namespace llvm { -- cgit v1.2.3