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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59193 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 128df11..9bf10ce 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -705,7 +705,7 @@
CXXConstructorDecl *DefaultCon =
CXXConstructorDecl::Create(Context, ClassDecl,
ClassDecl->getLocation(),
- ClassDecl->getIdentifier(),
+ &Context.Idents.getConstructorId(),
Context.getFunctionType(Context.VoidTy,
0, 0, false, 0),
/*isExplicit=*/false,
@@ -771,7 +771,7 @@
CXXConstructorDecl *CopyConstructor
= CXXConstructorDecl::Create(Context, ClassDecl,
ClassDecl->getLocation(),
- ClassDecl->getIdentifier(),
+ &Context.Idents.getConstructorId(),
Context.getFunctionType(Context.VoidTy,
&ArgType, 1,
false, 0),
@@ -795,12 +795,10 @@
// If a class has no user-declared destructor, a destructor is
// declared implicitly. An implicitly-declared destructor is an
// inline public member of its class.
- std::string DestructorName = "~";
- DestructorName += ClassDecl->getName();
CXXDestructorDecl *Destructor
= CXXDestructorDecl::Create(Context, ClassDecl,
ClassDecl->getLocation(),
- &PP.getIdentifierTable().get(DestructorName),
+ &Context.Idents.getConstructorId(),
Context.getFunctionType(Context.VoidTy,
0, 0, false, 0),
/*isInline=*/true,