[cfe-commits] r93186 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/Rewriter/rewrite-anonymous-union.m
Fariborz Jahanian
fjahanian at apple.com
Mon Jan 11 13:17:33 PST 2010
Author: fjahanian
Date: Mon Jan 11 15:17:32 2010
New Revision: 93186
URL: http://llvm.org/viewvc/llvm-project?rev=93186&view=rev
Log:
Fix a problem related to rewrite of anonymous unions.
(fixes radar 6948022)
Added:
cfe/trunk/test/Rewriter/rewrite-anonymous-union.m
Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=93186&r1=93185&r2=93186&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Jan 11 15:17:32 2010
@@ -739,9 +739,10 @@
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);
Added: cfe/trunk/test/Rewriter/rewrite-anonymous-union.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-anonymous-union.m?rev=93186&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-anonymous-union.m (added)
+++ cfe/trunk/test/Rewriter/rewrite-anonymous-union.m Mon Jan 11 15:17:32 2010
@@ -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;
+
+ at interface NSNumber
++ (NSNumber *)numberWithLong:(long)value;
+ at end
+
+ at interface OSRecurrence {
+ OSPatternSpecificData _pts;
+}
+- (void)_setTypeSpecificInfoOnRecord;
+ at end
+
+ at implementation OSRecurrence
+- (void)_setTypeSpecificInfoOnRecord
+{
+ [NSNumber numberWithLong:(_pts.dayOfMonth >= 31 ? -1 : _pts.dayOfMonth)];
+}
+ at end
+
More information about the cfe-commits
mailing list