Upgrade to CXX 17
Fix TestInstall build
Fix few issues surfaced during regression tests
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -30,7 +30,7 @@ add_subdirectory(third_party/antlr4/runtime/Cpp EXCLUDE_FROM_ALL)
add_subdirectory(third_party/UHDM)
add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

MODIFY
src/Utils/FileUtils.cpp
src/Utils/FileUtils.cpp
@@ -113,7 +113,8 @@ int FileUtils::mkDir(const char* path) {
}
std::string FileUtils::getPathName(const std::string path) {
- return (fs::path(path).parent_path() += fs::path::preferred_separator).string();
+ fs::path fs_path(path);
+ return fs_path.has_parent_path() ? (fs::path(path).parent_path() += fs::path::preferred_separator).string() : "";
}
std::string FileUtils::getFullPath(const std::string path) {
@@ -125,11 +126,11 @@ std::string FileUtils::getFullPath(const std::string path) {
bool FileUtils::getFullPath(const std::string path, std::string* const result) {
std::error_code ec;
fs::path fullPath = fs::canonical(path, ec);
- if (!ec && fileIsRegular(fullPath.string())) {
- if (result != nullptr) *result = fullPath.string();
- return true;
+ bool found = (!ec && fileIsRegular(fullPath.string()));
+ if (result != nullptr) {
+ *result = found ? fullPath.string() : path;
}
- return false;
+ return found;
}
static bool has_suffix(const std::string& s, const std::string& suffix) {
@@ -186,7 +187,7 @@ std::vector<SymbolId> FileUtils::collectFilesRegexp(const std::string dirPath,
std::smatch base_match;
for (fs::directory_entry entry : fs::directory_iterator(dirPath)) {
- std::string value = entry.path().string();
+ std::string value = entry.path().filename().string();
if (std::regex_match(value, base_match, base_regex)) {
result.push_back(symbols->registerSymbol(value));
}
@@ -281,11 +282,6 @@ std::string FileUtils::getFileContent(const std::string filename) {
}
std::string FileUtils::fileName(std::string str) {
- char c = '/';
- auto it1 = std::find_if(str.rbegin(), str.rend(),
- [c](char ch) { return (ch == c); });
- if (it1 != str.rend())
- str.erase(str.begin(), it1.base());
- return str;
+ return fs::path(str).filename().string();
}

MODIFY
tests/TestInstall/CMakeLists.txt
tests/TestInstall/CMakeLists.txt
# -*- mode:cmake -*-
+cmake_minimum_required(VERSION 3.13)
# Usage:
# After a make install at the top drectory:
project(HELLOSUREWORLD)
-set(CMAKE_CXX_STANDARD 14)
-
-cmake_minimum_required(VERSION 3.13)
+set(CMAKE_CXX_STANDARD 17)
# Python
find_package(Python3 3.3 REQUIRED COMPONENTS Interpreter Development)

Upgrade to CXX 17
Fix TestInstall build
Fix few issues surfaced during regression tests