diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h --- a/clang/include/clang/Basic/Specifiers.h +++ b/clang/include/clang/Basic/Specifiers.h @@ -19,6 +19,9 @@ #include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" +namespace llvm { +class raw_ostream; +} // namespace llvm namespace clang { /// Define the meaning of possible values of the kind in ExplicitSpecifier. @@ -333,6 +336,8 @@ // parameters are assumed to only get null on error. NullableResult, }; + /// Prints human-readable debug representation. + llvm::raw_ostream &operator<<(llvm::raw_ostream&, NullabilityKind); /// Return true if \p L has a weaker nullability annotation than \p R. The /// ordering is: Unspecified < Nullable < NonNull. diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -849,6 +849,20 @@ llvm_unreachable("Unknown nullability kind."); } +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NullabilityKind NK) { + switch (NK) { + case NullabilityKind::NonNull: + return OS << "NonNull"; + case NullabilityKind::Nullable: + return OS << "Nullable"; + case NullabilityKind::NullableResult: + return OS << "NullableResult"; + case NullabilityKind::Unspecified: + return OS << "Unspecified"; + } + llvm_unreachable("Unknown nullability kind."); +} + diag::kind IdentifierTable::getFutureCompatDiagKind(const IdentifierInfo &II, const LangOptions &LangOpts) {