[cfe-commits] r58866 - in /cfe/trunk: include/clang/AST/DeclBase.h include/clang/Basic/DiagnosticKinds.def lib/Parse/ParseDecl.cpp lib/Sema/SemaDecl.cpp test/SemaCXX/destructor.cpp
Chris Lattner
clattner at apple.com
Mon Nov 10 22:20:12 PST 2008
On Nov 7, 2008, at 2:02 PM, Argiris Kirtzidis wrote:
> Author: akirtzidis
> Date: Fri Nov 7 16:02:30 2008
> New Revision: 58866
>
> URL: http://llvm.org/viewvc/llvm-project?rev=58866&view=rev
> Log:
> Changes in preparation for nested-name-specifiers.
>
> -When parsing declarators, don't depend on "CurScope-
> >isCXXClassScope() == true" for constructors/destructors
> -For C++ member declarations, don't depend on
> "Declarator.getContext() == Declarator::MemberContext"
Hi Argiris,
> +++ cfe/trunk/include/clang/AST/DeclBase.h Fri Nov 7 16:02:30 2008
> @@ -310,6 +310,10 @@
> }
> }
>
> + bool isCXXRecord() const {
> + return DeclKind == Decl::CXXRecord;
> + }
> +
Why do you need this? Why not just use isa<CXXRecordDecl>(D)?
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Nov 7 16:02:30 2008
> @@ -1355,6 +1355,7 @@
> /// conversion-function-id [TODO]
> /// '~' class-name
> /// template-id [TODO]
> +///
> void Parser::ParseDirectDeclarator(Declarator &D) {
> // Parse the first direct-declarator seen.
> if (Tok.is(tok::identifier) && D.mayHaveIdentifier()) {
> @@ -1362,31 +1363,35 @@
> // Determine whether this identifier is a C++ constructor name or
> // a normal identifier.
> if (getLang().CPlusPlus &&
> - CurScope->isCXXClassScope() &&
> Actions.isCurrentClassName(*Tok.getIdentifierInfo(),
> CurScope))
> D.SetConstructor(Actions.isTypeName(*Tok.getIdentifierInfo(),
> CurScope),
> Tok.getIdentifierInfo(), Tok.getLocation());
> else
> D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
> ConsumeToken();
> + } else if (getLang().CPlusPlus &&
> + Tok.is(tok::tilde) && D.mayHaveIdentifier()) {
> // 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());
This is FIXME'd, but this should really be sped up. Relying on
std::string's for this is very slow. This should use SmallString or
something else similar.
Stepping back one level, is cramming a ~ into an identifier really the
right way to go here? Maybe we should use a smart pointer of some
kind instead of relying on IdentifierInfo*? We will eventually need
something richer like this to handle template-id's, right?
-Chris
More information about the cfe-commits
mailing list