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
5 changes: 3 additions & 2 deletions .github/workflows/hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
windows-2022
]
compiler: [ clang, gcc ]
unity_build: [ ON, OFF ]
exclude:
- os: windows-2022
compiler: gcc
Expand Down Expand Up @@ -95,7 +96,7 @@ jobs:

cd runtime/Cpp

cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Debug
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -DCMAKE_UNITY_BUILD_BATCH_SIZE=20 -S . -B out/Debug
if %errorlevel% neq 0 exit /b %errorlevel%

cmake --build out/Debug -j %NUMBER_OF_PROCESSORS%
Expand Down Expand Up @@ -130,7 +131,7 @@ jobs:

cd runtime/Cpp

cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Debug
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -DCMAKE_UNITY_BUILD_BATCH_SIZE=20 -S . -B out/Debug
cmake --build out/Debug --parallel

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/antlr4cpp-vs2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
5 changes: 1 addition & 4 deletions runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cstring>

#include "atn/SingletonPredictionContext.h"
#include "atn/HashUtils.h"
#include "misc/MurmurHash.h"
#include "support/Casts.h"

Expand All @@ -17,10 +18,6 @@ using namespace antlrcpp;

namespace {

bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
return lhs == rhs || lhs == 0 || rhs == 0;
}

bool predictionContextEqual(const Ref<const PredictionContext> &lhs, const Ref<const PredictionContext> &rhs) {
// parent PredictionContext pointers can be null during full context mode and
// the ctxs are in an ArrayPredictionContext. If both are null, return true
Expand Down
18 changes: 18 additions & 0 deletions runtime/Cpp/runtime/src/atn/HashUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright (c) 2022 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/

#pragma once

#include <cstddef>

namespace antlr4 {
namespace atn {

inline bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
return lhs == rhs || lhs == 0 || rhs == 0;
}

} // namespace atn
} // namespace antlr4
5 changes: 1 addition & 4 deletions runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "misc/MurmurHash.h"
#include "atn/LexerIndexedCustomAction.h"
#include "atn/HashUtils.h"
#include "support/CPPUtils.h"
#include "support/Arrays.h"
#include "support/Casts.h"
Expand All @@ -18,10 +19,6 @@ using namespace antlrcpp;

namespace {

bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
return lhs == rhs || lhs == 0 || rhs == 0;
}

bool lexerActionEqual(const Ref<const LexerAction> &lhs, const Ref<const LexerAction> &rhs) {
return *lhs == *rhs;
}
Expand Down
9 changes: 1 addition & 8 deletions runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* can be found in the LICENSE.txt file in the project root.
*/

#include "atn/HashUtils.h"
#include "misc/MurmurHash.h"
#include "Lexer.h"
#include "support/CPPUtils.h"
Expand All @@ -15,14 +16,6 @@ using namespace antlr4::atn;
using namespace antlr4::misc;
using namespace antlrcpp;

namespace {

bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
return lhs == rhs || lhs == 0 || rhs == 0;
}

}

LexerIndexedCustomAction::LexerIndexedCustomAction(int offset, Ref<const LexerAction> action)
: LexerAction(LexerActionType::INDEXED_CUSTOM, true), _action(std::move(action)), _offset(offset) {}

Expand Down
9 changes: 1 addition & 8 deletions runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@

#include "support/Casts.h"
#include "misc/MurmurHash.h"
#include "atn/HashUtils.h"

using namespace antlr4::atn;
using namespace antlrcpp;

namespace {

bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
return lhs == rhs || lhs == 0 || rhs == 0;
}

}

SingletonPredictionContext::SingletonPredictionContext(Ref<const PredictionContext> parent, size_t returnState)
: PredictionContext(PredictionContextType::SINGLETON), parent(std::move(parent)), returnState(returnState) {
assert(returnState != ATNState::INVALID_STATE_NUMBER);
Expand Down