r339306 - Refactor attribute printing to be a bit more obviously-correct.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 8 18:21:06 PDT 2018
Author: rsmith
Date: Wed Aug 8 18:21:06 2018
New Revision: 339306
URL: http://llvm.org/viewvc/llvm-project?rev=339306&view=rev
Log:
Refactor attribute printing to be a bit more obviously-correct.
No functionality change intended.
Added:
cfe/trunk/test/Misc/ast-print-attr.c
Modified:
cfe/trunk/lib/AST/TypePrinter.cpp
Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=339306&r1=339305&r2=339306&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Aug 8 18:21:06 2018
@@ -1398,25 +1398,21 @@ void TypePrinter::printAttributedAfter(c
T->getAttrKind() == AttributedType::attr_objc_ownership)
return printAfter(T->getEquivalentType(), OS);
- if (T->getAttrKind() == AttributedType::attr_objc_kindof)
- return;
-
- // TODO: not all attributes are GCC-style attributes.
- if (T->isMSTypeSpec())
- return;
-
- // Nothing to print after.
- if (T->getAttrKind() == AttributedType::attr_nonnull ||
- T->getAttrKind() == AttributedType::attr_nullable ||
- T->getAttrKind() == AttributedType::attr_null_unspecified)
- return printAfter(T->getModifiedType(), OS);
-
// If this is a calling convention attribute, don't print the implicit CC from
// the modified type.
SaveAndRestore<bool> MaybeSuppressCC(InsideCCAttribute, T->isCallingConv());
printAfter(T->getModifiedType(), OS);
+ // Some attributes are printed as qualifiers before the type, so we have
+ // nothing left to do.
+ if (T->getAttrKind() == AttributedType::attr_objc_kindof ||
+ T->isMSTypeSpec() ||
+ T->getAttrKind() == AttributedType::attr_nonnull ||
+ T->getAttrKind() == AttributedType::attr_nullable ||
+ T->getAttrKind() == AttributedType::attr_null_unspecified)
+ return;
+
// Don't print the inert __unsafe_unretained attribute at all.
if (T->getAttrKind() == AttributedType::attr_objc_inert_unsafe_unretained)
return;
Added: cfe/trunk/test/Misc/ast-print-attr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-attr.c?rev=339306&view=auto
==============================================================================
--- cfe/trunk/test/Misc/ast-print-attr.c (added)
+++ cfe/trunk/test/Misc/ast-print-attr.c Wed Aug 8 18:21:06 2018
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ast-print -x objective-c++ -fms-extensions %s -o - | FileCheck %s
+
+// CHECK: using A = __kindof id (*)[1];
+using A = __kindof id (*)[1];
+
+// CHECK: using B = int ** __ptr32 *[3];
+using B = int ** __ptr32 *[3];
+
+// FIXME: This is the wrong spelling for the attribute.
+// FIXME: Too many parens here!
+// CHECK: using C = int ((*))() __attribute__((cdecl));
+using C = int (*)() [[gnu::cdecl]];
More information about the cfe-commits
mailing list