[cfe-commits] r42001 - in /cfe/trunk: AST/Decl.cpp Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaDecl.cpp Sema/SemaExpr.cpp include/clang/AST/Decl.h

Steve Naroff snaroff at apple.com
Sun Sep 16 09:16:00 PDT 2007


Author: snaroff
Date: Sun Sep 16 11:16:00 2007
New Revision: 42001

URL: http://llvm.org/viewvc/llvm-project?rev=42001&view=rev
Log:
Fixes/tweaks that prevent "defaults-i.m" from compiling.

- Allow classnames as the receiver (removing a FIXME from ParseObjCMessageExpression).
- Added a FIXME to ParseObjCMessageExpression()...we need to return a message expr AST node!


Modified:
    cfe/trunk/AST/Decl.cpp
    cfe/trunk/Parse/ParseObjc.cpp
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=42001&r1=42000&r2=42001&view=diff

==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Sun Sep 16 11:16:00 2007
@@ -28,6 +28,42 @@
 static unsigned nInterfaceDecls = 0;
 static bool StatSwitch = false;
 
+const char *Decl::getDeclKindName() {
+  switch (DeclKind) {
+  default: assert(0 && "Unknown decl kind!");
+  case Typedef:
+    return "Typedef";
+  case Function:
+    return "Function";
+  case BlockVariable:
+    return "BlockVariable";
+  case FileVariable:
+    return "FileVariable";
+  case ParmVariable:
+    return "ParmVariable";
+  case EnumConstant:
+    return "EnumConstant";
+  case ObjcInterface:
+    return "ObjcInterface";
+  case ObjcClass:
+    return "ObjcClass";
+  case ObjcMethod:
+    return "ObjcMethod";
+  case ObjcProtoMethod:
+    return "ObjcProtoMethod";
+  case ObjcProtocol:
+    return "ObjcProtocol";
+  case Struct:
+    return "Struct";
+  case Union:
+    return "Union";
+  case Class:
+    return "Class";
+  case Enum:
+    return "Enum";
+  }
+}
+
 bool Decl::CollectingStats(bool enable) {
   if (enable) StatSwitch = true;
 	return StatSwitch;

Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=42001&r1=42000&r2=42001&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Sun Sep 16 11:16:00 2007
@@ -986,8 +986,11 @@
   assert(Tok.getKind() == tok::l_square && "'[' expected");
   SourceLocation Loc = ConsumeBracket(); // consume '['
   // Parse receiver
-  // FIXME: receiver as type-name/class-name
-  ParseAssignmentExpression();
+  if (Tok.getKind() == tok::identifier &&
+      Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope))
+    ConsumeToken();
+  else
+    ParseAssignmentExpression();
   // Parse objc-selector
   IdentifierInfo *selIdent = ParseObjCSelector();
   if (Tok.getKind() == tok::colon) {
@@ -1024,7 +1027,7 @@
     return 0;
   }
   ConsumeBracket(); // consume ']'
-  return 0;
+  return 0; // FIXME: return a message expr AST!
 }
 
 Parser::ExprResult Parser::ParseObjCStringLiteral() {

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

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Sun Sep 16 11:16:00 2007
@@ -182,7 +182,7 @@
   ScopedDecl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, 
                                SourceLocation IdLoc, Scope *S);  
   ScopedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S);
-  Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
+  ScopedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
                                  Scope *S);
   // Decl attributes - this routine is the top level dispatcher. 
   void HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix,

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42001&r1=42000&r2=42001&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sun Sep 16 11:16:00 2007
@@ -815,8 +815,8 @@
 
 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
-Decl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
-                                     Scope *S) {
+ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, 
+                                           IdentifierInfo &II, Scope *S) {
   if (getLangOptions().C99)  // Extension in C99.
     Diag(Loc, diag::ext_implicit_function_decl, II.getName());
   else  // Legal in C90, but warn about it.
@@ -842,7 +842,7 @@
   while (S->getParent())
     S = S->getParent();
   
-  return static_cast<Decl*>(ActOnDeclarator(S, D, 0));
+  return dyn_cast<ScopedDecl>(static_cast<Decl*>(ActOnDeclarator(S, D, 0)));
 }
 
 

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

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sun Sep 16 11:16:00 2007
@@ -60,7 +60,7 @@
                                            IdentifierInfo &II,
                                            bool HasTrailingLParen) {
   // Could be enum-constant or decl.
-  Decl *D = LookupScopedDecl(&II, Decl::IDNS_Ordinary, Loc, S);
+  ScopedDecl *D = LookupScopedDecl(&II, Decl::IDNS_Ordinary, Loc, S);
   if (D == 0) {
     // Otherwise, this could be an implicitly declared function reference (legal
     // in C90, extension in C99).

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=42001&r1=42000&r2=42001&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sun Sep 16 11:16:00 2007
@@ -68,7 +68,8 @@
 public:
   
   Kind getKind() const { return DeclKind; }
-
+  const char *getDeclKindName();
+  
   /// setInvalidDecl - Indicates the Decl had a semantic error. This
   /// allows for graceful error recovery.
   void setInvalidDecl() { InvalidDecl = 1; }
@@ -83,6 +84,7 @@
     case FileVariable:
     case ParmVariable:
     case EnumConstant:
+    case ObjcInterface:
       return IDNS_Ordinary;
     case Struct:
     case Union:





More information about the cfe-commits mailing list