From cc543b031ee10e2bddc60c645134bcdb355f621b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 13 Feb 2007 07:53:34 +0000 Subject: [PATCH] add a setName variant that takes a null-terminated string. This can be used to avoid std::string allocations in common cases. llvm-svn: 34232 --- include/llvm/Value.h | 2 ++ lib/VMCore/Value.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/llvm/Value.h b/include/llvm/Value.h index be751d5f632..fac596b415c 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -92,6 +92,8 @@ public: void setName(const std::string &name); void setName(const char *Name, unsigned NameLen); + void setName(const char *Name); // Takes a null-terminated string. + /// takeName - transfer the name from V to this value, setting V's name to /// empty. It is an error to call V->takeName(V). diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index ee6f94ad386..c7af9313598 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -122,6 +122,10 @@ void Value::setName(const std::string &name) { setName(&name[0], name.size()); } +void Value::setName(const char *Name) { + setName(Name, Name ? strlen(Name) : 0); +} + void Value::setName(const char *NameStr, unsigned NameLen) { if (NameLen == 0 && !hasName()) return; if (getType() != Type::VoidTy && "Cannot assign a name to void values!");