#include "llvm/Support/Annotation.h"
#include "llvm/Support/ManagedStatic.h"
#include <map>
+#include <cstring>
using namespace llvm;
Annotation::~Annotation() {} // Designed to be subclassed
}
}
-typedef std::map<const std::string, unsigned> IDMapType;
+namespace {
+ class StrCmp {
+ public:
+ bool operator()(const char *a, const char *b) const {
+ return strcmp(a, b) < 0;
+ }
+ };
+}
+
+typedef std::map<const char*, unsigned, StrCmp> IDMapType;
static unsigned IDCounter = 0; // Unique ID counter
// Static member to ensure initialiation on demand.
}
}
-AnnotationID AnnotationManager::getID(const std::string &Name) { // Name -> ID
+AnnotationID AnnotationManager::getID(const char *Name) { // Name -> ID
IDMapType::iterator I = IDMap->find(Name);
if (I == IDMap->end()) {
(*IDMap)[Name] = IDCounter++; // Add a new element
// getID - Name -> ID + registration of a factory function for demand driven
// annotation support.
-AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact,
+AnnotationID AnnotationManager::getID(const char *Name, Factory Fact,
void *Data) {
AnnotationID Result(getID(Name));
registerAnnotationFactory(Result, Fact, Data);
// getName - This function is especially slow, but that's okay because it should
// only be used for debugging.
//
-const std::string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name
+const char *AnnotationManager::getName(AnnotationID ID) { // ID -> Name
IDMapType &TheMap = *IDMap;
for (IDMapType::iterator I = TheMap.begin(); ; ++I) {
assert(I != TheMap.end() && "Annotation ID is unknown!");