[llvm-commits] [llvm] r76893 - in /llvm/trunk: include/llvm/Value.h lib/VMCore/Value.cpp
Daniel Dunbar
daniel at zuster.org
Thu Jul 23 11:50:54 PDT 2009
Author: ddunbar
Date: Thu Jul 23 13:50:53 2009
New Revision: 76893
URL: http://llvm.org/viewvc/llvm-project?rev=76893&view=rev
Log:
Add llvm::Value::getNameRef, for help in API migration.
Modified:
llvm/trunk/include/llvm/Value.h
llvm/trunk/lib/VMCore/Value.cpp
Modified: llvm/trunk/include/llvm/Value.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=76893&r1=76892&r2=76893&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Value.h (original)
+++ llvm/trunk/include/llvm/Value.h Thu Jul 23 13:50:53 2009
@@ -16,6 +16,7 @@
#include "llvm/AbstractTypeUser.h"
#include "llvm/Use.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include <iosfwd>
#include <string>
@@ -129,7 +130,7 @@
/// construct a string, they are very expensive and should be avoided.
std::string getName() const { return getNameStr(); }
std::string getNameStr() const;
-
+ StringRef getNameRef() const;
void setName(const std::string &name);
void setName(const char *Name, unsigned NameLen);
Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=76893&r1=76892&r2=76893&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Thu Jul 23 13:50:53 2009
@@ -178,6 +178,11 @@
Name->getKeyData()+Name->getKeyLength());
}
+StringRef Value::getNameRef() const {
+ if (Name == 0) return StringRef();
+ return StringRef(Name->getKeyData(), Name->getKeyLength());
+}
+
void Value::setName(const std::string &name) {
setName(&name[0], name.size());
}
@@ -238,7 +243,7 @@
}
// Name is changing to something new.
- Name = ST->createValueName(NameStr, NameLen, this);
+ Name = ST->createValueName(StringRef(NameStr, NameLen), this);
}
More information about the llvm-commits
mailing list