[cfe-commits] r61951 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/StmtPrinter.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaInit.cpp

Douglas Gregor dgregor at apple.com
Thu Jan 8 14:45:41 PST 2009


Author: dgregor
Date: Thu Jan  8 16:45:41 2009
New Revision: 61951

URL: http://llvm.org/viewvc/llvm-project?rev=61951&view=rev
Log:
Revert my previous, failed attempt to pretty-print anonymous struct/union accesses well. Added a FIXME so we know to revisit this later

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Jan  8 16:45:41 2009
@@ -49,21 +49,17 @@
   /// (C++ [temp.dep.constexpr]).
   bool ValueDependent : 1;
 
-  /// Implicit - Whether this expression was implicitly created by the
-  /// implementation, rather than written explicitly by the user.
-  bool Implicit : 1;
-
 protected:
   // FIXME: Eventually, this constructor should go away and we should
   // require every subclass to provide type/value-dependence
   // information.
   Expr(StmtClass SC, QualType T) 
-    : Stmt(SC), TypeDependent(false), ValueDependent(false), Implicit(false) {
+    : Stmt(SC), TypeDependent(false), ValueDependent(false) {
     setType(T); 
   }
 
   Expr(StmtClass SC, QualType T, bool TD, bool VD)
-    : Stmt(SC), TypeDependent(TD), ValueDependent(VD), Implicit(false) {
+    : Stmt(SC), TypeDependent(TD), ValueDependent(VD) {
     setType(T);
   }
 
@@ -105,14 +101,6 @@
   /// @endcode
   bool isTypeDependent() const { return TypeDependent; }
 
-  /// isImplicit - Determines whether this expression was implicitly
-  /// created by the implementation to express the semantics of an
-  /// implicit operation, such as an implicit conversion or implicit
-  /// reference to "this". When false, this expression was written
-  /// directly in the source code.
-  bool isImplicit() const { return Implicit; }
-  void setImplicit(bool I = true) { Implicit = I; }
-
   /// SourceLocation tokens are not useful in isolation - they are low level
   /// value objects created/interpreted by SourceManager. We assume AST
   /// clients will have a pointer to the respective SourceManager.
@@ -996,9 +984,7 @@
 
 public:
   ImplicitCastExpr(QualType ty, Expr *op, bool Lvalue) : 
-    CastExpr(ImplicitCastExprClass, ty, op), LvalueCast(Lvalue) {
-    setImplicit(true);
-  }
+    CastExpr(ImplicitCastExprClass, ty, op), LvalueCast(Lvalue) { }
 
   virtual SourceRange getSourceRange() const {
     return getSubExpr()->getSourceRange();
@@ -1687,7 +1673,9 @@
 
   // Explicit InitListExpr's originate from source code (and have valid source
   // locations). Implicit InitListExpr's are created by the semantic analyzer.
-  bool isExplicit() { return !isImplicit(); }
+  bool isExplicit() {
+    return LBraceLoc.isValid() && RBraceLoc.isValid();
+  }
   
   virtual SourceRange getSourceRange() const {
     return SourceRange(LBraceLoc, RBraceLoc);

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=61951&r1=61950&r2=61951&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jan  8 16:45:41 2009
@@ -757,10 +757,11 @@
   OS << ")";
 }
 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
-  if (!Node->getBase()->isImplicit()) {
-    PrintExpr(Node->getBase());
-    OS << (Node->isArrow() ? "->" : ".");
-  }
+  // FIXME: Suppress printing implicit bases (like "this")
+  PrintExpr(Node->getBase());
+  OS << (Node->isArrow() ? "->" : ".");
+  // FIXME: Suppress printing references to unnamed objects
+  // representing anonymous unions/structs
   OS << Node->getMemberDecl()->getNameAsString();
 }
 void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jan  8 16:45:41 2009
@@ -444,7 +444,6 @@
 
     BaseObjectExpr = new DeclRefExpr(BaseObject, BaseObject->getType(),
                                      SourceLocation());
-    BaseObjectExpr->setImplicit();
     ExtraQuals 
       = Context.getCanonicalType(BaseObject->getType()).getCVRQualifiers();
   } else if (BaseObjectExpr) {
@@ -474,7 +473,6 @@
           BaseObjectExpr = new CXXThisExpr(SourceLocation(),
                                            MD->getThisType(Context));
           BaseObjectIsPointer = true;
-          BaseObjectExpr->setImplicit();
         }
       } else {
         return Diag(Loc, diag::err_invalid_member_use_in_static_method)
@@ -502,7 +500,6 @@
     }
     Result = new MemberExpr(Result, BaseObjectIsPointer, *FI,
                             OpLoc, MemberType);
-    Result->setImplicit();
     BaseObjectIsPointer = false;
     ExtraQuals = Context.getCanonicalType(MemberType).getCVRQualifiers();
     OpLoc = SourceLocation();
@@ -664,7 +661,6 @@
           // Build the implicit member access expression.
           Expr *This = new CXXThisExpr(SourceLocation(),
                                        MD->getThisType(Context));
-          This->setImplicit();
           return new MemberExpr(This, true, cast<NamedDecl>(D), 
                                 SourceLocation(), MemberType);
         }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Jan  8 16:45:41 2009
@@ -90,7 +90,6 @@
                                        &InitExprs[0], InitExprs.size(), 
                                        SourceLocation(),
                                        ParentIList->hadDesignators());
-  ILE->setImplicit();
   ILE->setType(T);
 
   // Modify the parent InitListExpr to point to the implicit InitListExpr.





More information about the cfe-commits mailing list