clang API Documentation
00001 //===- VersionTuple.cpp - Version Number Handling ---------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the VersionTuple class, which represents a version in 00011 // the form major[.minor[.subminor]]. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 #include "clang/Basic/VersionTuple.h" 00015 #include "llvm/Support/raw_ostream.h" 00016 00017 using namespace clang; 00018 00019 std::string VersionTuple::getAsString() const { 00020 std::string Result; 00021 { 00022 llvm::raw_string_ostream Out(Result); 00023 Out << *this; 00024 } 00025 return Result; 00026 } 00027 00028 raw_ostream& clang::operator<<(raw_ostream &Out, 00029 const VersionTuple &V) { 00030 Out << V.getMajor(); 00031 if (llvm::Optional<unsigned> Minor = V.getMinor()) 00032 Out << '.' << *Minor; 00033 if (llvm::Optional<unsigned> Subminor = V.getSubminor()) 00034 Out << '.' << *Subminor; 00035 return Out; 00036 }