diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-12 23:21:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-12 23:21:09 +0000 |
commit | b6acda0f3606fec82a782b8c0e316335696e4b4e (patch) | |
tree | 83587ca83a45dc07a5582a476d2f56496fda08dd /clang/lib/Basic/IdentifierTable.cpp | |
parent | c208f4617c2e1391bf2593492d3c17032fc16366 (diff) | |
download | bcm5719-llvm-b6acda0f3606fec82a782b8c0e316335696e4b4e.tar.gz bcm5719-llvm-b6acda0f3606fec82a782b8c0e316335696e4b4e.zip |
Don't build identifiers for C++ constructors, destructors, or
conversion functions. Instead, we just use a placeholder identifier
for these (e.g., "<constructor>") and override NamedDecl::getName() to
provide a human-readable name.
This is one potential solution to the problem; another solution would
be to replace the use of IdentifierInfo* in NamedDecl with a different
class that deals with identifiers better. I'm also prototyping that to
see how it compares, but this commit is better than what we had
previously.
llvm-svn: 59193
Diffstat (limited to 'clang/lib/Basic/IdentifierTable.cpp')
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 2b9d7e38456..b8684753b2c 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -42,7 +42,8 @@ IdentifierInfo::IdentifierInfo() { IdentifierTable::IdentifierTable(const LangOptions &LangOpts) // Start with space for 8K identifiers. - : HashTable(8192) { + : HashTable(8192), + ConstructorId(0), DestructorId(0), ConversionFunctionId(0) { // Populate the identifier table with info about keywords for the current // language. @@ -51,7 +52,33 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts) } // This cstor is intended to be used only for serialization. -IdentifierTable::IdentifierTable() : HashTable(8192) {} +IdentifierTable::IdentifierTable() + : HashTable(8192), + ConstructorId(0), DestructorId(0), ConversionFunctionId(0) { } + +/// getConstructorId - Return a placeholder identifier for a C++ +/// constructor. +IdentifierInfo &IdentifierTable::getConstructorId() { + if (!ConstructorId) + ConstructorId = &get("<constructor>"); + return *ConstructorId; +} + +/// getDestructorId - Return a placeholder identifier for a C++ +/// destructor. +IdentifierInfo &IdentifierTable::getDestructorId() { + if (!DestructorId) + DestructorId = &get("<destructor>"); + return *DestructorId; +} + +/// getConversionFunctionId - Return a placeholder identifier for a +/// C++ conversion function. +IdentifierInfo &IdentifierTable::getConversionFunctionId() { + if (!ConversionFunctionId) + ConversionFunctionId = &get("<conversion function>"); + return *ConversionFunctionId; +} //===----------------------------------------------------------------------===// // Language Keyword Implementation |