]> granicus.if.org Git - clang/commitdiff
Fix a problem related to rewrite of anonymous unions.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 11 Jan 2010 21:17:32 +0000 (21:17 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 11 Jan 2010 21:17:32 +0000 (21:17 +0000)
(fixes radar 6948022)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93186 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtPrinter.cpp
test/Rewriter/rewrite-anonymous-union.m [new file with mode: 0644]

index a7e42af04d81bc40510bfd8a24ea22d65e5ccce9..83d38f84524b555ba2ebc761b3905cc0a87fce53 100644 (file)
@@ -739,9 +739,10 @@ void StmtPrinter::VisitCallExpr(CallExpr *Call) {
 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
   // FIXME: Suppress printing implicit bases (like "this")
   PrintExpr(Node->getBase());
+  if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
+    if (FD->isAnonymousStructOrUnion())
+      return;
   OS << (Node->isArrow() ? "->" : ".");
-  // FIXME: Suppress printing references to unnamed objects
-  // representing anonymous unions/structs
   if (NestedNameSpecifier *Qualifier = Node->getQualifier())
     Qualifier->print(OS, Policy);
 
diff --git a/test/Rewriter/rewrite-anonymous-union.m b/test/Rewriter/rewrite-anonymous-union.m
new file mode 100644 (file)
index 0000000..579a068
--- /dev/null
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -rewrite-objc -o - %s
+// rdar://6948022
+
+typedef unsigned int uint32_t;
+
+typedef struct {
+    union {
+        uint32_t daysOfWeek;
+        uint32_t dayOfMonth;
+    };
+    uint32_t nthOccurrence;
+} OSPatternSpecificData;
+
+@interface NSNumber
++ (NSNumber *)numberWithLong:(long)value;
+@end
+
+@interface OSRecurrence  {
+    OSPatternSpecificData _pts;
+}
+- (void)_setTypeSpecificInfoOnRecord;
+@end
+
+@implementation OSRecurrence
+- (void)_setTypeSpecificInfoOnRecord
+{
+    [NSNumber numberWithLong:(_pts.dayOfMonth >= 31 ? -1 : _pts.dayOfMonth)];
+}
+@end
+