diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 3d5510d..09b7624 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -10,12 +10,11 @@ get_directory_property(ATDNA_DEFINES COMPILE_DEFINITIONS) list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1) set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}") -# Force this binary to Release flags (to make MSVC happy) +# Force this binary to /MD flags (to make MSVC happy) if(MSVC) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE}") - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS_DEBUG "/MD /Zi /Ob0 /Od /RTC1") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /O2 /Ob2 /DNDEBUG") - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-debug -incremental:no") + set(CMAKE_CXX_FLAGS_RELEASE "/MD /Zi /O2 /Ob1 /DNDEBUG") endif() # Find dependencies @@ -31,6 +30,8 @@ else() endif() if(ATDNA_DYNAMIC_LLVM) + find_library(CLANGCPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib") + if (NOT CLANGCPP_LIB) list(APPEND LLVM_LIBS clangFrontend clangTooling @@ -44,6 +45,11 @@ if(ATDNA_DYNAMIC_LLVM) clangLex clangBasic LLVM) + else() + list(APPEND LLVM_LIBS + clang-cpp + LLVM) + endif() else() find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib") find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib") @@ -53,18 +59,27 @@ else() if (NOT LLVMBINARYFORMAT_LIB) set(LLVMBINARYFORMAT_LIB "") endif() + find_library(CLANG_CPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib") + if (NOT CLANG_CPP_LIB) + list(APPEND CLANG_LIBS + clangFrontend + clangTooling + clangDriver + clangSerialization + clangParse + clangSema + clangAnalysis + clangEdit + clangAST + clangLex + clangBasic) + else() + list(APPEND CLANG_LIBS + clang-cpp) + endif() + list(APPEND LLVM_LIBS - clangFrontend - clangTooling - clangDriver - clangSerialization - clangParse - clangSema - clangAnalysis - clangEdit - clangAST - clangLex - clangBasic + ${CLANG_LIBS} LLVMCore LLVMOption LLVMMCParser @@ -73,6 +88,8 @@ else() LLVMMC LLVMProfileData LLVMSupport + LLVMRemarks + LLVMBitStreamReader ${LLVMDEMANGLE_LIB}) endif() @@ -133,6 +150,7 @@ if(MSVC) target_compile_options(atdna PRIVATE /GR-) else() target_compile_options(atdna PRIVATE -fno-rtti -Wno-error) + set_property(TARGET atdna PROPERTY CXX_STANDARD 17) endif() # Define installs diff --git a/atdna/FindLLVM.cmake b/atdna/FindLLVM.cmake index d10022a..e76c075 100644 --- a/atdna/FindLLVM.cmake +++ b/atdna/FindLLVM.cmake @@ -30,7 +30,7 @@ set(LLVM_ROOT_DIR "" CACHE PATH "Location of LLVM development root") set(LLVM_FIND_COMPONENTS "") if(WIN32) -get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE CACHE) +get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE) endif() set(llvm_config_names llvm-config-3.9 llvm-config39 diff --git a/atdna/main.cpp b/atdna/main.cpp index 0becc78..b21eda3 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -262,7 +262,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { templateStmt += ", "; qualType += ", "; } - templateStmt += nonTypeParm->getType().getAsString().append(1, ' ').append(nonTypeParm->getName().str()); + templateStmt += nonTypeParm->getType().getAsString(context.getPrintingPolicy()).append(1, ' ').append(nonTypeParm->getName().str()); qualType += nonTypeParm->getName(); needsComma = true; } @@ -1261,10 +1261,13 @@ int main(int argc, const char** argv) { } llvm::IntrusiveRefCntPtr fman(new clang::FileManager(clang::FileSystemOptions())); +#if LLVM_VERSION_MAJOR >= 10 + clang::tooling::ToolInvocation TI(std::move(args), std::make_unique(), fman.get()); +#else ATDNAAction* action = new ATDNAAction(); clang::tooling::ToolInvocation TI(std::move(args), action, fman.get()); +#endif if (!TI.run()) return 1; - return 0; } diff --git a/src/athena/Compression.cpp b/src/athena/Compression.cpp index 4ede938..47bd6e0 100644 --- a/src/athena/Compression.cpp +++ b/src/athena/Compression.cpp @@ -12,36 +12,25 @@ namespace athena::io::Compression { atInt32 decompressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint32 dstLen) { z_stream strm = {}; - strm.total_in = strm.avail_in = srcLen; - strm.total_out = strm.avail_out = dstLen; - strm.next_in = (Bytef*)src; - strm.next_out = (Bytef*)dst; - + strm.avail_in = srcLen; + strm.avail_out = dstLen; + strm.next_in = const_cast(src); + strm.next_out = dst; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; - atInt32 err = -1; - atInt32 ret = -1; + atInt32 ret; + // 15 window bits, and the | 16 tells zlib to to detect if using gzip or zlib + ret = inflateInit2(&strm, MAX_WBITS | 16); - err = inflateInit(&strm); // 15 window bits, and the +32 tells zlib to to detect if using gzip or zlib - - if (err == Z_OK) { - err = inflate(&strm, Z_FINISH); - - if (err == Z_STREAM_END) + if (ret == Z_OK) { + ret = inflate(&strm, Z_FINISH); + if (ret == Z_STREAM_END) { ret = strm.total_out; - else { - inflateEnd(&strm); - return err; } - } else { - inflateEnd(&strm); - return err; } - inflateEnd(&strm); - return ret; } diff --git a/src/athena/MemoryReader.cpp b/src/athena/MemoryReader.cpp index f92d54f..9b60938 100644 --- a/src/athena/MemoryReader.cpp +++ b/src/athena/MemoryReader.cpp @@ -104,7 +104,7 @@ atUint8* MemoryReader::data() const { atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) { if (m_position >= m_length) { if (m_globalErr) - atFatal(FMT_STRING("Position {:08X} outside stream bounds "), m_position); + atError(FMT_STRING("Position {:08X} outside stream bounds "), m_position); m_position = m_length; setError(); return 0;