blob: d5cf126ff487624ef4ba35c5e0c078a44e7ac53e [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
28llvm::raw_ostream& clang::operator<<(llvm::raw_ostream &Out,
29 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}