diff options
author | Chris Lattner <sabre@nondot.org> | 2001-08-27 05:19:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-08-27 05:19:10 +0000 |
commit | f93e63a189fa18d7ea74f53185379b393c02b3ae (patch) | |
tree | 371d92c9b45e2bcba59d0d70bd75b4a0e252ed08 | |
parent | 827c2a1d7ccc156cb0d74de584f9b8738cbe9aa2 (diff) | |
download | bcm5719-llvm-f93e63a189fa18d7ea74f53185379b393c02b3ae.tar.gz bcm5719-llvm-f93e63a189fa18d7ea74f53185379b393c02b3ae.zip |
Support passing a data pointer to annotation factory methods
llvm-svn: 376
-rw-r--r-- | llvm/lib/Support/Annotation.cpp | 11 | ||||
-rw-r--r-- | llvm/support/lib/Support/Annotation.cpp | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/Support/Annotation.cpp b/llvm/lib/Support/Annotation.cpp index 735d01b7824..e9866207894 100644 --- a/llvm/lib/Support/Annotation.cpp +++ b/llvm/lib/Support/Annotation.cpp @@ -14,8 +14,8 @@ static unsigned IDCounter = 0; // Unique ID counter static IDMapType &getIDMap() { static IDMapType TheMap; return TheMap; } // On demand annotation creation support... -typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *); -typedef map<unsigned, AnnFactory> FactMapType; +typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *, void *); +typedef map<unsigned, pair<AnnFactory,void*> > FactMapType; static FactMapType &getFactMap() { static FactMapType FactMap; return FactMap; } @@ -45,9 +45,10 @@ const string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name // Annotable::findOrCreateAnnotation method. // void AnnotationManager::registerAnnotationFactory(AnnotationID ID, - AnnFactory F) { + AnnFactory F, + void *ExtraData) { if (F) - getFactMap()[ID.ID] = F; + getFactMap()[ID.ID] = make_pair(F, ExtraData); else getFactMap().erase(ID.ID); } @@ -59,5 +60,5 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID, Annotable *Obj) { FactMapType::iterator I = getFactMap().find(ID.ID); if (I == getFactMap().end()) return 0; - return I->second(ID, Obj); + return I->second.first(ID, Obj, I->second.second); } diff --git a/llvm/support/lib/Support/Annotation.cpp b/llvm/support/lib/Support/Annotation.cpp index 735d01b7824..e9866207894 100644 --- a/llvm/support/lib/Support/Annotation.cpp +++ b/llvm/support/lib/Support/Annotation.cpp @@ -14,8 +14,8 @@ static unsigned IDCounter = 0; // Unique ID counter static IDMapType &getIDMap() { static IDMapType TheMap; return TheMap; } // On demand annotation creation support... -typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *); -typedef map<unsigned, AnnFactory> FactMapType; +typedef Annotation *(*AnnFactory)(AnnotationID, Annotable *, void *); +typedef map<unsigned, pair<AnnFactory,void*> > FactMapType; static FactMapType &getFactMap() { static FactMapType FactMap; return FactMap; } @@ -45,9 +45,10 @@ const string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name // Annotable::findOrCreateAnnotation method. // void AnnotationManager::registerAnnotationFactory(AnnotationID ID, - AnnFactory F) { + AnnFactory F, + void *ExtraData) { if (F) - getFactMap()[ID.ID] = F; + getFactMap()[ID.ID] = make_pair(F, ExtraData); else getFactMap().erase(ID.ID); } @@ -59,5 +60,5 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID, Annotable *Obj) { FactMapType::iterator I = getFactMap().find(ID.ID); if (I == getFactMap().end()) return 0; - return I->second(ID, Obj); + return I->second.first(ID, Obj, I->second.second); } |