summaryrefslogtreecommitdiffstats
path: root/lib/Basic/VersionTuple.cpp
blob: 77aad39cbf2c422cfef91b24893980878ba6f50e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//===- VersionTuple.cpp - Version Number Handling ---------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the VersionTuple class, which represents a version in
// the form major[.minor[.subminor]].
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/VersionTuple.h"
#include "llvm/Support/raw_ostream.h"

using namespace clang;

std::string VersionTuple::getAsString() const {
  std::string Result;
  {
    llvm::raw_string_ostream Out(Result);
    Out << *this;
  }
  return Result;
}

raw_ostream& clang::operator<<(raw_ostream &Out, 
                                     const VersionTuple &V) {
  Out << V.getMajor();
  if (llvm::Optional<unsigned> Minor = V.getMinor())
    Out << '.' << *Minor;
  if (llvm::Optional<unsigned> Subminor = V.getSubminor())
    Out << '.' << *Subminor;
  return Out;
}