CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ms_cl_version.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Visual Studio CL version numbering scheme
4
5Author: Daniel Kroening, 2018
6
7\*******************************************************************/
8
9#include "ms_cl_version.h"
10
11#include <util/run.h>
12#include <util/string2int.h>
13#include <util/string_utils.h>
14#include <util/tempfile.h>
15
16#include <fstream>
17
18void ms_cl_versiont::get(const std::string &executable)
19{
20 // stdout will have the help output, we just want to discard it
21 temporary_filet tmp_file_out("goto-cl.", ".out");
22 // stderr has the version string
23 temporary_filet tmp_file_err("goto-cl.", ".err");
24 const int result =
26
27 v_major = v_minor = 0;
29
30 if(result >= 0)
31 {
32 std::ifstream in(tmp_file_err());
33 std::string line;
34
35 if(std::getline(in, line))
36 {
37 // Example:
38 //
39 // NOLINTNEXTLINE (whitespace/braces)
40 // Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
41 auto split = split_string(line, ' ');
42 if(split.size() > 3)
43 {
44 if(split.back() == "x86" || split.back() == "80x86")
46 else if(split.back() == "x64")
48 else if(split.back() == "ARM")
50 else
52
53 auto split_v = split_string(split[split.size() - 3], '.');
54
55 if(split_v.size() >= 2)
56 {
59 }
60 }
61 }
62 }
63}
64
65bool ms_cl_versiont::is_at_least(unsigned _major, unsigned _minor) const
66{
67 return v_major > _major || (v_major == _major && v_minor >= _minor);
68}
69
70std::ostream &operator<<(std::ostream &out, const ms_cl_versiont &v)
71{
72 out << v.v_major << '.' << v.v_minor;
73
74 switch(v.target)
75 {
77 out << " x86";
78 break;
80 out << " x64";
81 break;
83 out << " ARM";
84 break;
86 break;
87 }
88
89 return out;
90}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
void get(const std::string &executable)
enum ms_cl_versiont::targett target
bool is_at_least(unsigned v_major, unsigned v_minor=0) const
std::ostream & operator<<(std::ostream &out, const ms_cl_versiont &v)
int run(const std::string &what, const std::vector< std::string > &argv)
Definition run.cpp:48
unsigned safe_string2unsigned(const std::string &str, int base)
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)