]> granicus.if.org Git - clang/commitdiff
Revert my previous, failed attempt to pretty-print anonymous struct/union accesses...
authorDouglas Gregor <dgregor@apple.com>
Thu, 8 Jan 2009 22:45:41 +0000 (22:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 8 Jan 2009 22:45:41 +0000 (22:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61951 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/StmtPrinter.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp

index 812b5ca642e4e60f977a8adab9778a329ea8009d..d1aac8100d9654a7354fea4672e2ddcca37f9364 100644 (file)
@@ -49,21 +49,17 @@ class Expr : public Stmt {
   /// (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 @@ public:
   /// @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 @@ class ImplicitCastExpr : public CastExpr {
 
 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 @@ public:
 
   // 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);
index 7456e8cca9e3be00d3ed2847d44b7b3cedcc01ee..14d30d86739a201671ba2a93a91f4b529b670d2c 100644 (file)
@@ -757,10 +757,11 @@ void StmtPrinter::VisitCallExpr(CallExpr *Call) {
   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) {
index 6db6ea19afd64adee76ce0db0241c21dadb752b3..bf04042ef8a991d56f204dbf7799e74ad96ad7d7 100644 (file)
@@ -444,7 +444,6 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
 
     BaseObjectExpr = new DeclRefExpr(BaseObject, BaseObject->getType(),
                                      SourceLocation());
-    BaseObjectExpr->setImplicit();
     ExtraQuals 
       = Context.getCanonicalType(BaseObject->getType()).getCVRQualifiers();
   } else if (BaseObjectExpr) {
@@ -474,7 +473,6 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
           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 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
     }
     Result = new MemberExpr(Result, BaseObjectIsPointer, *FI,
                             OpLoc, MemberType);
-    Result->setImplicit();
     BaseObjectIsPointer = false;
     ExtraQuals = Context.getCanonicalType(MemberType).getCVRQualifiers();
     OpLoc = SourceLocation();
@@ -664,7 +661,6 @@ Sema::ExprResult Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
           // 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);
         }
index 6a9275fbe8a649f285c75de631111ff7ba74bacc..031fe27ddf7515779852a85367c8a6fb8bd5b1ec 100644 (file)
@@ -90,7 +90,6 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
                                        &InitExprs[0], InitExprs.size(), 
                                        SourceLocation(),
                                        ParentIList->hadDesignators());
-  ILE->setImplicit();
   ILE->setType(T);
 
   // Modify the parent InitListExpr to point to the implicit InitListExpr.