aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-10-18 02:09:45 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-10-18 02:09:45 +0000
commitecfa8d2d865a997e2240dd7ea8f939844e347200 (patch)
treedea865c72d4de589db5abcab9edb636c66485cbb
parent2ad3289fffc95399c6e1bae36e2abbee00d3d9b9 (diff)
Add NameDecl::getName() -> StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84394 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Decl.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 19e7519d61..1d44509106 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -96,28 +96,40 @@ 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();
}
- /// getDeclName - Get the actual, stored name of the declaration,
- /// which may be a special name.
- DeclarationName getDeclName() const { return Name; }
-
- /// \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.
+ //
+ // 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; }
+
+ /// \brief Set the name of this declaration.
+ void setDeclName(DeclarationName N) { Name = N; }
+
/// 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,