]> granicus.if.org Git - clang/commitdiff
Update NamedDecl::getName() to work for empty names.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 19 Oct 2009 01:21:12 +0000 (01:21 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 19 Oct 2009 01:21:12 +0000 (01:21 +0000)
 - I'm not sure this is ideal, but otherwise clients must be overly careful when handling decl's which can have empty names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84457 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h

index 55f823f01816ff86fd5e78df02ea29ac633c72c0..72ce0d852cfc55af46cdd06f5de80df080925d25 100644 (file)
@@ -100,8 +100,8 @@ public:
   /// 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()->getName();
+    assert(Name.isIdentifier() && "Name is not a simple identifier");
+    return getIdentifier() ? getIdentifier()->getName() : "";
   }
 
   /// getNameAsCString - Get the name of identifier for this declaration as a
@@ -110,8 +110,8 @@ public:
   //
   // FIXME: Deprecated, move clients to getName().
   const char *getNameAsCString() const {
-    assert(getIdentifier() && "Name is not a simple identifier");
-    return getIdentifier()->getNameStart();
+    assert(Name.isIdentifier() && "Name is not a simple identifier");
+    return getIdentifier() ? getIdentifier()->getNameStart() : "";
   }
 
   /// getNameAsString - Get a human-readable name for the declaration, even if