[cfe-commits] r39444 - in /cfe/cfe/trunk: AST/Expr.cpp AST/SemaExpr.cpp Sema/SemaExpr.cpp

Steve Naroff snaroff at apple.com
Wed Jul 11 09:44:29 PDT 2007


Author: snaroff
Date: Wed Jul 11 11:44:28 2007
New Revision: 39444

URL: http://llvm.org/viewvc/llvm-project?rev=39444&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Some minor cleanup (comments, spec refs, simplied some expressions).

Modified:
    cfe/cfe/trunk/AST/Expr.cpp
    cfe/cfe/trunk/AST/SemaExpr.cpp
    cfe/cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Expr.cpp?rev=39444&r1=39443&r2=39444&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Expr.cpp (original)
+++ cfe/cfe/trunk/AST/Expr.cpp Wed Jul 11 11:44:28 2007
@@ -135,23 +135,19 @@
   if (TR->isIncompleteType() && TR->isVoidType())
     return false;
   
-  // now, check the expression
+  // the type looks fine, now check the expression
   switch (getStmtClass()) {
   case StringLiteralClass: // C99 6.5.1p4
     return true;
-  case ArraySubscriptExprClass:
+  case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
     return true;
   case DeclRefExprClass: // C99 6.5.1p2
-    const DeclRefExpr *d = cast<DeclRefExpr>(this);
-    return isa<VarDecl>(d->getDecl());
+    return isa<VarDecl>(cast<DeclRefExpr>(this)->getDecl());
   case MemberExprClass: // C99 6.5.2.3p4
     const MemberExpr *m = cast<MemberExpr>(this);
-    if (m->isArrow())
-      return true;
-    return m->getBase()->isLvalue();
+    return m->isArrow() ? true : m->getBase()->isLvalue();
   case UnaryOperatorClass: // C99 6.5.3p4
-    const UnaryOperator *u = cast<UnaryOperator>(this);
-    return u->getOpcode() == UnaryOperator::Deref;
+    return cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Deref;
   case ParenExprClass: // C99 6.5.1p5
     return cast<ParenExpr>(this)->getSubExpr()->isLvalue();
   default: 

Modified: cfe/cfe/trunk/AST/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaExpr.cpp?rev=39444&r1=39443&r2=39444&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/AST/SemaExpr.cpp Wed Jul 11 11:44:28 2007
@@ -780,9 +780,9 @@
 QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
   Decl *dcl = getPrimaryDeclaration(op);
   
-  if (!op->isLvalue()) { // 
-    if (dcl && isa<FunctionDecl>(dcl))
-      ;  // C99 6.5.3.2p1: Allow function designators.
+  if (!op->isLvalue()) { // C99 6.5.3.2p1
+    if (dcl && isa<FunctionDecl>(dcl)) // allow function designators
+      ;  
     else {
       Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof);
       return QualType();

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

==============================================================================
--- cfe/cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaExpr.cpp Wed Jul 11 11:44:28 2007
@@ -780,9 +780,9 @@
 QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
   Decl *dcl = getPrimaryDeclaration(op);
   
-  if (!op->isLvalue()) { // 
-    if (dcl && isa<FunctionDecl>(dcl))
-      ;  // C99 6.5.3.2p1: Allow function designators.
+  if (!op->isLvalue()) { // C99 6.5.3.2p1
+    if (dcl && isa<FunctionDecl>(dcl)) // allow function designators
+      ;  
     else {
       Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof);
       return QualType();





More information about the cfe-commits mailing list