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 | 7d7e6727a5de032c86dcb58ae734e7c1603c26e6 (patch) | |
tree | 0c542ae5d737114b92f73e8291c51903e8c0b74b /lib/Parse/ParseDecl.cpp | |
parent | b7c3ca8af0a1a3b66fb220562c72dd3102153d5b (diff) |
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
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 70d65f3b48..0c1080a5b8 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1437,7 +1437,8 @@ void Parser::ParseDirectDeclarator(Declarator &D) { if (getLang().CPlusPlus && Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope)) D.SetConstructor(Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope), - Tok.getIdentifierInfo(), Tok.getLocation()); + &PP.getIdentifierTable().getConstructorId(), + Tok.getLocation()); else D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation()); ConsumeToken(); @@ -1446,18 +1447,9 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // This should be a C++ destructor. SourceLocation TildeLoc = ConsumeToken(); if (Tok.is(tok::identifier)) { - // Use the next identifier and "~" to form a name for the - // destructor. This is useful both for diagnostics and for - // correctness of the parser, since we use presence/absence of the - // identifier to determine what we parsed. - // FIXME: We could end up with a template-id here, once we parse - // templates, and will have to do something different to form the - // name of the destructor. - IdentifierInfo *II = Tok.getIdentifierInfo(); - II = &PP.getIdentifierTable().get(std::string("~") + II->getName()); - if (TypeTy *Type = ParseClassName()) - D.SetDestructor(Type, II, TildeLoc); + D.SetDestructor(Type, &PP.getIdentifierTable().getDestructorId(), + TildeLoc); else D.SetIdentifier(0, TildeLoc); } else { @@ -1473,10 +1465,9 @@ void Parser::ParseDirectDeclarator(Declarator &D) { } else { // This must be a conversion function (C++ [class.conv.fct]). if (TypeTy *ConvType = ParseConversionFunctionId()) { - IdentifierInfo *II - = &PP.getIdentifierTable().get(std::string("operator ") + - Actions.getTypeAsString(ConvType)); - D.SetConversionFunction(ConvType, II, OperatorLoc); + D.SetConversionFunction(ConvType, + &PP.getIdentifierTable().getConversionFunctionId(), + OperatorLoc); } } } else if (Tok.is(tok::l_paren) && SS.isEmpty()) { |