Fixed building on MSVC (#287)

This commit is contained in:
Bartek Kryza
2024-06-10 20:09:13 +02:00
parent fa742a03c4
commit 4f9a09783f
4 changed files with 39 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
# This script assumes that all clang-uml dependencies are instaled in C:\clang-uml # This script assumes that all clang-uml dependencies are instaled in C:\clang-uml
param ($Prefix="C:\clang-uml-llvm17", $BuildType="Release") param ($Prefix="C:\clang-uml-llvm18", $BuildType="Release")
mkdir _BUILD mkdir _BUILD

View File

@@ -83,8 +83,12 @@ void translation_unit_visitor::include_visitor::InclusionDirective(
assert(diagram().get(current_file_id.value())); assert(diagram().get(current_file_id.value()));
#if LLVM_VERSION_MAJOR > 14 #if LLVM_VERSION_MAJOR > 14
if (!file.has_value())
return;
auto include_path = std::filesystem::path(file->getDir().getName().str()); auto include_path = std::filesystem::path(file->getDir().getName().str());
#else #else
if (file == nullptr)
return;
auto include_path = std::filesystem::path(file->getDir()->getName().str()); auto include_path = std::filesystem::path(file->getDir()->getName().str());
#endif #endif
include_path = include_path / file->getName().str(); include_path = include_path / file->getName().str();

View File

@@ -20,7 +20,11 @@ public:
struct { struct {
int len; int len;
int flags; int flags;
} __attribute__((packed)) bars[LENGTH]; }
#ifndef _MSC_VER
__attribute__((packed))
#endif
bars[LENGTH];
private: private:
struct { struct {

View File

@@ -26,6 +26,7 @@ TEST_CASE("Test progress indicator")
{ {
using namespace clanguml::common::generators; using namespace clanguml::common::generators;
using namespace std::string_literals; using namespace std::string_literals;
using clanguml::util::contains;
std::stringstream sstr; std::stringstream sstr;
@@ -46,7 +47,19 @@ TEST_CASE("Test progress indicator")
output_lines.emplace_back(std::move(line)); output_lines.emplace_back(std::move(line));
REQUIRE_EQ(output_lines[0], ""); REQUIRE_EQ(output_lines[0], "");
#ifdef _MSC_VER
REQUIRE(contains(output_lines[1],
"One [>----------------------------------] "
"[00:00s] 0/100"s));
REQUIRE(contains(output_lines[2],
"One [>----------------------------------] "
"[00m:00s] 1/100"s));
REQUIRE(contains(output_lines[3],
"One [===================================] "
"[00m:00s] 100/100 OK"s));
#else
REQUIRE_EQ(output_lines[1], REQUIRE_EQ(output_lines[1],
"One [█----------------------------------] " "One [█----------------------------------] "
"[00:00s] 0/100"); "[00:00s] 0/100");
@@ -58,12 +71,14 @@ TEST_CASE("Test progress indicator")
REQUIRE_EQ(output_lines[3], REQUIRE_EQ(output_lines[3],
"One [███████████████████████████████████] " "One [███████████████████████████████████] "
"[00m:00s] 100/100 ✔"); "[00m:00s] 100/100 ✔");
#endif
} }
TEST_CASE("Test progress indicator fail") TEST_CASE("Test progress indicator fail")
{ {
using namespace clanguml::common::generators; using namespace clanguml::common::generators;
using namespace std::string_literals; using namespace std::string_literals;
using clanguml::util::contains;
std::stringstream sstr; std::stringstream sstr;
@@ -91,6 +106,19 @@ TEST_CASE("Test progress indicator fail")
REQUIRE_EQ(output_lines[0], ""); REQUIRE_EQ(output_lines[0], "");
#ifdef _MSC_VER
REQUIRE(contains(output_lines[1],
"One [>----------------------------------] "
"[00:00s] 0/100"s));
REQUIRE(contains(output_lines[2],
"One [>----------------------------------] "
"[00m:00s] 1/100"s));
REQUIRE(contains(output_lines[3],
"One [>----------------------------------] "
"[00m:00s] 1/100 FAILED"s));
#else
REQUIRE_EQ(output_lines[1], REQUIRE_EQ(output_lines[1],
"One [█----------------------------------] " "One [█----------------------------------] "
"[00:00s] 0/100"); "[00:00s] 0/100");
@@ -102,4 +130,5 @@ TEST_CASE("Test progress indicator fail")
REQUIRE_EQ(output_lines[3], REQUIRE_EQ(output_lines[3],
"One [█----------------------------------] " "One [█----------------------------------] "
"[00m:00s] 1/100 ✗"); "[00m:00s] 1/100 ✗");
#endif
} }