[cfe-commits] r84394 - /cfe/trunk/include/clang/AST/Decl.h

Daniel Dunbar daniel at zuster.org
Sat Oct 17 19:09:45 PDT 2009


Author: ddunbar
Date: Sat Oct 17 21:09:45 2009
New Revision: 84394

URL: http://llvm.org/viewvc/llvm-project?rev=84394&view=rev
Log:
Add NameDecl::getName() -> StringRef.

Modified:
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=84394&r1=84393&r2=84394&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Oct 17 21:09:45 2009
@@ -96,28 +96,40 @@
   /// 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,





More information about the cfe-commits mailing list