21
21
#include " swift/Basic/LLVM.h"
22
22
#include " llvm/ADT/FoldingSet.h"
23
23
#include " llvm/Support/VersionTuple.h"
24
- #include < optional >
24
+ #include " llvm/Support/raw_ostream.h "
25
25
26
26
namespace swift {
27
27
class ASTContext ;
@@ -317,11 +317,20 @@ class AvailabilityRange {
317
317
318
318
// / Returns a representation of this range as a string for debugging purposes.
319
319
std::string getAsString () const {
320
- return " AvailabilityRange(" + getVersionString () + " )" ;
320
+ return " AvailabilityRange(" + getVersionDescription () + " )" ;
321
321
}
322
322
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
324
324
// / 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".
325
334
std::string getVersionString () const {
326
335
ASSERT (Range.hasLowerEndpoint ());
327
336
return Range.getLowerEndpoint ().getAsString ();
@@ -330,4 +339,20 @@ class AvailabilityRange {
330
339
331
340
} // end namespace swift
332
341
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
+
333
358
#endif
0 commit comments