blob: 77aad39cbf2c422cfef91b24893980878ba6f50e [file] [log] [blame]
Douglas Gregor0a0d2b12011-03-23 00:50:03 +00001//===- VersionTuple.cpp - Version Number Handling ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the VersionTuple class, which represents a version in
11// the form major[.minor[.subminor]].
12//
13//===----------------------------------------------------------------------===//
14#include "clang/Basic/VersionTuple.h"
15#include "llvm/Support/raw_ostream.h"
16
17using namespace clang;
18
19std::string VersionTuple::getAsString() const {
20 std::string Result;
21 {
22 llvm::raw_string_ostream Out(Result);
23 Out << *this;
24 }
25 return Result;
26}
27
Chris Lattner5f9e2722011-07-23 10:55:15 +000028raw_ostream& clang::operator<<(raw_ostream &Out,
Douglas Gregor0a0d2b12011-03-23 00:50:03 +000029 const VersionTuple &V) {
30 Out << V.getMajor();
31 if (llvm::Optional<unsigned> Minor = V.getMinor())
32 Out << '.' << *Minor;
33 if (llvm::Optional<unsigned> Subminor = V.getSubminor())
34 Out << '.' << *Subminor;
35 return Out;
36}