Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if(MSVC)
else()
add_compile_options(-Wall -Weffc++ -Wextra)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wglobal-constructors -Wexit-time-destructors -Wweak-vtables -Wvla-extension)
add_compile_options(-Wglobal-constructors -Wexit-time-destructors -Wweak-vtables -Wvla-extension -Wctad-maybe-unsupported)
endif()

# Improve code security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <inflection/util/StringViewUtils.hpp>
#include <unicode/uchar.h>
#include <unicode/uscript.h>
#include <unicode/utf16.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type of change seems to be overly cautious, but it's OK to include.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get hard errors if I don't

error: use of undeclared identifier 'U16_PREV', error: use of undeclared identifier 'U16_GET', error: use of undeclared identifier 'U16_LENGTH'


namespace inflection::grammar::synthesis {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <inflection/tokenizer/Token_Tail.hpp>
#include <inflection/tokenizer/Tokenizer.hpp>
#include <inflection/tokenizer/TokenizerFactory.hpp>
#include <unicode/utf16.h>
#include <inflection/npc.hpp>
#include <memory>
#include <unicode/uchar.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <inflection/dictionary/PhraseProperties.hpp>
#include <inflection/grammar/synthesis/GrammemeConstants.hpp>
#include <inflection/grammar/synthesis/TrGrammarSynthesizer.hpp>
#include <unicode/utf16.h>
#include <inflection/util/LocaleConstants.hpp>
#include <inflection/util/LocaleUtils.hpp>
#include <inflection/util/StringViewUtils.hpp>
Expand Down
1 change: 1 addition & 0 deletions src/inflection/lang/StringFilterUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <icu4cxx/UnicodeSet.hpp>
#include <unicode/ulocdata.h>
#include <unicode/uscript.h>
#include <unicode/utf16.h>
#include <map>
#include <mutex>

Expand Down
1 change: 1 addition & 0 deletions src/inflection/tokenizer/ControlCleaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <inflection/tokenizer/TokenUtil.hpp>
#include <inflection/npc.hpp>
#include <unicode/uchar.h>
#include <unicode/utf16.h>

namespace inflection::tokenizer {

Expand Down
1 change: 1 addition & 0 deletions src/inflection/tokenizer/TokenUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <inflection/util/UnicodeSetUtils.hpp>
#include <inflection/npc.hpp>
#include <unicode/uchar.h>
#include <unicode/utf16.h>

namespace inflection::tokenizer {

Expand Down
1 change: 1 addition & 0 deletions src/inflection/util/StringViewUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <unicode/uchar.h>
#include <unicode/ustring.h>
#include <unicode/utf8.h>
#include <unicode/utf16.h>

namespace inflection::util {

Expand Down
1 change: 1 addition & 0 deletions src/inflection/util/UnicodeSetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <inflection/util/StringViewUtils.hpp>
#include <inflection/util/StringUtils.hpp>
#include <inflection/npc.hpp>
#include <unicode/utf16.h>

namespace inflection::util {

Expand Down
4 changes: 2 additions & 2 deletions test/src/inflection/dialog/DialogThreadSafetyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ TEST_CASE("DialogThreadSafetyTest#testInflect", "[multithreaded]")
}

const inflection::dialog::SemanticFeatureModel* currModel = nullptr;
std::atomic finished(false);
std::barrier barrier(processorCount + 1);
std::atomic<bool> finished(false);
std::barrier<> barrier(processorCount + 1);
for (int32_t count = 0; count < processorCount; count++) {
results[count].reserve(minimumNumberOfWords);
threads.emplace_back(testInflection, &currModel, &phrases, &constraints, &semanticFeatures, &barrier, &finished, count, &results[count]);
Expand Down
5 changes: 3 additions & 2 deletions test/src/inflection/dictionary/MMappedDictionaryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ TEST_CASE("MMappedDictionaryTest#testCompressedArray")
TEST_CASE("MMappedDictionaryTest#readInvalidFiles")
{
auto temporaryPath = createTemporaryFilePath();
::inflection::util::Finally finally([&temporaryPath]() noexcept {
auto cleanup = [&temporaryPath]() noexcept {
::std::filesystem::remove(temporaryPath);
});
};
::inflection::util::Finally<decltype(cleanup)> finally(cleanup);

::std::u16string uPath;
::inflection::util::StringUtils::convert(&uPath, temporaryPath.string());
Expand Down
8 changes: 5 additions & 3 deletions tools/buildDictionary/InflectionDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <algorithm>
#include <fstream>
#include <functional>
#include <map>
#include <set>
#include <string>
Expand Down Expand Up @@ -183,12 +184,13 @@ static ParsedInflectionData parseXMLDocument(const std::string& source,
LIBXML_TEST_VERSION

xmlDocPtr xmlDoc = nullptr;
inflection::util::Finally finally([&xmlDoc]() noexcept {
auto cleanup = [&xmlDoc]() noexcept {
if (xmlDoc != nullptr) {
xmlFreeDoc(xmlDoc);
}
xmlCleanupParser();
});
};
inflection::util::Finally<decltype(cleanup)> finally(cleanup);
std::u16string resourceName = inflection::util::StringViewUtils::to_u16string(source);
inflection::util::MemoryMappedFile mMapFile(resourceName);
auto xmlDocSize = mMapFile.getSize();
Expand Down Expand Up @@ -336,7 +338,7 @@ void InflectionDictionary::write(::std::ofstream& writer, DictionaryLogger& logg
npc(inflection_Suffixes)->write(writer);
logger.logWithOffset(locale.getName() + " inflection_Suffixes number=" + std::to_string(npc(inflection_Suffixes)->size()));

inflection::dictionary::metadata::CompressedArray compressedInflectionsArray(inflectionsArray);
inflection::dictionary::metadata::CompressedArray<int64_t> compressedInflectionsArray(inflectionsArray);
compressedInflectionsArray.serialize(writer);
logger.logWithOffset(locale.getName() + " inflections number=" + std::to_string(inflectionsArray.size()));

Expand Down
6 changes: 3 additions & 3 deletions tools/buildDictionary/LexicalDictionaryBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ void LexicalDictionaryBuilder::writeDictionary(::std::ofstream& writer,
propertyNameToKeyId,
propertyValuesStringContainer,
propertyValueMapsVector);
inflection::dictionary::metadata::CompressedArray propertyValueMaps(propertyValueMapsVector);
inflection::dictionary::metadata::CompressedArray<int32_t> propertyValueMaps(propertyValueMapsVector);
propertyValueMapsVector.clear();
propertyValueMapsVector.shrink_to_fit();

Expand All @@ -420,11 +420,11 @@ void LexicalDictionaryBuilder::writeDictionary(::std::ofstream& writer,
auto dataSingletonsResult = compressDataSingletons(wordsToData, logger, dictionary.getLocale());

{
CompressedArray dataSingletonsRaw(dataSingletonsResult.dataSingletons);
CompressedArray<uint64_t> dataSingletonsRaw(dataSingletonsResult.dataSingletons);
dataSingletonsResult.dataSingletons.clear();
dataSingletonsResult.dataSingletons.shrink_to_fit();

MarisaTrie wordsToDataTrie(dataSingletonsResult.use2Stage ? dataSingletonsResult.wordsToDataSingletons : wordsToData);
MarisaTrie<uint64_t> wordsToDataTrie(dataSingletonsResult.use2Stage ? dataSingletonsResult.wordsToDataSingletons : wordsToData);
dataSingletonsResult.wordsToDataSingletons.clear();
wordsToData.clear();

Expand Down
10 changes: 5 additions & 5 deletions tools/buildStringMap/buildStringMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ void writeBidirectionalTries(const char* outFileName,

::std::map<::std::u16string_view, int32_t> fromIdMap;
convertStringValuesToIdentifiers(fromMap, toSetMap, fromIdMap);
::inflection::dictionary::metadata::MarisaTrie fromTrie(fromIdMap);
::inflection::dictionary::metadata::MarisaTrie<int32_t> fromTrie(fromIdMap);

::std::map<::std::u16string_view, int32_t> toIdMap;
convertStringValuesToIdentifiers(toMap, fromSetMap, toIdMap);
::inflection::dictionary::metadata::MarisaTrie toTrie(toIdMap);
::inflection::dictionary::metadata::MarisaTrie<int32_t> toTrie(toIdMap);

std::ofstream out(outFileName, std::ios::binary);
if (!out) {
Expand Down Expand Up @@ -190,7 +190,7 @@ void writeSelfReferencingTrie(const char* outFileName,
::std::map<::std::u16string_view, int32_t> combinedIdMap;
convertStringValuesToIdentifiers(fromMap, combinedSetMap, combinedIdMap);
convertStringValuesToIdentifiers(toMap, combinedSetMap, combinedIdMap);
::inflection::dictionary::metadata::MarisaTrie combinedTrie(combinedIdMap);
::inflection::dictionary::metadata::MarisaTrie<int32_t> combinedTrie(combinedIdMap);

std::ofstream out(outFileName, std::ios::binary);
if (!out) {
Expand Down Expand Up @@ -284,11 +284,11 @@ int main(int argc, const char * const argv[]) {

::std::map<::std::u16string_view, int32_t> fromIdMap;
convertStringValuesToIdentifiers(fromMap, toSetMap, fromIdMap);
::inflection::dictionary::metadata::MarisaTrie fromTrie(fromIdMap);
::inflection::dictionary::metadata::MarisaTrie<int32_t> fromTrie(fromIdMap);

::std::map<::std::u16string_view, int32_t> toIdMap;
convertStringValuesToIdentifiers(toMap, fromSetMap, toIdMap);
::inflection::dictionary::metadata::MarisaTrie toTrie(toIdMap);
::inflection::dictionary::metadata::MarisaTrie<int32_t> toTrie(toIdMap);

std::ofstream out(outFileName, std::ios::binary);
if (!out) {
Expand Down
Loading