diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-10-19 01:21:12 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-10-19 01:21:12 +0000 |
commit | 45475c696ecfd6d296535adb4723b7ba8817c06c (patch) | |
tree | d73077a2636490a1b08e8447bb3a6887668c92e8 | |
parent | 259e9ccf882d11491ad149aec5e6d7a061c9f938 (diff) |
Update NamedDecl::getName() to work for empty names.
- 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
-rw-r--r-- | include/clang/AST/Decl.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 55f823f018..72ce0d852c 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -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 |