diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 7 | ||||
-rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 30 | ||||
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Parse/ParseTentative.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 40 | ||||
-rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 54 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 2 |
13 files changed, 120 insertions, 95 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index c3ce4760097..d33093b8b5e 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -954,9 +954,8 @@ void DeclPrinter::PrintObjCMethodType(ASTContext &Ctx, if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Oneway) Out << "oneway "; if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_CSNullability) { - if (auto nullability = AttributedType::stripOuterNullability(T)) { - Out << getNullabilitySpelling(*nullability).substr(2) << ' '; - } + if (auto nullability = AttributedType::stripOuterNullability(T)) + Out << getNullabilitySpelling(*nullability, true) << ' '; } Out << Ctx.getUnqualifiedObjCPointerType(T).getAsString(Policy); @@ -1207,7 +1206,7 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) { Out << (first ? ' ' : ',') << "null_resettable"; } else { Out << (first ? ' ' : ',') - << getNullabilitySpelling(*nullability).substr(2); + << getNullabilitySpelling(*nullability, true); } first = false; } diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index ebe09d85495..9938170c321 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -1147,11 +1147,11 @@ void TypePrinter::printAttributedBefore(const AttributedType *T, T->getAttrKind() == AttributedType::attr_nullable || T->getAttrKind() == AttributedType::attr_null_unspecified) { if (T->getAttrKind() == AttributedType::attr_nonnull) - OS << " __nonnull"; + OS << " _Nonnull"; else if (T->getAttrKind() == AttributedType::attr_nullable) - OS << " __nullable"; + OS << " _Nullable"; else if (T->getAttrKind() == AttributedType::attr_null_unspecified) - OS << " __null_unspecified"; + OS << " _Null_unspecified"; else llvm_unreachable("unhandled nullability"); spaceBeforePlaceHolder(OS); @@ -1186,11 +1186,11 @@ void TypePrinter::printAttributedAfter(const AttributedType *T, T->getAttrKind() == AttributedType::attr_nullable || T->getAttrKind() == AttributedType::attr_null_unspecified) { if (T->getAttrKind() == AttributedType::attr_nonnull) - OS << " __nonnull"; + OS << " _Nonnull"; else if (T->getAttrKind() == AttributedType::attr_nullable) - OS << " __nullable"; + OS << " _Nullable"; else if (T->getAttrKind() == AttributedType::attr_null_unspecified) - OS << " __null_unspecified"; + OS << " _Null_unspecified"; else llvm_unreachable("unhandled nullability"); diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 7f5a15dab6b..f89caf7b248 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -24,6 +24,27 @@ using namespace clang; +const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB, + DiagNullabilityKind nullability) { + StringRef string; + switch (nullability.first) { + case NullabilityKind::NonNull: + string = nullability.second ? "'nonnull'" : "'_Nonnull'"; + break; + + case NullabilityKind::Nullable: + string = nullability.second ? "'nullable'" : "'_Nullable'"; + break; + + case NullabilityKind::Unspecified: + string = nullability.second ? "'null_unspecified'" : "'_Null_unspecified'"; + break; + } + + DB.AddString(string); + return DB; +} + static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT, StringRef Modifier, StringRef Argument, ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs, diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index b2950081000..40b28222b8b 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -647,16 +647,17 @@ const char *clang::getOperatorSpelling(OverloadedOperatorKind Operator) { llvm_unreachable("Invalid OverloadedOperatorKind!"); } -StringRef clang::getNullabilitySpelling(NullabilityKind kind) { +StringRef clang::getNullabilitySpelling(NullabilityKind kind, + bool isContextSensitive) { switch (kind) { case NullabilityKind::NonNull: - return "__nonnull"; + return isContextSensitive ? "nonnull" : "_Nonnull"; case NullabilityKind::Nullable: - return "__nullable"; + return isContextSensitive ? "nullable" : "_Nullable"; case NullabilityKind::Unspecified: - return "__null_unspecified"; + return isContextSensitive ? "null_unspecified" : "_Null_unspecified"; } llvm_unreachable("Unknown nullability kind."); } diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 1c52552ea15..e3294eca46f 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -691,9 +691,9 @@ void Parser::ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs) { // Treat these like attributes, even though they're type specifiers. while (true) { switch (Tok.getKind()) { - case tok::kw___nonnull: - case tok::kw___nullable: - case tok::kw___null_unspecified: { + case tok::kw__Nonnull: + case tok::kw__Nullable: + case tok::kw__Null_unspecified: { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); if (!getLangOpts().ObjC1) @@ -3076,9 +3076,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, continue; // Nullability type specifiers. - case tok::kw___nonnull: - case tok::kw___nullable: - case tok::kw___null_unspecified: + case tok::kw__Nonnull: + case tok::kw__Nullable: + case tok::kw__Null_unspecified: ParseNullabilityTypeSpecifiers(DS.getAttributes()); continue; @@ -4326,9 +4326,9 @@ bool Parser::isTypeSpecifierQualifier() { case tok::kw___pascal: case tok::kw___unaligned: - case tok::kw___nonnull: - case tok::kw___nullable: - case tok::kw___null_unspecified: + case tok::kw__Nonnull: + case tok::kw__Nullable: + case tok::kw__Null_unspecified: case tok::kw___private: case tok::kw___local: @@ -4503,9 +4503,9 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { case tok::kw___pascal: case tok::kw___unaligned: - case tok::kw___nonnull: - case tok::kw___nullable: - case tok::kw___null_unspecified: + case tok::kw__Nonnull: + case tok::kw__Nullable: + case tok::kw__Null_unspecified: case tok::kw___private: case tok::kw___local: @@ -4738,9 +4738,9 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, unsigned AttrReqs, goto DoneWithTypeQuals; // Nullability type specifiers. - case tok::kw___nonnull: - case tok::kw___nullable: - case tok::kw___null_unspecified: + case tok::kw__Nonnull: + case tok::kw__Nullable: + case tok::kw__Null_unspecified: ParseNullabilityTypeSpecifiers(DS.getAttributes()); continue; diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index e4f7911138d..f975f8715ed 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -557,14 +557,14 @@ static void diagnoseRedundantPropertyNullability(Parser &P, SourceLocation nullabilityLoc){ if (DS.getNullability() == nullability) { P.Diag(nullabilityLoc, diag::warn_nullability_duplicate) - << static_cast<unsigned>(nullability) << true + << DiagNullabilityKind(nullability, true) << SourceRange(DS.getNullabilityLoc()); return; } P.Diag(nullabilityLoc, diag::err_nullability_conflicting) - << static_cast<unsigned>(nullability) << true - << static_cast<unsigned>(DS.getNullability()) << true + << DiagNullabilityKind(nullability, true) + << DiagNullabilityKind(DS.getNullability(), true) << SourceRange(DS.getNullabilityLoc()); } diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index d63cf24bcdb..536e98c6831 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -632,8 +632,8 @@ Parser::TPResult Parser::TryParsePtrOperatorSeq() { // ptr-operator ConsumeToken(); while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict, - tok::kw___nonnull, tok::kw___nullable, - tok::kw___null_unspecified)) + tok::kw__Nonnull, tok::kw__Nullable, + tok::kw__Null_unspecified)) ConsumeToken(); } else { return TPResult::True; @@ -1276,9 +1276,9 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, case tok::kw___ptr32: case tok::kw___forceinline: case tok::kw___unaligned: - case tok::kw___nonnull: - case tok::kw___nullable: - case tok::kw___null_unspecified: + case tok::kw__Nonnull: + case tok::kw__Nullable: + case tok::kw__Null_unspecified: return TPResult::True; // Borland diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index ebb6bbcd345..ff6a3eed8c2 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1343,9 +1343,9 @@ static void AddTypeSpecifierResults(const LangOptions &LangOpts, } // Nullability - Results.AddResult(Result("__nonnull", CCP_Type)); - Results.AddResult(Result("__null_unspecified", CCP_Type)); - Results.AddResult(Result("__nullable", CCP_Type)); + Results.AddResult(Result("_Nonnull", CCP_Type)); + Results.AddResult(Result("_Null_unspecified", CCP_Type)); + Results.AddResult(Result("_Nullable", CCP_Type)); } static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ce89d993f3c..dc826f05b06 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2472,13 +2472,15 @@ static void mergeParamDeclTypes(ParmVarDecl *NewParam, if (auto Oldnullability = OldParam->getType()->getNullability(S.Context)) { if (auto Newnullability = NewParam->getType()->getNullability(S.Context)) { if (*Oldnullability != *Newnullability) { - unsigned unsNewnullability = static_cast<unsigned>(*Newnullability); - unsigned unsOldnullability = static_cast<unsigned>(*Oldnullability); S.Diag(NewParam->getLocation(), diag::warn_mismatched_nullability_attr) - << unsNewnullability - << ((NewParam->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) != 0) - << unsOldnullability - << ((OldParam->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) != 0); + << DiagNullabilityKind( + *Newnullability, + ((NewParam->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) + != 0)) + << DiagNullabilityKind( + *Oldnullability, + ((OldParam->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) + != 0)); S.Diag(OldParam->getLocation(), diag::note_previous_declaration); } } else { diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 543566fdb7c..d0b299877e0 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1400,16 +1400,20 @@ static bool CheckMethodOverrideReturn(Sema &S, !S.Context.hasSameNullabilityTypeQualifier(MethodImpl->getReturnType(), MethodDecl->getReturnType(), false)) { - unsigned unsNullabilityMethodImpl = - static_cast<unsigned>(*MethodImpl->getReturnType()->getNullability(S.Context)); - unsigned unsNullabilityMethodDecl = - static_cast<unsigned>(*MethodDecl->getReturnType()->getNullability(S.Context)); + auto nullabilityMethodImpl = + *MethodImpl->getReturnType()->getNullability(S.Context); + auto nullabilityMethodDecl = + *MethodDecl->getReturnType()->getNullability(S.Context); S.Diag(MethodImpl->getLocation(), diag::warn_conflicting_nullability_attr_overriding_ret_types) - << unsNullabilityMethodImpl - << ((MethodImpl->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) != 0) - << unsNullabilityMethodDecl - << ((MethodDecl->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) != 0); + << DiagNullabilityKind( + nullabilityMethodImpl, + ((MethodImpl->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) + != 0)) + << DiagNullabilityKind( + nullabilityMethodDecl, + ((MethodDecl->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) + != 0)); S.Diag(MethodDecl->getLocation(), diag::note_previous_declaration); } @@ -1486,15 +1490,17 @@ static bool CheckMethodOverrideParam(Sema &S, if (Warn && IsOverridingMode && !isa<ObjCImplementationDecl>(MethodImpl->getDeclContext()) && !S.Context.hasSameNullabilityTypeQualifier(ImplTy, IfaceTy, true)) { - unsigned unsImplTy = static_cast<unsigned>(*ImplTy->getNullability(S.Context)); - unsigned unsIfaceTy = static_cast<unsigned>(*IfaceTy->getNullability(S.Context)); S.Diag(ImplVar->getLocation(), diag::warn_conflicting_nullability_attr_overriding_param_types) - << unsImplTy - << ((ImplVar->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) != 0) - << unsIfaceTy - << ((IfaceVar->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) != 0); - S.Diag(IfaceVar->getLocation(), diag::note_previous_declaration); + << DiagNullabilityKind( + *ImplTy->getNullability(S.Context), + ((ImplVar->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) + != 0)) + << DiagNullabilityKind( + *IfaceTy->getNullability(S.Context), + ((IfaceVar->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) + != 0)); + S.Diag(IfaceVar->getLocation(), diag::note_previous_declaration); } if (S.Context.hasSameUnqualifiedType(ImplTy, IfaceTy)) return true; @@ -3184,8 +3190,8 @@ static QualType mergeTypeNullabilityForRedecl(Sema &S, SourceLocation loc, // Complain about mismatched nullability. S.Diag(loc, diag::err_nullability_conflicting) - << static_cast<unsigned>(*nullability) << usesCSKeyword - << static_cast<unsigned>(*prevNullability) << prevUsesCSKeyword; + << DiagNullabilityKind(*nullability, usesCSKeyword) + << DiagNullabilityKind(*prevNullability, prevUsesCSKeyword); return type; } diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index 87fb5b6913a..0f88abcdf9e 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -1758,7 +1758,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, } } -void Sema::diagnoseNullResettableSynthesizedSetters(ObjCImplDecl *impDecl) { +void Sema::diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl) { for (const auto *propertyImpl : impDecl->property_impls()) { const auto *property = propertyImpl->getPropertyDecl(); @@ -2025,7 +2025,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, if (property->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_null_resettable) { QualType modifiedTy = resultTy; - if (auto nullability = AttributedType::stripOuterNullability(modifiedTy)){ + if (auto nullability = AttributedType::stripOuterNullability(modifiedTy)) { if (*nullability == NullabilityKind::Unspecified) resultTy = Context.getAttributedType(AttributedType::attr_nonnull, modifiedTy, modifiedTy); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 03cbdfdbf1d..8d76f692025 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2567,19 +2567,19 @@ namespace { IdentifierInfo *Sema::getNullabilityKeyword(NullabilityKind nullability) { switch (nullability) { case NullabilityKind::NonNull: - if (!Ident___nonnull) - Ident___nonnull = PP.getIdentifierInfo("__nonnull"); - return Ident___nonnull; + if (!Ident__Nonnull) + Ident__Nonnull = PP.getIdentifierInfo("_Nonnull"); + return Ident__Nonnull; case NullabilityKind::Nullable: - if (!Ident___nullable) - Ident___nullable = PP.getIdentifierInfo("__nullable"); - return Ident___nullable; + if (!Ident__Nullable) + Ident__Nullable = PP.getIdentifierInfo("_Nullable"); + return Ident__Nullable; case NullabilityKind::Unspecified: - if (!Ident___null_unspecified) - Ident___null_unspecified = PP.getIdentifierInfo("__null_unspecified"); - return Ident___null_unspecified; + if (!Ident__Null_unspecified) + Ident__Null_unspecified = PP.getIdentifierInfo("_Null_unspecified"); + return Ident__Null_unspecified; } llvm_unreachable("Unknown nullability kind."); } @@ -2900,7 +2900,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } } - // Determine whether we should infer __nonnull on pointer types. + // Determine whether we should infer _Nonnull on pointer types. Optional<NullabilityKind> inferNullability; bool inferNullabilityCS = false; bool inferNullabilityInnerOnly = false; @@ -3003,7 +3003,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, break; case PointerDeclaratorKind::SingleLevelPointer: - // Infer __nonnull if we are in an assumes-nonnull region. + // Infer _Nonnull if we are in an assumes-nonnull region. if (inAssumeNonNullRegion) { inferNullability = NullabilityKind::NonNull; inferNullabilityCS = (context == Declarator::ObjCParameterContext || @@ -3013,7 +3013,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, case PointerDeclaratorKind::CFErrorRefPointer: case PointerDeclaratorKind::NSErrorPointerPointer: - // Within a function or method signature, infer __nullable at both + // Within a function or method signature, infer _Nullable at both // levels. if (isFunctionOrMethod && inAssumeNonNullRegion) inferNullability = NullabilityKind::Nullable; @@ -3023,7 +3023,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (isFunctionOrMethod) { // On pointer-to-pointer parameters marked cf_returns_retained or // cf_returns_not_retained, if the outer pointer is explicit then - // infer the inner pointer as __nullable. + // infer the inner pointer as _Nullable. auto hasCFReturnsAttr = [](const AttributeList *NextAttr) -> bool { while (NextAttr) { if (NextAttr->getKind() == AttributeList::AT_CFReturnsRetained || @@ -3070,7 +3070,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } // Local function that checks the nullability for a given pointer declarator. - // Returns true if __nonnull was inferred. + // Returns true if _Nonnull was inferred. auto inferPointerNullability = [&](SimplePointerKind pointerKind, SourceLocation pointerLoc, AttributeList *&attrs) -> AttributeList * { @@ -5084,8 +5084,7 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, // Duplicated nullability. if (nullability == *existingNullability) { Diag(nullabilityLoc, diag::warn_nullability_duplicate) - << static_cast<unsigned>(nullability) - << isContextSensitive + << DiagNullabilityKind(nullability, isContextSensitive) << FixItHint::CreateRemoval(nullabilityLoc); break; @@ -5093,10 +5092,8 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, // Conflicting nullability. Diag(nullabilityLoc, diag::err_nullability_conflicting) - << static_cast<unsigned>(nullability) - << isContextSensitive - << static_cast<unsigned>(*existingNullability) - << false; + << DiagNullabilityKind(nullability, isContextSensitive) + << DiagNullabilityKind(*existingNullability, false); return true; } @@ -5110,10 +5107,8 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, if (auto existingNullability = desugared->getNullability(Context)) { if (nullability != *existingNullability) { Diag(nullabilityLoc, diag::err_nullability_conflicting) - << static_cast<unsigned>(nullability) - << isContextSensitive - << static_cast<unsigned>(*existingNullability) - << false; + << DiagNullabilityKind(nullability, isContextSensitive) + << DiagNullabilityKind(*existingNullability, false); // Try to find the typedef with the existing nullability specifier. if (auto typedefType = desugared->getAs<TypedefType>()) { @@ -5123,7 +5118,7 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, = AttributedType::stripOuterNullability(underlyingType)) { if (*typedefNullability == *existingNullability) { Diag(typedefDecl->getLocation(), diag::note_nullability_here) - << static_cast<unsigned>(*existingNullability); + << DiagNullabilityKind(*existingNullability, false); } } } @@ -5135,7 +5130,7 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, // If this definitely isn't a pointer type, reject the specifier. if (!desugared->canHaveNullability()) { Diag(nullabilityLoc, diag::err_nullability_nonpointer) - << static_cast<unsigned>(nullability) << isContextSensitive << type; + << DiagNullabilityKind(nullability, isContextSensitive) << type; return true; } @@ -5148,10 +5143,10 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, pointeeType->isObjCObjectPointerType() || pointeeType->isMemberPointerType()) { Diag(nullabilityLoc, diag::err_nullability_cs_multilevel) - << static_cast<unsigned>(nullability) + << DiagNullabilityKind(nullability, true) << type; Diag(nullabilityLoc, diag::note_nullability_type_specifier) - << static_cast<unsigned>(nullability) + << DiagNullabilityKind(nullability, false) << type << FixItHint::CreateReplacement(nullabilityLoc, getNullabilitySpelling(nullability)); @@ -5216,7 +5211,8 @@ static bool distributeNullabilityTypeAttr(TypeProcessingState &state, auto diag = state.getSema().Diag(attr.getLoc(), diag::warn_nullability_declspec) - << static_cast<unsigned>(mapNullabilityAttrKind(attr.getKind())) + << DiagNullabilityKind(mapNullabilityAttrKind(attr.getKind()), + attr.isContextSensitiveKeywordAttribute()) << type << static_cast<unsigned>(pointerKind); diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 996dd2b0783..3b2a17c5497 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -5405,7 +5405,7 @@ QualType TreeTransform<Derived>::TransformAttributedType( if (auto nullability = oldType->getImmediateNullability()) { if (!modifiedType->canHaveNullability()) { SemaRef.Diag(TL.getAttrNameLoc(), diag::err_nullability_nonpointer) - << static_cast<unsigned>(*nullability) << false << modifiedType; + << DiagNullabilityKind(*nullability, false) << modifiedType; return QualType(); } } |