Skip to content
Closed
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
11 changes: 6 additions & 5 deletions runtime/Cpp/runtime/src/ParserRuleContext.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: This is the superfluous and Byte Order Mark, that was removed while editing. This is UTF-8, not UTF-16.

* 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 "RuleContext.h"
#include "support/Casts.h"
#include "support/CPPUtils.h"

namespace antlr4 {
Expand Down Expand Up @@ -102,9 +103,9 @@ namespace antlr4 {

size_t j = 0; // what element have we found with ctxType?
for (auto &child : children) {
if (antlrcpp::is<T *>(child)) {
if (antlrcpp::is<T *>(child)) { // TODO: avoid slow is<> call.
if (j++ == i) {
return dynamic_cast<T *>(child);
return antlrcpp::downCast<T *>(child);
}
}
}
Expand All @@ -115,8 +116,8 @@ namespace antlr4 {
std::vector<T *> getRuleContexts() {
std::vector<T *> contexts;
for (auto *child : children) {
if (antlrcpp::is<T *>(child)) {
contexts.push_back(dynamic_cast<T *>(child));
if (antlrcpp::is<T *>(child)) { // TODO: avoid slow is<> call
contexts.push_back(antlrcpp::downCast<T *>(child));
}
}

Expand Down