Fix printing of member references to avoid displaying implicitly-generated member references, e.g., for anonymous struct/unions or implicit 'this' in member functions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61885 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index bf04042..6db6ea1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -444,6 +444,7 @@
 
     BaseObjectExpr = new DeclRefExpr(BaseObject, BaseObject->getType(),
                                      SourceLocation());
+    BaseObjectExpr->setImplicit();
     ExtraQuals 
       = Context.getCanonicalType(BaseObject->getType()).getCVRQualifiers();
   } else if (BaseObjectExpr) {
@@ -473,6 +474,7 @@
           BaseObjectExpr = new CXXThisExpr(SourceLocation(),
                                            MD->getThisType(Context));
           BaseObjectIsPointer = true;
+          BaseObjectExpr->setImplicit();
         }
       } else {
         return Diag(Loc, diag::err_invalid_member_use_in_static_method)
@@ -500,6 +502,7 @@
     }
     Result = new MemberExpr(Result, BaseObjectIsPointer, *FI,
                             OpLoc, MemberType);
+    Result->setImplicit();
     BaseObjectIsPointer = false;
     ExtraQuals = Context.getCanonicalType(MemberType).getCVRQualifiers();
     OpLoc = SourceLocation();
@@ -661,6 +664,7 @@
           // 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);
         }
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 031fe27..6a9275f 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -90,6 +90,7 @@
                                        &InitExprs[0], InitExprs.size(), 
                                        SourceLocation(),
                                        ParentIList->hadDesignators());
+  ILE->setImplicit();
   ILE->setType(T);
 
   // Modify the parent InitListExpr to point to the implicit InitListExpr.