Add NameDecl::getName() -> StringRef.

llvm-svn: 84394
This commit is contained in:
Daniel Dunbar 2009-10-18 02:09:45 +00:00
parent c04294035f
commit 0013afb6ac
1 changed files with 19 additions and 7 deletions

View File

@ -96,14 +96,33 @@ public:
/// name (C++ constructor, Objective-C selector, etc.).
IdentifierInfo *getIdentifier() const { return Name.getAsIdentifierInfo(); }
/// getName - Get the name of identifier for this declaration as a StringRef.
/// This requires that the declaration have a name and that it be a simple
/// identifier.
llvm::StringRef getName() const {
assert(getIdentifier() && "Name is not a simple identifier");
return getIdentifier()->getNameStr();
}
/// getNameAsCString - Get the name of identifier for this declaration as a
/// C string (const char*). This requires that the declaration have a name
/// and that it be a simple identifier.
//
// FIXME: Deprecated, move clients to getName().
const char *getNameAsCString() const {
assert(getIdentifier() && "Name is not a simple identifier");
return getIdentifier()->getNameStart();
}
/// getNameAsString - Get a human-readable name for the declaration, even if
/// it is one of the special kinds of names (C++ constructor, Objective-C
/// selector, etc). Creating this name requires expensive string
/// manipulation, so it should be called only when performance doesn't matter.
/// For simple declarations, getNameAsCString() should suffice.
//
// FIXME: Deprecated, move clients to getName().
std::string getNameAsString() const { return Name.getAsString(); }
/// getDeclName - Get the actual, stored name of the declaration,
/// which may be a special name.
DeclarationName getDeclName() const { return Name; }
@ -111,13 +130,6 @@ public:
/// \brief Set the name of this declaration.
void setDeclName(DeclarationName N) { Name = N; }
/// getNameAsString - Get a human-readable name for the declaration, even if
/// it is one of the special kinds of names (C++ constructor, Objective-C
/// selector, etc). Creating this name requires expensive string
/// manipulation, so it should be called only when performance doesn't matter.
/// For simple declarations, getNameAsCString() should suffice.
std::string getNameAsString() const { return Name.getAsString(); }
/// getQualifiedNameAsString - Returns human-readable qualified name for
/// declaration, like A::B::i, for i being member of namespace A::B.
/// If declaration is not member of context which can be named (record,