[cfe-commits] r80055 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseExpr.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp

Anders Carlsson andersca at mac.com
Tue Aug 25 16:46:41 PDT 2009


Author: andersca
Date: Tue Aug 25 18:46:41 2009
New Revision: 80055

URL: http://llvm.org/viewvc/llvm-project?rev=80055&view=rev
Log:
Parsing of pseudo-destructors.

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=80055&r1=80054&r2=80055&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Aug 25 18:46:41 2009
@@ -1263,7 +1263,16 @@
     return ExprEmpty();
   }
 
-
+  virtual OwningExprResult
+  ActOnPseudoDtorReferenceExpr(Scope *S, ExprArg Base,
+                               SourceLocation OpLoc,
+                               tok::TokenKind OpKind,
+                               SourceLocation ClassNameLoc,
+                               IdentifierInfo *ClassName,
+                               const CXXScopeSpec *SS = 0) {
+    return ExprEmpty();
+  }
+  
   /// ActOnFinishFullExpr - Called whenever a full expression has been parsed.
   /// (C++ [intro.execution]p12).
   virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr) {

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=80055&r1=80054&r2=80055&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Aug 25 18:46:41 2009
@@ -933,18 +933,34 @@
         ParseOptionalCXXScopeSpecifier(SS);
       }
 
-      if (Tok.isNot(tok::identifier)) {
+      if (Tok.is(tok::identifier)) {
+        if (!LHS.isInvalid())
+          LHS = Actions.ActOnMemberReferenceExpr(CurScope, move(LHS), OpLoc,
+                                                 OpKind, Tok.getLocation(),
+                                                 *Tok.getIdentifierInfo(),
+                                                 ObjCImpDecl, &SS);
+      } else if (getLang().CPlusPlus && Tok.is(tok::tilde)) {
+        // We have a C++ pseudo-destructor.
+        
+        // Consume the tilde.
+        ConsumeToken();
+        
+        if (!Tok.is(tok::identifier)) {
+          Diag(Tok, diag::err_expected_ident);
+          return ExprError();
+        }
+        
+        if (!LHS.isInvalid())
+          LHS = Actions.ActOnPseudoDtorReferenceExpr(CurScope, move(LHS), 
+                                                     OpLoc, OpKind,
+                                                     Tok.getLocation(), 
+                                                     Tok.getIdentifierInfo(),
+                                                     &SS);
+      } else {
         Diag(Tok, diag::err_expected_ident);
         return ExprError();
       }
 
-      if (!LHS.isInvalid()) {
-        LHS = Actions.ActOnMemberReferenceExpr(CurScope, move(LHS), OpLoc,
-                                               OpKind, Tok.getLocation(),
-                                               *Tok.getIdentifierInfo(),
-                                               ObjCImpDecl, &SS);
-      }
-
       if (getLang().CPlusPlus)
         Actions.ActOnCXXExitMemberScope(CurScope, MemberSS);
 

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=80055&r1=80054&r2=80055&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug 25 18:46:41 2009
@@ -1921,6 +1921,14 @@
                                                TypeTy *Ty,
                                                SourceLocation RParen);
 
+  virtual OwningExprResult
+  ActOnPseudoDtorReferenceExpr(Scope *S, ExprArg Base,
+                               SourceLocation OpLoc,
+                               tok::TokenKind OpKind,
+                               SourceLocation ClassNameLoc,
+                               IdentifierInfo *ClassName,
+                               const CXXScopeSpec *SS = 0);
+  
   /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is 
   /// non-empty, will create a new CXXExprWithTemporaries expression.
   /// Otherwise, just returs the passed in expression.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=80055&r1=80054&r2=80055&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 25 18:46:41 2009
@@ -1958,7 +1958,6 @@
                                tok::TokenKind OpKind, SourceLocation MemberLoc,
                                IdentifierInfo &Member,
                                DeclPtrTy ObjCImpDecl, const CXXScopeSpec *SS) {
-  // FIXME: handle the CXXScopeSpec for proper lookup of qualified-ids
   if (SS && SS->isInvalid())
     return ExprError();
 

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=80055&r1=80054&r2=80055&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug 25 18:46:41 2009
@@ -1682,11 +1682,35 @@
   return E;
 }
 
+Sema::OwningExprResult
+Sema::ActOnPseudoDtorReferenceExpr(Scope *S, ExprArg Base,
+                                   SourceLocation OpLoc,
+                                   tok::TokenKind OpKind,
+                                   SourceLocation ClassNameLoc,
+                                   IdentifierInfo *ClassName,
+                                   const CXXScopeSpec *SS) {
+  if (SS && SS->isInvalid())
+    return ExprError();
+  
+  // Since this might be a postfix expression, get rid of ParenListExprs.
+  Base = MaybeConvertParenListExprToParenExpr(S, move(Base));
+  
+  Expr *BaseExpr = Base.takeAs<Expr>();
+  assert(BaseExpr && "no record expression");
+  
+  // Perform default conversions.
+  DefaultFunctionArrayConversion(BaseExpr);
+  
+  QualType BaseType = BaseExpr->getType();
+  return ExprError();
+}
+
 Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) {
   Expr *FullExpr = Arg.takeAs<Expr>();
   if (FullExpr)
     FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr, 
                                                  /*ShouldDestroyTemps=*/true);
 
+
   return Owned(FullExpr);
 }





More information about the cfe-commits mailing list