Merge pull request #1902 from jm-mikkelsen/master

C++ runtime changes for high warning levels
This commit is contained in:
Terence Parr 2017-06-26 08:18:38 -07:00 committed by GitHub
commit 990d4848b2
128 changed files with 480 additions and 159 deletions

View File

@ -148,4 +148,5 @@ YYYY/MM/DD, github id, Full name, email
2017/05/11, jimallman, Jim Allman, jim@ibang.com
2017/05/26, waf, Will Fuqua, wafuqua@gmail.com
2017/05/29, kosak, Corey Kosak, kosak@kosak.com
2017/06/10, jm-mikkelsen, Jan Martin Mikkelsen, janm@transactionware.com
2017/06/25, alimg, Alim Gökkaya, alim.gokkaya@gmail.com

View File

@ -0,0 +1,5 @@
#include "ANTLRErrorListener.h"
antlr4::ANTLRErrorListener::~ANTLRErrorListener()
{
}

View File

@ -16,7 +16,7 @@ namespace antlr4 {
/// How to emit recognition errors (an interface in Java).
class ANTLR4CPP_PUBLIC ANTLRErrorListener {
public:
virtual ~ANTLRErrorListener() {};
virtual ~ANTLRErrorListener();
/// <summary>
/// Upon syntax error, notify any interested parties. This is not how to

View File

@ -0,0 +1,5 @@
#include "ANTLRErrorStrategy.h"
antlr4::ANTLRErrorStrategy::~ANTLRErrorStrategy()
{
}

View File

@ -32,7 +32,7 @@ namespace antlr4 {
/// <summary>
/// Reset the error handler state for the specified {@code recognizer}. </summary>
/// <param name="recognizer"> the parser instance </param>
virtual ~ANTLRErrorStrategy() {};
virtual ~ANTLRErrorStrategy();
virtual void reset(Parser *recognizer) = 0;

View File

@ -71,7 +71,7 @@ size_t ANTLRInputStream::LA(ssize_t i) {
return 0; // undefined
}
ssize_t position = (ssize_t)p;
ssize_t position = static_cast<ssize_t>(p);
if (i < 0) {
i++; // e.g., translate LA(-1) to use offset i=0; then _data[p+0-1]
if ((position + i - 1) < 0) {
@ -79,11 +79,11 @@ size_t ANTLRInputStream::LA(ssize_t i) {
}
}
if ((position + i - 1) >= (ssize_t)_data.size()) {
if ((position + i - 1) >= static_cast<ssize_t>(_data.size())) {
return IntStream::EOF;
}
return _data[(size_t)(position + i - 1)];
return _data[static_cast<size_t>((position + i - 1))];
}
size_t ANTLRInputStream::LT(ssize_t i) {
@ -123,8 +123,8 @@ std::string ANTLRInputStream::getText(const Interval &interval) {
return "";
}
size_t start = interval.a;
size_t stop = interval.b;
size_t start = static_cast<size_t>(interval.a);
size_t stop = static_cast<size_t>(interval.b);
if (stop >= _data.size()) {

View File

@ -18,7 +18,7 @@ void BailErrorStrategy::recover(Parser *recognizer, std::exception_ptr e) {
context->exception = e;
if (context->parent == nullptr)
break;
context = (ParserRuleContext *)context->parent;
context = static_cast<ParserRuleContext *>(context->parent);
} while (true);
try {
@ -42,7 +42,7 @@ Token* BailErrorStrategy::recoverInline(Parser *recognizer) {
context->exception = exception;
if (context->parent == nullptr)
break;
context = (ParserRuleContext *)context->parent;
context = static_cast<ParserRuleContext *>(context->parent);
} while (true);
try {

View File

@ -96,7 +96,7 @@ size_t BufferedTokenStream::fetch(size_t n) {
std::unique_ptr<Token> t(_tokenSource->nextToken());
if (is<WritableToken *>(t.get())) {
(static_cast<WritableToken *>(t.get()))->setTokenIndex((int)_tokens.size());
(static_cast<WritableToken *>(t.get()))->setTokenIndex(_tokens.size());
}
_tokens.push_back(std::move(t));
@ -272,7 +272,7 @@ ssize_t BufferedTokenStream::previousTokenOnChannel(size_t i, size_t channel) {
}
if (i == 0)
return i;
break;
i--;
}
return i;
@ -289,7 +289,7 @@ std::vector<Token *> BufferedTokenStream::getHiddenTokensToRight(size_t tokenInd
size_t from = tokenIndex + 1;
// if none onchannel to right, nextOnChannel=-1 so set to = last token
if (nextOnChannel == -1) {
to = (ssize_t)size() - 1;
to = static_cast<ssize_t>(size() - 1);
} else {
to = nextOnChannel;
}
@ -313,11 +313,11 @@ std::vector<Token *> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenInde
}
ssize_t prevOnChannel = previousTokenOnChannel(tokenIndex - 1, Lexer::DEFAULT_TOKEN_CHANNEL);
if (prevOnChannel == (ssize_t)tokenIndex - 1) {
if (prevOnChannel == static_cast<ssize_t>(tokenIndex - 1)) {
return { };
}
// if none onchannel to left, prevOnChannel=-1 then from=0
size_t from = (size_t)(prevOnChannel + 1);
size_t from = static_cast<size_t>(prevOnChannel + 1);
size_t to = tokenIndex - 1;
return filterForChannel(from, to, channel);
@ -336,7 +336,7 @@ std::vector<Token *> BufferedTokenStream::filterForChannel(size_t from, size_t t
hidden.push_back(t);
}
} else {
if (t->getChannel() == (size_t)channel) {
if (t->getChannel() == static_cast<size_t>(channel)) {
hidden.push_back(t);
}
}

View File

@ -13,7 +13,7 @@ namespace antlr4 {
/// A source of characters for an ANTLR lexer.
class ANTLR4CPP_PUBLIC CharStream : public IntStream {
public:
virtual ~CharStream() = 0;
virtual ~CharStream();
/// This method returns the text for a range of characters within this input
/// stream. This method is guaranteed to not throw an exception if the

View File

@ -35,7 +35,7 @@ CommonToken::CommonToken(std::pair<TokenSource*, CharStream*> source, size_t typ
_start = start;
_stop = stop;
if (_source.first != nullptr) {
_line = (int)source.first->getLine();
_line = static_cast<int>(source.first->getLine());
_charPositionInLine = source.first->getCharPositionInLine();
}
}

View File

@ -13,7 +13,7 @@ using namespace antlr4;
const Ref<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
CommonTokenFactory::CommonTokenFactory(bool copyText) : copyText(copyText) {
CommonTokenFactory::CommonTokenFactory(bool copyText_) : copyText(copyText_) {
}
CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) {

View File

@ -12,8 +12,8 @@ using namespace antlr4;
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : CommonTokenStream(tokenSource, Token::DEFAULT_CHANNEL) {
}
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, size_t channel)
: BufferedTokenStream(tokenSource), channel(channel) {
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, size_t channel_)
: BufferedTokenStream(tokenSource), channel(channel_) {
}
ssize_t CommonTokenStream::adjustSeekIndex(size_t i) {
@ -25,7 +25,7 @@ Token* CommonTokenStream::LB(size_t k) {
return nullptr;
}
ssize_t i = (ssize_t)_p;
ssize_t i = static_cast<ssize_t>(_p);
size_t n = 1;
// find k good tokens looking backwards
while (n <= k) {
@ -46,7 +46,7 @@ Token* CommonTokenStream::LT(ssize_t k) {
return nullptr;
}
if (k < 0) {
return LB((size_t)-k);
return LB(static_cast<size_t>(-k));
}
size_t i = _p;
ssize_t n = 1; // we know tokens[p] is a good one

View File

@ -62,18 +62,18 @@ void DefaultErrorStrategy::reportError(Parser *recognizer, const RecognitionExce
beginErrorCondition(recognizer);
if (is<const NoViableAltException *>(&e)) {
reportNoViableAlternative(recognizer, (const NoViableAltException &)e);
reportNoViableAlternative(recognizer, static_cast<const NoViableAltException &>(e));
} else if (is<const InputMismatchException *>(&e)) {
reportInputMismatch(recognizer, (const InputMismatchException &)e);
reportInputMismatch(recognizer, static_cast<const InputMismatchException &>(e));
} else if (is<const FailedPredicateException *>(&e)) {
reportFailedPredicate(recognizer, (const FailedPredicateException &)e);
reportFailedPredicate(recognizer, static_cast<const FailedPredicateException &>(e));
} else if (is<const RecognitionException *>(&e)) {
recognizer->notifyErrorListeners(e.getOffendingToken(), e.what(), std::current_exception());
}
}
void DefaultErrorStrategy::recover(Parser *recognizer, std::exception_ptr /*e*/) {
if (lastErrorIndex == (int)recognizer->getInputStream()->index() &&
if (lastErrorIndex == static_cast<int>(recognizer->getInputStream()->index()) &&
lastErrorStates.contains(recognizer->getState())) {
// uh oh, another error at same token index and previously-visited
@ -82,7 +82,7 @@ void DefaultErrorStrategy::recover(Parser *recognizer, std::exception_ptr /*e*/)
// at least to prevent an infinite loop; this is a failsafe.
recognizer->consume();
}
lastErrorIndex = (int)recognizer->getInputStream()->index();
lastErrorIndex = static_cast<int>(recognizer->getInputStream()->index());
lastErrorStates.add(recognizer->getState());
misc::IntervalSet followSet = getErrorRecoverySet(recognizer);
consumeUntil(recognizer, followSet);
@ -312,7 +312,7 @@ misc::IntervalSet DefaultErrorStrategy::getErrorRecoverySet(Parser *recognizer)
if (ctx->parent == nullptr)
break;
ctx = (RuleContext *)ctx->parent;
ctx = static_cast<RuleContext *>(ctx->parent);
}
recoverSet.remove(Token::EPSILON);

View File

@ -17,7 +17,7 @@ using namespace antlr4;
DiagnosticErrorListener::DiagnosticErrorListener() : DiagnosticErrorListener(true) {
}
DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly) : exactOnly(exactOnly) {
DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly_) : exactOnly(exactOnly_) {
}
void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
@ -53,7 +53,7 @@ void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const
std::string DiagnosticErrorListener::getDecisionDescription(Parser *recognizer, const dfa::DFA &dfa) {
size_t decision = dfa.decision;
size_t ruleIndex = ((atn::ATNState*)dfa.atnStartState)->ruleIndex;
size_t ruleIndex = (reinterpret_cast<atn::ATNState*>(dfa.atnStartState))->ruleIndex;
const std::vector<std::string>& ruleNames = recognizer->getRuleNames();
if (ruleIndex == INVALID_INDEX || ruleIndex >= ruleNames.size()) {

View File

@ -22,3 +22,43 @@ IOException::IOException(const std::string &msg) : std::exception(), _message(ms
const char* IOException::what() const NOEXCEPT {
return _message.c_str();
}
//------------------ IllegalStateException -----------------------------------------------------------------------------
IllegalStateException::~IllegalStateException() {
}
//------------------ IllegalArgumentException --------------------------------------------------------------------------
IllegalArgumentException::~IllegalArgumentException() {
}
//------------------ NullPointerException ------------------------------------------------------------------------------
NullPointerException::~NullPointerException() {
}
//------------------ IndexOutOfBoundsException -------------------------------------------------------------------------
IndexOutOfBoundsException::~IndexOutOfBoundsException() {
}
//------------------ UnsupportedOperationException ---------------------------------------------------------------------
UnsupportedOperationException::~UnsupportedOperationException() {
}
//------------------ EmptyStackException -------------------------------------------------------------------------------
EmptyStackException::~EmptyStackException() {
}
//------------------ CancellationException -----------------------------------------------------------------------------
CancellationException::~CancellationException() {
}
//------------------ ParseCancellationException ------------------------------------------------------------------------
ParseCancellationException::~ParseCancellationException() {
}

View File

@ -21,32 +21,51 @@ namespace antlr4 {
class ANTLR4CPP_PUBLIC IllegalStateException : public RuntimeException {
public:
IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {};
IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {}
IllegalStateException(IllegalStateException const&) = default;
~IllegalStateException();
IllegalStateException& operator=(IllegalStateException const&) = default;
};
class ANTLR4CPP_PUBLIC IllegalArgumentException : public RuntimeException {
public:
IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {};
IllegalArgumentException(IllegalArgumentException const&) = default;
IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {}
~IllegalArgumentException();
IllegalArgumentException& operator=(IllegalArgumentException const&) = default;
};
class ANTLR4CPP_PUBLIC NullPointerException : public RuntimeException {
public:
NullPointerException(const std::string &msg = "") : RuntimeException(msg) {};
NullPointerException(const std::string &msg = "") : RuntimeException(msg) {}
NullPointerException(NullPointerException const&) = default;
~NullPointerException();
NullPointerException& operator=(NullPointerException const&) = default;
};
class ANTLR4CPP_PUBLIC IndexOutOfBoundsException : public RuntimeException {
public:
IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {};
IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {}
IndexOutOfBoundsException(IndexOutOfBoundsException const&) = default;
~IndexOutOfBoundsException();
IndexOutOfBoundsException& operator=(IndexOutOfBoundsException const&) = default;
};
class ANTLR4CPP_PUBLIC UnsupportedOperationException : public RuntimeException {
public:
UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {};
UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {}
UnsupportedOperationException(UnsupportedOperationException const&) = default;
~UnsupportedOperationException();
UnsupportedOperationException& operator=(UnsupportedOperationException const&) = default;
};
class ANTLR4CPP_PUBLIC EmptyStackException : public RuntimeException {
public:
EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {};
EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {}
EmptyStackException(EmptyStackException const&) = default;
~EmptyStackException();
EmptyStackException& operator=(EmptyStackException const&) = default;
};
// IOException is not a runtime exception (in the java hierarchy).
@ -63,12 +82,18 @@ namespace antlr4 {
class ANTLR4CPP_PUBLIC CancellationException : public IllegalStateException {
public:
CancellationException(const std::string &msg = "") : IllegalStateException(msg) {};
CancellationException(const std::string &msg = "") : IllegalStateException(msg) {}
CancellationException(CancellationException const&) = default;
~CancellationException();
CancellationException& operator=(CancellationException const&) = default;
};
class ANTLR4CPP_PUBLIC ParseCancellationException : public CancellationException {
public:
ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {};
ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {}
ParseCancellationException(ParseCancellationException const&) = default;
~ParseCancellationException();
ParseCancellationException& operator=(ParseCancellationException const&) = default;
};
} // namespace antlr4

View File

@ -28,8 +28,8 @@ FailedPredicateException::FailedPredicateException(Parser *recognizer, const std
atn::ATNState *s = recognizer->getInterpreter<atn::ATNSimulator>()->atn.states[recognizer->getState()];
atn::Transition *transition = s->transitions[0];
if (is<atn::PredicateTransition*>(transition)) {
_ruleIndex = ((atn::PredicateTransition *)transition)->ruleIndex;
_predicateIndex = ((atn::PredicateTransition *)transition)->predIndex;
_ruleIndex = static_cast<atn::PredicateTransition *>(transition)->ruleIndex;
_predicateIndex = static_cast<atn::PredicateTransition *>(transition)->predIndex;
} else {
_ruleIndex = 0;
_predicateIndex = 0;

View File

@ -13,3 +13,6 @@ InputMismatchException::InputMismatchException(Parser *recognizer)
: RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(),
recognizer->getCurrentToken()) {
}
InputMismatchException::~InputMismatchException() {
}

View File

@ -16,6 +16,9 @@ namespace antlr4 {
class ANTLR4CPP_PUBLIC InputMismatchException : public RecognitionException {
public:
InputMismatchException(Parser *recognizer);
InputMismatchException(InputMismatchException const&) = default;
~InputMismatchException();
InputMismatchException& operator=(InputMismatchException const&) = default;
};
} // namespace antlr4

View File

@ -8,3 +8,5 @@
using namespace antlr4;
const std::string IntStream::UNKNOWN_SOURCE_NAME = "<unknown>";
IntStream::~IntStream() = default;

View File

@ -27,7 +27,7 @@ namespace antlr4 {
/// </summary>
class ANTLR4CPP_PUBLIC IntStream {
public:
static const size_t EOF = (size_t)-1;
static const size_t EOF = std::numeric_limits<size_t>::max();
/// The value returned by <seealso cref="#LA LA()"/> when the end of the stream is
/// reached.
@ -40,7 +40,7 @@ namespace antlr4 {
/// </summary>
static const std::string UNKNOWN_SOURCE_NAME;
virtual ~IntStream() {};
virtual ~IntStream();
/// <summary>
/// Consumes the current symbol in the stream. This method has the following

View File

@ -19,8 +19,8 @@ namespace antlr4 {
class ANTLR4CPP_PUBLIC Lexer : public Recognizer, public TokenSource {
public:
static const size_t DEFAULT_MODE = 0;
static const size_t MORE = (size_t)-2;
static const size_t SKIP = (size_t)-3;
static const size_t MORE = static_cast<size_t>(-2);
static const size_t SKIP = static_cast<size_t>(-3);
static const size_t DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
static const size_t HIDDEN = Token::HIDDEN_CHANNEL;

View File

@ -28,7 +28,7 @@ atn::ATNConfigSet* LexerNoViableAltException::getDeadEndConfigs() {
std::string LexerNoViableAltException::toString() {
std::string symbol;
if (_startIndex < getInputStream()->size()) {
symbol = ((CharStream *)getInputStream())->getText(misc::Interval(_startIndex, _startIndex));
symbol = static_cast<CharStream *>(getInputStream())->getText(misc::Interval(_startIndex, _startIndex));
symbol = antlrcpp::escapeWhitespace(symbol, false);
}
std::string format = "LexerNoViableAltException('" + symbol + "')";

View File

@ -11,7 +11,7 @@
using namespace antlr4;
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens) : ListTokenSource(std::move(tokens), "") {
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_) : ListTokenSource(std::move(tokens_), "") {
}
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_, const std::string &sourceName_)
@ -32,7 +32,7 @@ ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_, co
size_t stop = std::max(INVALID_INDEX, start - 1);
tokens.emplace_back((_factory->create({ this, getInputStream() }, Token::EOF, "EOF",
Token::DEFAULT_CHANNEL, start, stop, (int)lastToken->getLine(), lastToken->getCharPositionInLine())));
Token::DEFAULT_CHANNEL, start, stop, static_cast<int>(lastToken->getLine()), lastToken->getCharPositionInLine())));
}
}

View File

@ -33,7 +33,10 @@ using namespace antlrcpp;
std::map<std::vector<uint16_t>, atn::ATN> Parser::bypassAltsAtnCache;
Parser::TraceListener::TraceListener(Parser *outerInstance) : outerInstance(outerInstance) {
Parser::TraceListener::TraceListener(Parser *outerInstance_) : outerInstance(outerInstance_) {
}
Parser::TraceListener::~TraceListener() {
}
void Parser::TraceListener::enterEveryRule(ParserRuleContext *ctx) {
@ -56,6 +59,9 @@ void Parser::TraceListener::exitEveryRule(ParserRuleContext *ctx) {
Parser::TrimToSizeListener Parser::TrimToSizeListener::INSTANCE;
Parser::TrimToSizeListener::~TrimToSizeListener() {
}
void Parser::TrimToSizeListener::enterEveryRule(ParserRuleContext * /*ctx*/) {
}

View File

@ -21,7 +21,7 @@ namespace antlr4 {
class TraceListener : public tree::ParseTreeListener {
public:
TraceListener(Parser *outerInstance);
virtual ~TraceListener() {};
virtual ~TraceListener();
virtual void enterEveryRule(ParserRuleContext *ctx) override;
virtual void visitTerminal(tree::TerminalNode *node) override;
@ -36,7 +36,7 @@ namespace antlr4 {
public:
static TrimToSizeListener INSTANCE;
virtual ~TrimToSizeListener() {};
virtual ~TrimToSizeListener();
virtual void enterEveryRule(ParserRuleContext *ctx) override;
virtual void visitTerminal(tree::TerminalNode *node) override;
@ -375,7 +375,7 @@ namespace antlr4 {
*/
bool isTrace() const;
tree::ParseTreeTracker& getTreeTracker() { return _tracker; };
tree::ParseTreeTracker& getTreeTracker() { return _tracker; }
/** How to create a token leaf node associated with a parent.
* Typically, the terminal node to create is not a function of the parent

View File

@ -174,19 +174,19 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
// We are at the start of a left recursive rule's (...)* loop
// and we're not taking the exit branch of loop.
InterpreterRuleContext *localctx = createInterpreterRuleContext(_parentContextStack.top().first,
_parentContextStack.top().second, (int)_ctx->getRuleIndex());
pushNewRecursionContext(localctx, _atn.ruleToStartState[p->ruleIndex]->stateNumber, (int)_ctx->getRuleIndex());
_parentContextStack.top().second, static_cast<int>(_ctx->getRuleIndex()));
pushNewRecursionContext(localctx, _atn.ruleToStartState[p->ruleIndex]->stateNumber, static_cast<int>(_ctx->getRuleIndex()));
}
break;
case atn::Transition::ATOM:
match((int)((atn::AtomTransition*)(transition))->_label);
match(static_cast<int>(static_cast<atn::AtomTransition*>(transition)->_label));
break;
case atn::Transition::RANGE:
case atn::Transition::SET:
case atn::Transition::NOT_SET:
if (!transition->matches((int)_input->LA(1), Token::MIN_USER_TOKEN_TYPE, Lexer::MAX_CHAR_VALUE)) {
if (!transition->matches(static_cast<int>(_input->LA(1)), Token::MIN_USER_TOKEN_TYPE, Lexer::MAX_CHAR_VALUE)) {
recoverInline();
}
matchWildcard();
@ -198,11 +198,11 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
case atn::Transition::RULE:
{
atn::RuleStartState *ruleStartState = (atn::RuleStartState*)(transition->target);
atn::RuleStartState *ruleStartState = static_cast<atn::RuleStartState*>(transition->target);
size_t ruleIndex = ruleStartState->ruleIndex;
InterpreterRuleContext *newctx = createInterpreterRuleContext(_ctx, p->stateNumber, ruleIndex);
if (ruleStartState->isLeftRecursiveRule) {
enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, ((atn::RuleTransition*)(transition))->precedence);
enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, static_cast<atn::RuleTransition*>(transition)->precedence);
} else {
enterRule(newctx, transition->target->stateNumber, ruleIndex);
}
@ -211,7 +211,7 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
case atn::Transition::PREDICATE:
{
atn::PredicateTransition *predicateTransition = (atn::PredicateTransition*)(transition);
atn::PredicateTransition *predicateTransition = static_cast<atn::PredicateTransition*>(transition);
if (!sempred(_ctx, predicateTransition->ruleIndex, predicateTransition->predIndex)) {
throw FailedPredicateException(this);
}
@ -220,15 +220,15 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
case atn::Transition::ACTION:
{
atn::ActionTransition *actionTransition = (atn::ActionTransition*)(transition);
atn::ActionTransition *actionTransition = static_cast<atn::ActionTransition*>(transition);
action(_ctx, actionTransition->ruleIndex, actionTransition->actionIndex);
}
break;
case atn::Transition::PRECEDENCE:
{
if (!precpred(_ctx, ((atn::PrecedencePredicateTransition*)(transition))->precedence)) {
throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(((atn::PrecedencePredicateTransition*)(transition))->precedence) + ")");
if (!precpred(_ctx, static_cast<atn::PrecedencePredicateTransition*>(transition)->precedence)) {
throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(static_cast<atn::PrecedencePredicateTransition*>(transition)->precedence) + ")");
}
}
break;
@ -283,7 +283,7 @@ void ParserInterpreter::recover(RecognitionException &e) {
if (_input->index() == i) {
// no input consumed, better add an error node
if (is<InputMismatchException *>(&e)) {
InputMismatchException &ime = (InputMismatchException&)e;
InputMismatchException &ime = static_cast<InputMismatchException&>(e);
Token *tok = e.getOffendingToken();
size_t expectedTokenType = ime.getExpectedTokens().getMinElement(); // get any element
_errorToken = getTokenFactory()->create({ tok->getTokenSource(), tok->getTokenSource()->getInputStream() },

View File

@ -27,6 +27,9 @@ RecognitionException::RecognitionException(const std::string &message, Recognize
}
}
RecognitionException::~RecognitionException() {
}
size_t RecognitionException::getOffendingState() const {
return _offendingState;
}

View File

@ -33,7 +33,9 @@ namespace antlr4 {
Token *offendingToken = nullptr);
RecognitionException(const std::string &message, Recognizer *recognizer, IntStream *input,
ParserRuleContext *ctx, Token *offendingToken = nullptr);
~RecognitionException() {}
RecognitionException(RecognitionException const&) = default;
~RecognitionException();
RecognitionException& operator=(RecognitionException const&) = default;
/// Get the ATN state number the parser was in at the time the error
/// occurred. For NoViableAltException and

View File

@ -27,6 +27,9 @@ Recognizer::Recognizer() {
_proxListener.addErrorListener(&ConsoleErrorListener::INSTANCE);
}
Recognizer::~Recognizer() {
}
dfa::Vocabulary const& Recognizer::getVocabulary() const {
static dfa::Vocabulary vocabulary = dfa::Vocabulary::fromTokenNames(getTokenNames());
return vocabulary;

View File

@ -11,10 +11,13 @@ namespace antlr4 {
class ANTLR4CPP_PUBLIC Recognizer {
public:
static const size_t EOF = (size_t)-1;
static const size_t EOF = std::numeric_limits<size_t>::max();
Recognizer();
virtual ~Recognizer() {};
Recognizer(Recognizer const&) = delete;
virtual ~Recognizer();
Recognizer& operator=(Recognizer const&) = delete;
/** Used to print out token names like ID during debugging and
* error reporting. The generated parsers implement a method

View File

@ -19,10 +19,10 @@ RuleContext::RuleContext() {
InitializeInstanceFields();
}
RuleContext::RuleContext(RuleContext *parent, size_t invokingState) {
RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) {
InitializeInstanceFields();
this->parent = parent;
this->invokingState = invokingState;
this->parent = parent_;
this->invokingState = invokingState_;
}
int RuleContext::depth() {
@ -31,7 +31,7 @@ int RuleContext::depth() {
while (true) {
if (p->parent == nullptr)
break;
p = (RuleContext *)p->parent;
p = static_cast<RuleContext *>(p->parent);
n++;
}
return n;
@ -112,7 +112,7 @@ std::string RuleContext::toString(const std::vector<std::string> &ruleNames, Rul
if (currentParent->parent == nullptr) // No parent anymore.
break;
currentParent = (RuleContext *)currentParent->parent;
currentParent = static_cast<RuleContext *>(currentParent->parent);
if (!ruleNames.empty() || !currentParent->isEmpty()) {
ss << " ";
}

View File

@ -0,0 +1,4 @@
#include "Token.h"
antlr4::Token::~Token() {
}

View File

@ -18,11 +18,11 @@ namespace antlr4 {
/// During lookahead operations, this "token" signifies we hit rule end ATN state
/// and did not follow it despite needing to.
static const size_t EPSILON = (size_t)-2;
static const size_t EPSILON = std::numeric_limits<size_t>::max() - 1;
static const size_t MIN_USER_TOKEN_TYPE = 1;
static const size_t EOF = IntStream::EOF;
virtual ~Token() {};
virtual ~Token();
/// All tokens go to the parser (unless skip() is called in that rule)
/// on a particular "channel". The parser tunes to a particular channel

View File

@ -15,7 +15,7 @@ namespace antlr4 {
template<typename Symbol>
class ANTLR4CPP_PUBLIC TokenFactory {
public:
virtual ~TokenFactory() {};
virtual ~TokenFactory() {}
/// This is the method used to create tokens in the lexer and in the
/// error handling strategy. If text!=null, than the start and stop positions

View File

@ -0,0 +1,4 @@
#include "TokenSource.h"
antlr4::TokenSource::~TokenSource() {
}

View File

@ -26,7 +26,7 @@ namespace antlr4 {
/// </summary>
class ANTLR4CPP_PUBLIC TokenSource {
public:
virtual ~TokenSource() {};
virtual ~TokenSource();
/// Return a <seealso cref="Token"/> object from your input stream (usually a
/// <seealso cref="CharStream"/>). Do not fail/return upon lexing error; keep chewing

View File

@ -14,19 +14,23 @@ using namespace antlr4;
using antlr4::misc::Interval;
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance, size_t index)
: outerInstance(outerInstance) {
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance_, size_t index_)
: outerInstance(outerInstance_) {
InitializeInstanceFields();
this->index = index;
this->index = index_;
}
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance, size_t index,
const std::string& text) : outerInstance(outerInstance) {
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance_, size_t index_,
const std::string& text_) : outerInstance(outerInstance_) {
InitializeInstanceFields();
this->index = index;
this->text = text;
this->index = index_;
this->text = text_;
}
TokenStreamRewriter::RewriteOperation::~RewriteOperation()
{
}
size_t TokenStreamRewriter::RewriteOperation::execute(std::string * /*buf*/) {
@ -45,8 +49,8 @@ void TokenStreamRewriter::RewriteOperation::InitializeInstanceFields() {
index = 0;
}
TokenStreamRewriter::InsertBeforeOp::InsertBeforeOp(TokenStreamRewriter *outerInstance, size_t index, const std::string& text)
: RewriteOperation(outerInstance, index, text), outerInstance(outerInstance) {
TokenStreamRewriter::InsertBeforeOp::InsertBeforeOp(TokenStreamRewriter *outerInstance_, size_t index_, const std::string& text_)
: RewriteOperation(outerInstance_, index_, text_), outerInstance(outerInstance_) {
}
size_t TokenStreamRewriter::InsertBeforeOp::execute(std::string *buf) {
@ -57,8 +61,8 @@ size_t TokenStreamRewriter::InsertBeforeOp::execute(std::string *buf) {
return index + 1;
}
TokenStreamRewriter::ReplaceOp::ReplaceOp(TokenStreamRewriter *outerInstance, size_t from, size_t to, const std::string& text)
: RewriteOperation(outerInstance, from, text), outerInstance(outerInstance) {
TokenStreamRewriter::ReplaceOp::ReplaceOp(TokenStreamRewriter *outerInstance_, size_t from, size_t to, const std::string& text)
: RewriteOperation(outerInstance_, from, text), outerInstance(outerInstance_) {
InitializeInstanceFields();
lastIndex = to;
@ -84,7 +88,7 @@ void TokenStreamRewriter::ReplaceOp::InitializeInstanceFields() {
const std::string TokenStreamRewriter::DEFAULT_PROGRAM_NAME = "default";
TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens) : tokens(tokens) {
TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens_) : tokens(tokens_) {
_programs[DEFAULT_PROGRAM_NAME].reserve(PROGRAM_INIT_SIZE);
}
@ -413,10 +417,10 @@ std::string TokenStreamRewriter::catOpText(std::string *a, std::string *b) {
std::string x = "";
std::string y = "";
if (a != nullptr) {
x = std::string(*a);
x = *a;
}
if (b != nullptr) {
y = std::string(*b);
y = *b;
}
return x + y;
}

View File

@ -164,7 +164,7 @@ namespace antlr4 {
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index);
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
virtual ~RewriteOperation() {};
virtual ~RewriteOperation();
/// Execute the rewrite operation by possibly adding to the buffer.
/// Return the index of the next token to operate on.

View File

@ -22,6 +22,9 @@ Vocabulary::Vocabulary(const std::vector<std::string> &literalNames,
// See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
}
Vocabulary::~Vocabulary() {
}
Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
if (tokenNames.empty()) {
return EMPTY_VOCABULARY;

View File

@ -14,7 +14,9 @@ namespace dfa {
/// interface.
class ANTLR4CPP_PUBLIC Vocabulary {
public:
virtual ~Vocabulary() {};
Vocabulary(Vocabulary const&) = default;
virtual ~Vocabulary();
Vocabulary& operator=(Vocabulary const&) = default;
/// Gets an empty <seealso cref="Vocabulary"/> instance.
///
@ -24,7 +26,7 @@ namespace dfa {
/// except <seealso cref="Token#EOF"/>.</para>
static const Vocabulary EMPTY_VOCABULARY;
Vocabulary() {};
Vocabulary() {}
/// <summary>
/// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified

View File

@ -0,0 +1,4 @@
#include "WritableToken.h"
antlr4::WritableToken::~WritableToken() {
}

View File

@ -11,6 +11,7 @@ namespace antlr4 {
class ANTLR4CPP_PUBLIC WritableToken : public Token {
public:
virtual ~WritableToken();
virtual void setText(const std::string &text) = 0;
virtual void setType(size_t ttype) = 0;
virtual void setLine(size_t line) = 0;

View File

@ -12,6 +12,7 @@
#include <fstream>
#include <iostream>
#include <iterator>
#include <limits>
#include <limits.h>
#include <list>
#include <map>
@ -76,7 +77,7 @@
class ANTLR4CPP_PUBLIC std::exception; // Needed for VS 2015.
#elif __APPLE__
#elif defined(__APPLE__)
typedef std::u32string UTF32String;
#define GUID_CFUUID
@ -124,5 +125,5 @@
#undef EOF
#endif
#define INVALID_INDEX (size_t)-1
#define INVALID_INDEX std::numeric_limits<size_t>::max()
template<class T> using Ref = std::shared_ptr<T>;

View File

@ -36,7 +36,7 @@ ATN::ATN(ATN &&other) {
modeToStartState = std::move(other.modeToStartState);
}
ATN::ATN(ATNType grammarType, size_t maxTokenType) : grammarType(grammarType), maxTokenType(maxTokenType) {
ATN::ATN(ATNType grammarType_, size_t maxTokenType_) : grammarType(grammarType_), maxTokenType(maxTokenType_) {
}
ATN::~ATN() {
@ -88,9 +88,12 @@ misc::IntervalSet ATN::nextTokens(ATNState *s, RuleContext *ctx) const {
}
misc::IntervalSet& ATN::nextTokens(ATNState *s) const {
if (s->nextTokenWithinRule.isEmpty()) {
s->nextTokenWithinRule = nextTokens(s, nullptr);
s->nextTokenWithinRule.setReadOnly(true);
if (!s->nextTokenWithinRule.isReadOnly()) {
std::unique_lock<std::mutex> lock { _mutex };
if (!s->nextTokenWithinRule.isReadOnly()) {
s->nextTokenWithinRule = nextTokens(s, nullptr);
s->nextTokenWithinRule.setReadOnly(true);
}
}
return s->nextTokenWithinRule;
}

View File

@ -103,6 +103,9 @@ namespace atn {
virtual misc::IntervalSet getExpectedTokens(size_t stateNumber, RuleContext *context) const;
std::string toString() const;
private:
mutable std::mutex _mutex;
};
} // namespace atn

View File

@ -13,19 +13,19 @@ using namespace antlr4::atn;
const size_t ATNConfig::SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
ATNConfig::ATNConfig(ATNState *state, size_t alt, Ref<PredictionContext> const& context)
: ATNConfig(state, alt, context, SemanticContext::NONE) {
ATNConfig::ATNConfig(ATNState *state_, size_t alt_, Ref<PredictionContext> const& context_)
: ATNConfig(state_, alt_, context_, SemanticContext::NONE) {
}
ATNConfig::ATNConfig(ATNState *state, size_t alt, Ref<PredictionContext> const& context, Ref<SemanticContext> const& semanticContext)
: state(state), alt(alt), context(context), semanticContext(semanticContext) {
ATNConfig::ATNConfig(ATNState *state_, size_t alt_, Ref<PredictionContext> const& context_, Ref<SemanticContext> const& semanticContext_)
: state(state_), alt(alt_), context(context_), semanticContext(semanticContext_) {
reachesIntoOuterContext = 0;
}
ATNConfig::ATNConfig(Ref<ATNConfig> const& c) : ATNConfig(c, c->state, c->context, c->semanticContext) {
}
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state) : ATNConfig(c, state, c->context, c->semanticContext) {
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state_) : ATNConfig(c, state_, c->context, c->semanticContext) {
}
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<SemanticContext> const& semanticContext)

View File

@ -85,7 +85,9 @@ namespace atn {
ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context);
ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context, Ref<SemanticContext> const& semanticContext);
ATNConfig(ATNConfig const&) = default;
virtual ~ATNConfig();
ATNConfig& operator=(ATNConfig const&) = default;
virtual size_t hashCode() const;

View File

@ -18,6 +18,9 @@ ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *
this->generateRuleBypassTransitions = options->generateRuleBypassTransitions;
}
ATNDeserializationOptions::~ATNDeserializationOptions() {
}
const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() {
return defaultOptions;
}

View File

@ -21,7 +21,9 @@ namespace atn {
public:
ATNDeserializationOptions();
ATNDeserializationOptions(ATNDeserializationOptions *options);
virtual ~ATNDeserializationOptions() {};
ATNDeserializationOptions(ATNDeserializationOptions const&) = default;
virtual ~ATNDeserializationOptions();
ATNDeserializationOptions& operator=(ATNDeserializationOptions const&) = default;
static const ATNDeserializationOptions& getDefaultOptions();

View File

@ -51,6 +51,8 @@
#include "atn/ATNDeserializer.h"
#include <string>
using namespace antlr4;
using namespace antlr4::atn;
using namespace antlrcpp;
@ -108,6 +110,9 @@ ATNDeserializer::ATNDeserializer(): ATNDeserializer(ATNDeserializationOptions::g
ATNDeserializer::ATNDeserializer(const ATNDeserializationOptions& dso): deserializationOptions(dso) {
}
ATNDeserializer::~ATNDeserializer() {
}
/**
* This value should never change. Updates following this version are
* reflected as change in the unique ID SERIALIZED_UUID.

View File

@ -21,7 +21,7 @@ namespace atn {
ATNDeserializer();
ATNDeserializer(const ATNDeserializationOptions& dso);
virtual ~ATNDeserializer() {};
virtual ~ATNDeserializer();
static Guid toUUID(const unsigned short *data, size_t offset);

View File

@ -50,6 +50,8 @@ ATNSerializer::ATNSerializer(ATN *atn, const std::vector<std::string> &tokenName
_tokenNames = tokenNames;
}
ATNSerializer::~ATNSerializer() { }
std::vector<size_t> ATNSerializer::serialize() {
std::vector<size_t> data;
data.push_back(ATNDeserializer::SERIALIZED_VERSION);

View File

@ -14,7 +14,7 @@ namespace atn {
ATNSerializer(ATN *atn);
ATNSerializer(ATN *atn, const std::vector<std::string> &tokenNames);
virtual ~ATNSerializer() {};
virtual ~ATNSerializer();
/// <summary>
/// Serialize state descriptors, edge descriptors, and decision->state map

View File

@ -23,6 +23,9 @@ ATNSimulator::ATNSimulator(const ATN &atn, PredictionContextCache &sharedContext
: atn(atn), _sharedContextCache(sharedContextCache) {
}
ATNSimulator::~ATNSimulator() {
}
void ATNSimulator::clearDFA() {
throw UnsupportedOperationException("This ATN simulator does not support clearing the DFA.");
}

View File

@ -20,7 +20,7 @@ namespace atn {
const ATN &atn;
ATNSimulator(const ATN &atn, PredictionContextCache &sharedContextCache);
virtual ~ATNSimulator() {};
virtual ~ATNSimulator();
virtual void reset() = 0;

View File

@ -77,7 +77,7 @@ namespace atn {
virtual ~ATNState();
static const size_t INITIAL_NUM_TRANSITIONS = 4;
static const size_t INVALID_STATE_NUMBER = (size_t)-1;
static const size_t INVALID_STATE_NUMBER = std::numeric_limits<size_t>::max();
enum {
ATN_INVALID_TYPE = 0,

View File

@ -9,3 +9,6 @@ using namespace antlr4::atn;
AbstractPredicateTransition::AbstractPredicateTransition(ATNState *target) : Transition(target) {
}
AbstractPredicateTransition::~AbstractPredicateTransition() {
}

View File

@ -16,6 +16,7 @@ namespace atn {
public:
AbstractPredicateTransition(ATNState *target);
~AbstractPredicateTransition();
};

View File

@ -21,6 +21,9 @@ ArrayPredictionContext::ArrayPredictionContext(std::vector<Ref<PredictionContext
assert(returnStates.size() > 0);
}
ArrayPredictionContext::~ArrayPredictionContext() {
}
bool ArrayPredictionContext::isEmpty() const {
// Since EMPTY_RETURN_STATE can only appear in the last position, we don't need to verify that size == 1.
return returnStates[0] == EMPTY_RETURN_STATE;

View File

@ -27,7 +27,7 @@ namespace atn {
ArrayPredictionContext(Ref<SingletonPredictionContext> const& a);
ArrayPredictionContext(std::vector<Ref<PredictionContext>> const& parents_, std::vector<size_t> const& returnStates);
virtual ~ArrayPredictionContext() {};
virtual ~ArrayPredictionContext();
virtual bool isEmpty() const override;
virtual size_t size() const override;

View File

@ -0,0 +1,4 @@
#include "BlockStartState.h"
antlr4::atn::BlockStartState::~BlockStartState() {
}

View File

@ -13,6 +13,7 @@ namespace atn {
/// The start of a regular {@code (...)} block.
class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState {
public:
~BlockStartState();
BlockEndState *endState = nullptr;
};

View File

@ -25,6 +25,9 @@ using namespace antlrcpp;
LL1Analyzer::LL1Analyzer(const ATN &atn) : _atn(atn) {
}
LL1Analyzer::~LL1Analyzer() {
}
std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) const {
std::vector<misc::IntervalSet> look;

View File

@ -22,7 +22,7 @@ namespace atn {
const atn::ATN &_atn;
LL1Analyzer(const atn::ATN &atn);
virtual ~LL1Analyzer() {};
virtual ~LL1Analyzer();
/// <summary>
/// Calculates the SLL(1) expected lookahead set for each outgoing transition

View File

@ -31,6 +31,9 @@ using namespace antlr4;
using namespace antlr4::atn;
using namespace antlrcpp;
LexerATNSimulator::SimState::~SimState() {
}
void LexerATNSimulator::SimState::reset() {
index = INVALID_INDEX;
line = 0;
@ -82,8 +85,6 @@ size_t LexerATNSimulator::match(CharStream *input, size_t mode) {
} else {
return execATN(input, dfa.s0);
}
return Token::EOF;
}
void LexerATNSimulator::reset() {

View File

@ -17,7 +17,7 @@ namespace atn {
protected:
class SimState {
public:
virtual ~SimState() {};
virtual ~SimState();
protected:
size_t index;

View File

@ -0,0 +1,4 @@
#include "LexerAction.h"
antlr4::atn::LexerAction::~LexerAction() {
}

View File

@ -6,6 +6,7 @@
#pragma once
#include "atn/LexerActionType.h"
#include "antlr4-common.h"
namespace antlr4 {
namespace atn {
@ -20,7 +21,7 @@ namespace atn {
/// </summary>
class ANTLR4CPP_PUBLIC LexerAction {
public:
virtual ~LexerAction() {};
virtual ~LexerAction();
/// <summary>
/// Gets the serialization type of the lexer action.

View File

@ -19,6 +19,9 @@ LexerActionExecutor::LexerActionExecutor(const std::vector<Ref<LexerAction>> &le
: _lexerActions(lexerActions), _hashCode(generateHashCode()) {
}
LexerActionExecutor::~LexerActionExecutor() {
}
Ref<LexerActionExecutor> LexerActionExecutor::append(Ref<LexerActionExecutor> const& lexerActionExecutor,
Ref<LexerAction> const& lexerAction) {
if (lexerActionExecutor == nullptr) {

View File

@ -23,7 +23,7 @@ namespace atn {
/// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
/// <param name="lexerActions"> The lexer actions to execute. </param>
LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions);
virtual ~LexerActionExecutor() {};
virtual ~LexerActionExecutor();
/// <summary>
/// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for

View File

@ -5,6 +5,8 @@
#pragma once
#include "antlr4-common.h"
namespace antlr4 {
namespace atn {
@ -14,7 +16,7 @@ namespace atn {
/// @author Sam Harwell
/// @since 4.2
/// </summary>
enum class ANTLR4CPP_PUBLIC LexerActionType : size_t {
enum class LexerActionType : size_t {
/// <summary>
/// The type of a <seealso cref="LexerChannelAction"/> action.
/// </summary>

View File

@ -13,6 +13,9 @@ using namespace antlr4::atn;
ParseInfo::ParseInfo(ProfilingATNSimulator *atnSimulator) : _atnSimulator(atnSimulator) {
}
ParseInfo::~ParseInfo() {
}
std::vector<DecisionInfo> ParseInfo::getDecisionInfo() {
return _atnSimulator->getDecisionInfo();
}

View File

@ -17,7 +17,10 @@ namespace atn {
class ANTLR4CPP_PUBLIC ParseInfo {
public:
ParseInfo(ProfilingATNSimulator *atnSimulator);
virtual ~ParseInfo() {};
ParseInfo(ParseInfo const&) = default;
virtual ~ParseInfo();
ParseInfo& operator=(ParseInfo const&) = default;
/// <summary>
/// Gets an array of <seealso cref="DecisionInfo"/> instances containing the profiling

View File

@ -31,7 +31,7 @@ namespace atn {
// ml: originally Integer.MAX_VALUE, which would be (size_t)-1 for us, but this is already used in places where
// -1 is converted to unsigned, so we use a different value here. Any value does the job provided it doesn't
// conflict with real return states.
static const size_t EMPTY_RETURN_STATE = (size_t)-10;
static const size_t EMPTY_RETURN_STATE = std::numeric_limits<size_t>::max() - 9;
private:
static const size_t INITIAL_HASH = 1;

View File

@ -25,6 +25,8 @@ namespace atn {
RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState);
RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState);
RuleTransition(RuleTransition const&) = delete;
RuleTransition& operator=(RuleTransition const&) = delete;
virtual SerializationType getSerializationType() const override;

View File

@ -311,6 +311,9 @@ std::string SemanticContext::OR::toString() const {
const Ref<SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(INVALID_INDEX, INVALID_INDEX, false);
SemanticContext::~SemanticContext() {
}
bool SemanticContext::operator != (const SemanticContext &other) const {
return !(*this == other);
}
@ -366,3 +369,9 @@ std::vector<Ref<SemanticContext::PrecedencePredicate>> SemanticContext::filterPr
return result;
}
//------------------ Operator -----------------------------------------------------------------------------------------
SemanticContext::Operator::~Operator() {
}

View File

@ -43,7 +43,7 @@ namespace atn {
*/
static const Ref<SemanticContext> NONE;
virtual ~SemanticContext() {};
virtual ~SemanticContext();
virtual size_t hashCode() const = 0;
virtual std::string toString() const = 0;
@ -144,6 +144,8 @@ namespace atn {
*/
class ANTLR4CPP_PUBLIC SemanticContext::Operator : public SemanticContext {
public:
virtual ~Operator() override;
/**
* Gets the operands for the semantic context operator.
*

View File

@ -15,6 +15,9 @@ SingletonPredictionContext::SingletonPredictionContext(Ref<PredictionContext> co
assert(returnState != ATNState::INVALID_STATE_NUMBER);
}
SingletonPredictionContext::~SingletonPredictionContext() {
}
Ref<SingletonPredictionContext> SingletonPredictionContext::create(Ref<PredictionContext> const& parent, size_t returnState) {
if (returnState == EMPTY_RETURN_STATE && parent) {

View File

@ -21,7 +21,7 @@ namespace atn {
const size_t returnState;
SingletonPredictionContext(Ref<PredictionContext> const& parent, size_t returnState);
virtual ~SingletonPredictionContext() {};
virtual ~SingletonPredictionContext();
static Ref<SingletonPredictionContext> create(Ref<PredictionContext> const& parent, size_t returnState);

View File

@ -25,6 +25,9 @@ Transition::Transition(ATNState *target) {
this->target = target;
}
Transition::~Transition() {
}
bool Transition::isEpsilon() const {
return false;
}

View File

@ -45,7 +45,7 @@ namespace atn {
// ml: this is a reference into the ATN.
ATNState *target;
virtual ~Transition() {};
virtual ~Transition();
protected:
Transition(ATNState *target);
@ -67,6 +67,9 @@ namespace atn {
virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const = 0;
virtual std::string toString() const;
Transition(Transition const&) = delete;
Transition& operator=(Transition const&) = delete;
};
} // namespace atn

View File

@ -17,6 +17,9 @@ DFASerializer::DFASerializer(const DFA *dfa, const std::vector<std::string>& tok
DFASerializer::DFASerializer(const DFA *dfa, const Vocabulary &vocabulary) : _dfa(dfa), _vocabulary(vocabulary) {
}
DFASerializer::~DFASerializer() {
}
std::string DFASerializer::toString() const {
if (_dfa->s0 == nullptr) {
return "";

View File

@ -15,7 +15,7 @@ namespace dfa {
public:
DFASerializer(const DFA *dfa, const std::vector<std::string>& tnames);
DFASerializer(const DFA *dfa, const Vocabulary &vocabulary);
virtual ~DFASerializer() {};
virtual ~DFASerializer();
virtual std::string toString() const;

View File

@ -18,6 +18,9 @@ DFAState::PredPrediction::PredPrediction(const Ref<SemanticContext> &pred, int a
this->alt = alt;
}
DFAState::PredPrediction::~PredPrediction() {
}
std::string DFAState::PredPrediction::toString() {
return std::string("(") + pred->toString() + ", " + std::to_string(alt) + ")";
}

View File

@ -43,7 +43,7 @@ namespace dfa {
int alt;
PredPrediction(const Ref<atn::SemanticContext> &pred, int alt);
virtual ~PredPrediction() {};
virtual ~PredPrediction();
virtual std::string toString();

View File

@ -12,6 +12,9 @@ using namespace antlr4::dfa;
LexerDFASerializer::LexerDFASerializer(DFA *dfa) : DFASerializer(dfa, Vocabulary::EMPTY_VOCABULARY) {
}
LexerDFASerializer::~LexerDFASerializer() {
}
std::string LexerDFASerializer::getEdgeLabel(size_t i) const {
return std::string("'") + static_cast<char>(i) + "'";
}

View File

@ -13,7 +13,7 @@ namespace dfa {
class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer {
public:
LexerDFASerializer(DFA *dfa);
virtual ~LexerDFASerializer() {};
virtual ~LexerDFASerializer();
protected:
virtual std::string getEdgeLabel(size_t i) const override;

View File

@ -7,6 +7,7 @@
using namespace antlr4::misc;
Interval::~Interval() = default;
size_t antlr4::misc::numericToSymbol(ssize_t v) {
return (size_t)v;

View File

@ -28,7 +28,9 @@ namespace misc {
Interval();
explicit Interval(size_t a_, size_t b_); // For unsigned -> signed mappings.
Interval(ssize_t a_, ssize_t b_);
virtual ~Interval() {};
Interval(Interval const&) = default;
virtual ~Interval();
Interval& operator=(Interval const&) = default;
/// return number of elements between a and b inclusively. x..x is length 1.
/// if b < a, then length is 0. 9..10 has length 2.

View File

@ -46,6 +46,21 @@ IntervalSet::IntervalSet(int n, ...) : IntervalSet() {
}
}
IntervalSet::~IntervalSet()
{
}
IntervalSet& IntervalSet::operator=(const IntervalSet& other)
{
if (_readonly) {
throw IllegalStateException("can't alter read only IntervalSet");
}
_intervals.clear();
return addAll(other);
}
IntervalSet IntervalSet::of(ssize_t a) {
return IntervalSet({ Interval(a, a) });
}

View File

@ -6,6 +6,7 @@
#pragma once
#include "misc/Interval.h"
#include <atomic>
namespace antlr4 {
namespace misc {
@ -30,7 +31,7 @@ namespace misc {
protected:
/// The list of sorted, disjoint intervals.
std::vector<Interval> _intervals;
bool _readonly;
std::atomic<bool> _readonly;
public:
IntervalSet();
@ -38,7 +39,9 @@ namespace misc {
IntervalSet(const IntervalSet &set);
IntervalSet(int numArgs, ...);
virtual ~IntervalSet() {}
virtual ~IntervalSet();
IntervalSet& operator=(const IntervalSet &set);
/// Create a set with a single element, el.
static IntervalSet of(ssize_t a);

View File

@ -57,7 +57,7 @@ size_t MurmurHash::initialize(size_t seed) {
return seed;
}
#if _WIN32 || _WIN64
#if defined(_WIN32) || defined(_WIN64)
#if _WIN64
#define ENVIRONMENT64
#else
@ -65,8 +65,8 @@ size_t MurmurHash::initialize(size_t seed) {
#endif
#endif
#if __GNUC__
#if __x86_64__ || __ppc64__
#if defined(__GNUC__)
#if defined(__x86_64__) || defined(__ppc64__)
#define ENVIRONMENT64
#else
#define ENVIRONMENT32

View File

@ -0,0 +1,4 @@
#include "misc/Predicate.h"
antlr4::misc::Predicate::~Predicate() {
}

View File

@ -5,12 +5,14 @@
#pragma once
#include "antlr4-common.h"
namespace antlr4 {
namespace misc {
class ANTLR4CPP_PUBLIC Predicate {
public:
virtual ~Predicate() {};
virtual ~Predicate();
virtual bool test(tree::ParseTree *t) = 0;
};

View File

@ -0,0 +1,9 @@
#include "Any.h"
antlrcpp::Any::~Any()
{
delete _ptr;
}
antlrcpp::Any::Base::~Base() {
}

View File

@ -92,9 +92,7 @@ struct Any
return *this;
}
virtual ~Any() {
delete _ptr;
}
virtual ~Any();
virtual bool equals(Any other) const {
return _ptr == other._ptr;
@ -102,7 +100,7 @@ struct Any
private:
struct Base {
virtual ~Base() { }
virtual ~Base();
virtual Base* clone() const = 0;
};

View File

@ -21,14 +21,13 @@ namespace antlrcpp {
// Using RAII + a lambda to implement a "finally" replacement.
struct FinalAction {
FinalAction(std::function<void ()> f) : _cleanUp { f } {}
FinalAction(FinalAction &&other) {
_cleanUp = other._cleanUp;
_enabled = other._enabled;
FinalAction(FinalAction &&other) :
_cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) {
other._enabled = false; // Don't trigger the lambda after ownership has moved.
}
~FinalAction() { if (_enabled) _cleanUp(); }
void disable() { _enabled = false; };
void disable() { _enabled = false; }
private:
std::function<void ()> _cleanUp;
bool _enabled {true};
@ -52,7 +51,7 @@ namespace antlrcpp {
std::stringstream ss;
// typeid gives the mangled class name, but that's all what's possible
// in a portable way.
ss << typeid(o).name() << "@" << std::hex << (size_t)&o;
ss << typeid(o).name() << "@" << std::hex << reinterpret_cast<uintptr_t>(&o);
return ss.str();
}

View File

@ -24,7 +24,7 @@ namespace antlrcpp {
// Don't make the converter static or we have to serialize access to it.
UTF32Converter converter;
#if _MSC_VER >= 1900 && _MSC_VER < 2000
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
auto p = reinterpret_cast<const int32_t *>(data.data());
return converter.to_bytes(p, p + data.size());
#else
@ -36,7 +36,7 @@ namespace antlrcpp {
{
UTF32Converter converter;
#if _MSC_VER >= 1900 && _MSC_VER < 2000
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
auto r = converter.from_bytes(first, last);
i32string s = reinterpret_cast<const int32_t *>(r.data());
#else

View File

@ -99,7 +99,7 @@ Guid::Guid(const uint16_t *bytes, bool reverse)
}
// converts a single hex char to a number (0 - 15)
unsigned char hexDigitToChar(char ch)
static unsigned char hexDigitToChar(char ch)
{
if (ch > 47 && ch < 58)
return (unsigned char)(ch - 48);
@ -114,7 +114,7 @@ unsigned char hexDigitToChar(char ch)
}
// converts the two hexadecimal characters to an unsigned char (a byte)
unsigned char hexPairToChar(char a, char b)
static unsigned char hexPairToChar(char a, char b)
{
return hexDigitToChar(a) * 16 + hexDigitToChar(b);
}

Some files were not shown because too many files have changed in this diff Show More