[cfe-dev] [PATCH] Avoid redundant NNS qualification in constructor/destructor names.

Enea Zaffanella zaffanella at cs.unipr.it
Fri Jan 13 06:35:12 PST 2012


Please find attached a patch that improves AST representation by
removing redundant name qualifications from C++ constructor/destructor
names used inside Decl and/or Expr nodes.

The rationale of the patch is that the mentioned name qualifications
really belong to the enclosing Decl/Expr nodes and should not be
replicated in the ctor/dtor name itself.

As the patch is only affecting the syntactic aspects of the AST
representation, its application affects no existing testcase.
In order to see the effects of the patch, one can compare the output
obtained by clang using command

    $ clang -cc1 -ast-print ctor-dtor-name.cc


Before the patch (r147790), we obtain the following output (only showing
relevant parts):
[...]
// Bad: ctor-name is ElaboratedType.
inline N::struct A::A() {
[...]
// Bad: dtor-name is ElaboratedType.
    q->A<int>::~A<int>::A<int>();


After applying the patch, we obtain:
[...]
// Good: ctor-name is bare Record
// (qualifier "N::A::" is stored in the CXXConstructorDecl
// and not shown just due to pretty printer)
inline A() {
[...]
// Good: dtor-name is TemplateSpecializationType
// (qualifier "A<int>::" is stored in MemberExpr node)
    q->A<int>::~A<int>();



OK to commit?

Enea.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CtorDtorName.patch
Type: text/x-patch
Size: 10472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120113/fca0429e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctor-dtor-name.cc
Type: text/x-c++src
Size: 221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120113/fca0429e/attachment.cc>


More information about the cfe-dev mailing list