diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 14:00:56 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 14:00:56 +0000 |
| commit | 2e645aa5697838f16ec570eb07c2bee7e13d0e0b (patch) | |
| tree | a764184c2fc9486979b074250b013a0937ee64e5 /lib/AST/TypePrinter.cpp | |
| parent | 798321d8eb5630cd4a8f490a4f25e32ef195fb07 (diff) | |
Notes
Diffstat (limited to 'lib/AST/TypePrinter.cpp')
| -rw-r--r-- | lib/AST/TypePrinter.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 3928fe8f8942..ebe09d85495e 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -1141,6 +1141,21 @@ void TypePrinter::printAttributedBefore(const AttributedType *T, } spaceBeforePlaceHolder(OS); } + + // Print nullability type specifiers. + if (T->getAttrKind() == AttributedType::attr_nonnull || + T->getAttrKind() == AttributedType::attr_nullable || + T->getAttrKind() == AttributedType::attr_null_unspecified) { + if (T->getAttrKind() == AttributedType::attr_nonnull) + OS << " __nonnull"; + else if (T->getAttrKind() == AttributedType::attr_nullable) + OS << " __nullable"; + else if (T->getAttrKind() == AttributedType::attr_null_unspecified) + OS << " __null_unspecified"; + else + llvm_unreachable("unhandled nullability"); + spaceBeforePlaceHolder(OS); + } } void TypePrinter::printAttributedAfter(const AttributedType *T, @@ -1154,12 +1169,34 @@ void TypePrinter::printAttributedAfter(const AttributedType *T, 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); + // Print nullability type specifiers that occur after + if (T->getAttrKind() == AttributedType::attr_nonnull || + T->getAttrKind() == AttributedType::attr_nullable || + T->getAttrKind() == AttributedType::attr_null_unspecified) { + if (T->getAttrKind() == AttributedType::attr_nonnull) + OS << " __nonnull"; + else if (T->getAttrKind() == AttributedType::attr_nullable) + OS << " __nullable"; + else if (T->getAttrKind() == AttributedType::attr_null_unspecified) + OS << " __null_unspecified"; + else + llvm_unreachable("unhandled nullability"); + + return; + } + OS << " __attribute__(("; switch (T->getAttrKind()) { default: llvm_unreachable("This attribute should have been handled already"); |
