[cfe-dev] Getting Involved, Newbie needs some Instruction

Fabio Fracassi f.fracassi at gmx.net
Fri Jul 3 19:22:35 PDT 2009


(resend message which seems to have been lost 2 days ago)

Hello clang Developers,

I have been interested in the standardisation of the upcomming C++0x for quite 
some time now, and while reading up on it I discovered LLVM and CLang.
I was imediately intrigued by the project, and I'd like to get involved.

So I started reading all the Documentation (short of API-Reference) that I 
could find, and think that I now have a tentative understanding how the 
larger parts fit togher.

Reading the Open Projects and the C++ Status Pages I took on the first 
"project" which looked managable and open, which landed me with 
Pseudo Destructor calls.

The first thing I did was creating a test for the feature, so I created a file 
llvm/tools/clang/test/CXX/expr/expr.post/expr.pseudo/p1.cpp with the following 
content:

 3: int main() {
 4:    typedef int NonClass_type;
 5:
 6:    NonClass_type nc;
 7:    nc.~NonClass_type();
 8:    nc.NonClass_type::~NonClass_type();
 9:
10:    NonClass_type * pNc;
11:    pNc->~NonClass_type();
12:    pNc->NonClass_type::~NonClass_type();
13: }

which probably contain the first mistakes along the way. 
(Do I test everything relevant? Do lines 8 and 12 belong
to paragraph 1?, ... ) 
Anyway, having this test I can clearly see that this feature
is not yet supported, I recive the following output from 
clang-cc -fsyntax-only -verify:

Errors seen but not expected:
  Line 7: expected identifier
  Line 8: member reference base type 'NonClass_type' (aka 'int') is not a 
structure or union
  Line 11: expected identifier
  Line 12: member reference base type 'NonClass_type' (aka 'int') is not a 
structure or union

So searching for these errors I get the source locations where they occur,
and discovered that Line 7 and 11 are not correctly parsed so I changed this 
with the following patch:

===================================================================
--- lib/Parse/ParseExpr.cpp     (revision 74335)
+++ lib/Parse/ParseExpr.cpp     (working copy)
@@ -915,7 +915,8 @@
       tok::TokenKind OpKind = Tok.getKind();
       SourceLocation OpLoc = ConsumeToken();  // Eat the "." or "->" token.

-      if (Tok.isNot(tok::identifier)) {
+      if (Tok.isNot(tok::identifier) && Tok.isNot(tok::tilde)) {
+        // ~ is valid for explicit destructor calls
         Diag(Tok, diag::err_expected_ident);
         return ExprError();
       }

After this rerunning my test I get:

Errors seen but not expected:
  Line 7: member reference base type 'NonClass_type' (aka 'int') is not a 
structure or union
  Line 8: member reference base type 'NonClass_type' (aka 'int') is not a 
structure or union
  Line 11: member reference base type 'NonClass_type' (aka 'int') is not a 
structure or union
  Line 12: member reference base type 'NonClass_type' (aka 'int') is not a 
structure or union

Yay!! First change.

So I guess this is correct, and calling destructors explicitly (pseudo or 
otherwise) should be handled in ActOnMemberReferenceExpr(...) ?

Well this is as far as I got alone, and I need some instruction on how 
to learn what I need to go on. From looking at the code I guess that I need 
to handle a destructor call somewhere between lines 2068 and 2104 in 
lib/Sema/SemaExpr.cpp and add a handler for Destructors somewhere in 
lib/Sema/SemaExprCXX.cpp. But I have no idea what exactly those should look 
like.

Can anybody give me some advice on where I can find some more information,
or explain how I need to go on exploring?

Thanks in advance and regards

Fabio














More information about the cfe-dev mailing list