aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-01-13 00:52:43 +0000
committerChris Lattner <sabre@nondot.org>2003-01-13 00:52:43 +0000
commit3fa61eb199e642d18b9bba837225b16e1d9ecbb2 (patch)
treece1f981f3df29db4b2e319d946f2806f468ad728
parent3cf5db73c7382c7236256779513fdeb1075f2f16 (diff)
downloadexternal_llvm-3fa61eb199e642d18b9bba837225b16e1d9ecbb2.zip
external_llvm-3fa61eb199e642d18b9bba837225b16e1d9ecbb2.tar.gz
external_llvm-3fa61eb199e642d18b9bba837225b16e1d9ecbb2.tar.bz2
Fix static initializer ordering dependency
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5236 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/Annotation.cpp19
-rw-r--r--support/lib/Support/Annotation.cpp19
2 files changed, 34 insertions, 4 deletions
diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp
index e876bf4..96ead52 100644
--- a/lib/Support/Annotation.cpp
+++ b/lib/Support/Annotation.cpp
@@ -20,7 +20,22 @@ static IDMapType &getIDMap() { static IDMapType TheMap; return TheMap; }
// On demand annotation creation support...
typedef Annotation *(*AnnFactory)(AnnotationID, const Annotable *, void *);
typedef map<unsigned, pair<AnnFactory,void*> > FactMapType;
-static FactMapType &getFactMap() { static FactMapType FactMap; return FactMap; }
+
+static FactMapType *TheFactMap = 0;
+static FactMapType &getFactMap() {
+ if (TheFactMap == 0)
+ TheFactMap = new FactMapType();
+ return *TheFactMap;
+}
+
+static void eraseFromFactMap(unsigned ID) {
+ assert(TheFactMap && "No entries found!");
+ TheFactMap->erase(ID);
+ if (TheFactMap->empty()) { // Delete when empty
+ delete TheFactMap;
+ TheFactMap = 0;
+ }
+}
AnnotationID AnnotationManager::getID(const string &Name) { // Name -> ID
@@ -64,7 +79,7 @@ void AnnotationManager::registerAnnotationFactory(AnnotationID ID,
if (F)
getFactMap()[ID.ID] = make_pair(F, ExtraData);
else
- getFactMap().erase(ID.ID);
+ eraseFromFactMap(ID.ID);
}
// createAnnotation - Create an annotation of the specified ID for the
diff --git a/support/lib/Support/Annotation.cpp b/support/lib/Support/Annotation.cpp
index e876bf4..96ead52 100644
--- a/support/lib/Support/Annotation.cpp
+++ b/support/lib/Support/Annotation.cpp
@@ -20,7 +20,22 @@ static IDMapType &getIDMap() { static IDMapType TheMap; return TheMap; }
// On demand annotation creation support...
typedef Annotation *(*AnnFactory)(AnnotationID, const Annotable *, void *);
typedef map<unsigned, pair<AnnFactory,void*> > FactMapType;
-static FactMapType &getFactMap() { static FactMapType FactMap; return FactMap; }
+
+static FactMapType *TheFactMap = 0;
+static FactMapType &getFactMap() {
+ if (TheFactMap == 0)
+ TheFactMap = new FactMapType();
+ return *TheFactMap;
+}
+
+static void eraseFromFactMap(unsigned ID) {
+ assert(TheFactMap && "No entries found!");
+ TheFactMap->erase(ID);
+ if (TheFactMap->empty()) { // Delete when empty
+ delete TheFactMap;
+ TheFactMap = 0;
+ }
+}
AnnotationID AnnotationManager::getID(const string &Name) { // Name -> ID
@@ -64,7 +79,7 @@ void AnnotationManager::registerAnnotationFactory(AnnotationID ID,
if (F)
getFactMap()[ID.ID] = make_pair(F, ExtraData);
else
- getFactMap().erase(ID.ID);
+ eraseFromFactMap(ID.ID);
}
// createAnnotation - Create an annotation of the specified ID for the