2121#include " swift/Basic/LLVM.h"
2222#include " llvm/ADT/FoldingSet.h"
2323#include " llvm/Support/VersionTuple.h"
24- #include < optional >
24+ #include " llvm/Support/raw_ostream.h "
2525
2626namespace swift {
2727class ASTContext ;
@@ -317,11 +317,20 @@ class AvailabilityRange {
317317
318318 // / Returns a representation of this range as a string for debugging purposes.
319319 std::string getAsString () const {
320- return " AvailabilityRange(" + getVersionString () + " )" ;
320+ return " AvailabilityRange(" + getVersionDescription () + " )" ;
321321 }
322322
323- // / Returns a representation of the raw version range as a string for
323+ // / Returns a representation of the version range as a string for
324324 // / debugging purposes.
325+ std::string getVersionDescription () const {
326+ if (Range.hasLowerEndpoint ())
327+ return Range.getLowerEndpoint ().getAsString ();
328+ else
329+ return Range.isEmpty () ? " never" : " always" ;
330+ }
331+
332+ // / Returns a string representation of the raw version range. It is an error
333+ // / to call this if the range is "always" or "never".
325334 std::string getVersionString () const {
326335 ASSERT (Range.hasLowerEndpoint ());
327336 return Range.getLowerEndpoint ().getAsString ();
@@ -330,4 +339,20 @@ class AvailabilityRange {
330339
331340} // end namespace swift
332341
342+ namespace llvm {
343+
344+ inline llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
345+ const swift::VersionRange &range) {
346+ os << range.getAsString ();
347+ return os;
348+ }
349+
350+ inline llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
351+ const swift::AvailabilityRange &range) {
352+ os << range.getAsString ();
353+ return os;
354+ }
355+
356+ } // namespace llvm
357+
333358#endif
0 commit comments