forked from jasder/antlr
Improve coding style of auto usages
This commit is contained in:
parent
621b933c7a
commit
88dffba62e
|
@ -242,4 +242,5 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2020/02/21, StochasticTinkr, Daniel Pitts, github@coloraura.com
|
||||
2020/03/17, XsongyangX, Song Yang, songyang1218@gmail.com
|
||||
2020/04/07, deniskyashif, Denis Kyashif, denis.kyashif@gmail.com
|
||||
2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com
|
||||
2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com
|
||||
2020/06/02, cohomology, Kilian Kilger, kkilger AT gmail.com
|
||||
|
|
|
@ -190,7 +190,7 @@ void Parser::removeParseListeners() {
|
|||
}
|
||||
|
||||
void Parser::triggerEnterRuleEvent() {
|
||||
for (auto listener : _parseListeners) {
|
||||
for (auto *listener : _parseListeners) {
|
||||
listener->enterEveryRule(_ctx);
|
||||
_ctx->enterRule(listener);
|
||||
}
|
||||
|
@ -307,14 +307,14 @@ Token* Parser::consume() {
|
|||
tree::ErrorNode *node = createErrorNode(o);
|
||||
_ctx->addChild(node);
|
||||
if (_parseListeners.size() > 0) {
|
||||
for (auto listener : _parseListeners) {
|
||||
for (auto *listener : _parseListeners) {
|
||||
listener->visitErrorNode(node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tree::TerminalNode *node = _ctx->addChild(createTerminalNode(o));
|
||||
if (_parseListeners.size() > 0) {
|
||||
for (auto listener : _parseListeners) {
|
||||
for (auto *listener : _parseListeners) {
|
||||
listener->visitTerminal(node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ void ParserRuleContext::copyFrom(ParserRuleContext *ctx) {
|
|||
|
||||
// copy any error nodes to alt label node
|
||||
if (!ctx->children.empty()) {
|
||||
for (auto child : ctx->children) {
|
||||
auto errorNode = dynamic_cast<ErrorNode *>(child);
|
||||
for (auto *child : ctx->children) {
|
||||
auto *errorNode = dynamic_cast<ErrorNode *>(child);
|
||||
if (errorNode != nullptr) {
|
||||
errorNode->setParent(this);
|
||||
children.push_back(errorNode);
|
||||
|
@ -82,7 +82,7 @@ tree::TerminalNode* ParserRuleContext::getToken(size_t ttype, size_t i) {
|
|||
}
|
||||
|
||||
size_t j = 0; // what token with ttype have we found?
|
||||
for (auto o : children) {
|
||||
for (auto *o : children) {
|
||||
if (is<tree::TerminalNode *>(o)) {
|
||||
tree::TerminalNode *tnode = dynamic_cast<tree::TerminalNode *>(o);
|
||||
Token *symbol = tnode->getSymbol();
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace antlr4 {
|
|||
template<typename T>
|
||||
std::vector<T *> getRuleContexts() {
|
||||
std::vector<T *> contexts;
|
||||
for (auto child : children) {
|
||||
for (auto *child : children) {
|
||||
if (antlrcpp::is<T *>(child)) {
|
||||
contexts.push_back(dynamic_cast<T *>(child));
|
||||
}
|
||||
|
|
|
@ -26,28 +26,28 @@ void ProxyErrorListener::removeErrorListeners() {
|
|||
void ProxyErrorListener::syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line,
|
||||
size_t charPositionInLine, const std::string &msg, std::exception_ptr e) {
|
||||
|
||||
for (auto listener : _delegates) {
|
||||
for (auto *listener : _delegates) {
|
||||
listener->syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||
bool exact, const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) {
|
||||
for (auto listener : _delegates) {
|
||||
for (auto *listener : _delegates) {
|
||||
listener->reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
||||
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) {
|
||||
for (auto listener : _delegates) {
|
||||
for (auto *listener : _delegates) {
|
||||
listener->reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||
size_t prediction, atn::ATNConfigSet *configs) {
|
||||
for (auto listener : _delegates) {
|
||||
for (auto *listener : _delegates) {
|
||||
listener->reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens_) : tokens(tokens_)
|
|||
|
||||
TokenStreamRewriter::~TokenStreamRewriter() {
|
||||
for (auto program : _programs) {
|
||||
for (auto operation : program.second) {
|
||||
for (auto *operation : program.second) {
|
||||
delete operation;
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
|
|||
|
||||
// Wipe prior inserts within range
|
||||
std::vector<InsertBeforeOp *> inserts = getKindOfOps<InsertBeforeOp>(rewrites, i);
|
||||
for (auto iop : inserts) {
|
||||
for (auto *iop : inserts) {
|
||||
if (iop->index == rop->index) {
|
||||
// E.g., insert before 2, delete 2..2; update replace
|
||||
// text to include insert before, kill insert
|
||||
|
@ -339,7 +339,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
|
|||
}
|
||||
// Drop any prior replaces contained within
|
||||
std::vector<ReplaceOp*> prevReplaces = getKindOfOps<ReplaceOp>(rewrites, i);
|
||||
for (auto prevRop : prevReplaces) {
|
||||
for (auto *prevRop : prevReplaces) {
|
||||
if (prevRop->index >= rop->index && prevRop->lastIndex <= rop->lastIndex) {
|
||||
// delete replace as it's a no-op.
|
||||
delete rewrites[prevRop->instructionIndex];
|
||||
|
@ -373,7 +373,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
|
|||
// combine current insert with prior if any at same index
|
||||
|
||||
std::vector<InsertBeforeOp *> prevInserts = getKindOfOps<InsertBeforeOp>(rewrites, i);
|
||||
for (auto prevIop : prevInserts) {
|
||||
for (auto *prevIop : prevInserts) {
|
||||
if (prevIop->index == iop->index) { // combine objects
|
||||
// convert to strings...we're in process of toString'ing
|
||||
// whole token buffer so no lazy eval issue with any templates
|
||||
|
@ -385,7 +385,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
|
|||
}
|
||||
// look for replaces where iop.index is in range; error
|
||||
std::vector<ReplaceOp*> prevReplaces = getKindOfOps<ReplaceOp>(rewrites, i);
|
||||
for (auto rop : prevReplaces) {
|
||||
for (auto *rop : prevReplaces) {
|
||||
if (iop->index == rop->index) {
|
||||
rop->text = catOpText(&iop->text, &rop->text);
|
||||
delete rewrites[i];
|
||||
|
|
|
@ -183,7 +183,7 @@ std::string ATN::toString() const {
|
|||
ss << "states (" << states.size() << ") {" << std::endl;
|
||||
|
||||
size_t index = 0;
|
||||
for (auto state : states) {
|
||||
for (auto *state : states) {
|
||||
if (state == nullptr) {
|
||||
ss << " " << index++ << ": nul" << std::endl;
|
||||
} else {
|
||||
|
@ -193,7 +193,7 @@ std::string ATN::toString() const {
|
|||
}
|
||||
|
||||
index = 0;
|
||||
for (auto state : decisionToState) {
|
||||
for (auto *state : decisionToState) {
|
||||
if (state == nullptr) {
|
||||
ss << " " << index++ << ": nul" << std::endl;
|
||||
} else {
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace std {
|
|||
size_t operator() (const std::vector<Ref<ATNConfig>> &vector) const
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
for (auto &config : vector) {
|
||||
for (const auto &config : vector) {
|
||||
seed ^= config->hashCode() + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
}
|
||||
return seed;
|
||||
|
|
|
@ -166,7 +166,7 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
}
|
||||
|
||||
data.push_back(containsEof ? 1 : 0);
|
||||
for (auto &interval : set.getIntervals()) {
|
||||
for (const auto &interval : set.getIntervals()) {
|
||||
if (interval.a == -1) {
|
||||
if (interval.b == -1) {
|
||||
continue;
|
||||
|
|
|
@ -17,7 +17,7 @@ ATNState::ATNState() {
|
|||
}
|
||||
|
||||
ATNState::~ATNState() {
|
||||
for (auto transition : transitions) {
|
||||
for (auto *transition : transitions) {
|
||||
delete transition;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -774,7 +774,7 @@ std::pair<ATNConfigSet *, ATNConfigSet *> ParserATNSimulator::splitAccordingToSe
|
|||
BitSet ParserATNSimulator::evalSemanticContext(std::vector<dfa::DFAState::PredPrediction*> predPredictions,
|
||||
ParserRuleContext *outerContext, bool complete) {
|
||||
BitSet predictions;
|
||||
for (auto prediction : predPredictions) {
|
||||
for (auto *prediction : predPredictions) {
|
||||
if (prediction->pred == SemanticContext::NONE) {
|
||||
predictions.set(prediction->alt);
|
||||
if (!complete) {
|
||||
|
|
|
@ -46,7 +46,7 @@ DFA::DFA(DFA &&other) : atnStartState(other.atnStartState), decision(other.decis
|
|||
|
||||
DFA::~DFA() {
|
||||
bool s0InList = (s0 == nullptr);
|
||||
for (auto state : states) {
|
||||
for (auto *state : states) {
|
||||
if (state == s0)
|
||||
s0InList = true;
|
||||
delete state;
|
||||
|
@ -88,7 +88,7 @@ void DFA::setPrecedenceStartState(int precedence, DFAState *startState, SingleWr
|
|||
|
||||
std::vector<DFAState *> DFA::getStates() const {
|
||||
std::vector<DFAState *> result;
|
||||
for (auto state : states)
|
||||
for (auto *state : states)
|
||||
result.push_back(state);
|
||||
|
||||
std::sort(result.begin(), result.end(), [](DFAState *o1, DFAState *o2) -> bool {
|
||||
|
|
|
@ -27,7 +27,7 @@ std::string DFASerializer::toString() const {
|
|||
|
||||
std::stringstream ss;
|
||||
std::vector<DFAState *> states = _dfa->getStates();
|
||||
for (auto s : states) {
|
||||
for (auto *s : states) {
|
||||
for (size_t i = 0; i < s->edges.size(); i++) {
|
||||
DFAState *t = s->edges[i];
|
||||
if (t != nullptr && t->stateNumber != INT32_MAX) {
|
||||
|
|
|
@ -42,7 +42,7 @@ DFAState::DFAState(std::unique_ptr<ATNConfigSet> configs_) : DFAState() {
|
|||
}
|
||||
|
||||
DFAState::~DFAState() {
|
||||
for (auto predicate : predicates) {
|
||||
for (auto *predicate : predicates) {
|
||||
delete predicate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ void IntervalSet::add(const Interval &addition) {
|
|||
|
||||
IntervalSet IntervalSet::Or(const std::vector<IntervalSet> &sets) {
|
||||
IntervalSet result;
|
||||
for (auto &s : sets) {
|
||||
for (const auto &s : sets) {
|
||||
result.addAll(s);
|
||||
}
|
||||
return result;
|
||||
|
@ -271,7 +271,7 @@ bool IntervalSet::contains(ssize_t el) const {
|
|||
if (el < _intervals[0].a) // list is sorted and el is before first interval; not here
|
||||
return false;
|
||||
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
if (el >= interval.a && el <= interval.b) {
|
||||
return true; // found in this interval
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ std::vector<Interval> const& IntervalSet::getIntervals() const {
|
|||
|
||||
size_t IntervalSet::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
hash = MurmurHash::update(hash, interval.a);
|
||||
hash = MurmurHash::update(hash, interval.b);
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ std::string IntervalSet::toString(bool elemAreChar) const {
|
|||
}
|
||||
|
||||
bool firstEntry = true;
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
if (!firstEntry)
|
||||
ss << ", ";
|
||||
firstEntry = false;
|
||||
|
@ -395,7 +395,7 @@ std::string IntervalSet::toString(const dfa::Vocabulary &vocabulary) const {
|
|||
}
|
||||
|
||||
bool firstEntry = true;
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
if (!firstEntry)
|
||||
ss << ", ";
|
||||
firstEntry = false;
|
||||
|
@ -436,7 +436,7 @@ std::string IntervalSet::elementName(const dfa::Vocabulary &vocabulary, ssize_t
|
|||
|
||||
size_t IntervalSet::size() const {
|
||||
size_t result = 0;
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
result += size_t(interval.b - interval.a + 1);
|
||||
}
|
||||
return result;
|
||||
|
@ -444,7 +444,7 @@ size_t IntervalSet::size() const {
|
|||
|
||||
std::vector<ssize_t> IntervalSet::toList() const {
|
||||
std::vector<ssize_t> result;
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
ssize_t a = interval.a;
|
||||
ssize_t b = interval.b;
|
||||
for (ssize_t v = a; v <= b; v++) {
|
||||
|
@ -456,7 +456,7 @@ std::vector<ssize_t> IntervalSet::toList() const {
|
|||
|
||||
std::set<ssize_t> IntervalSet::toSet() const {
|
||||
std::set<ssize_t> result;
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
ssize_t a = interval.a;
|
||||
ssize_t b = interval.b;
|
||||
for (ssize_t v = a; v <= b; v++) {
|
||||
|
@ -468,7 +468,7 @@ std::set<ssize_t> IntervalSet::toSet() const {
|
|||
|
||||
ssize_t IntervalSet::get(size_t i) const {
|
||||
size_t index = 0;
|
||||
for (auto &interval : _intervals) {
|
||||
for (const auto &interval : _intervals) {
|
||||
ssize_t a = interval.a;
|
||||
ssize_t b = interval.b;
|
||||
for (ssize_t v = a; v <= b; v++) {
|
||||
|
|
|
@ -79,7 +79,7 @@ struct ANTLR4CPP_PUBLIC Any
|
|||
if (_ptr == a._ptr)
|
||||
return *this;
|
||||
|
||||
auto old_ptr = _ptr;
|
||||
auto * old_ptr = _ptr;
|
||||
_ptr = a.clone();
|
||||
|
||||
if (old_ptr)
|
||||
|
|
|
@ -16,7 +16,7 @@ std::string Arrays::listToString(const std::vector<std::string> &list, const std
|
|||
bool firstEntry = true;
|
||||
|
||||
ss << '[';
|
||||
for (auto &entry : list) {
|
||||
for (const auto &entry : list) {
|
||||
ss << entry;
|
||||
if (firstEntry) {
|
||||
ss << separator;
|
||||
|
@ -32,7 +32,7 @@ template <>
|
|||
std::string Arrays::toString(const std::vector<antlr4::tree::ParseTree*> &source) {
|
||||
std::string result = "[";
|
||||
bool firstEntry = true;
|
||||
for (auto value : source) {
|
||||
for (auto *value : source) {
|
||||
result += value->toStringTree();
|
||||
if (firstEntry) {
|
||||
result += ", ";
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace antlrcpp {
|
|||
|
||||
case ' ':
|
||||
if (escapeSpaces) {
|
||||
result += "·";
|
||||
result += "\u00B7";
|
||||
break;
|
||||
}
|
||||
// else fall through
|
||||
|
|
|
@ -21,11 +21,10 @@ namespace antlrcpp {
|
|||
template<typename T>
|
||||
inline std::string utf32_to_utf8(T const& data)
|
||||
{
|
||||
// Don't make the converter static or we have to serialize access to it.
|
||||
thread_local UTF32Converter converter;
|
||||
UTF32Converter converter;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||
auto p = reinterpret_cast<const int32_t *>(data.data());
|
||||
const auto p = reinterpret_cast<const int32_t *>(data.data());
|
||||
return converter.to_bytes(p, p + data.size());
|
||||
#else
|
||||
return converter.to_bytes(data);
|
||||
|
@ -34,7 +33,7 @@ namespace antlrcpp {
|
|||
|
||||
inline UTF32String utf8_to_utf32(const char* first, const char* last)
|
||||
{
|
||||
thread_local UTF32Converter converter;
|
||||
UTF32Converter converter;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||
auto r = converter.from_bytes(first, last);
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace tree {
|
|||
}
|
||||
|
||||
void reset() {
|
||||
for (auto entry : _allocated)
|
||||
for (auto * entry : _allocated)
|
||||
delete entry;
|
||||
_allocated.clear();
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ std::vector<ParseTree *> Trees::getDescendants(ParseTree *t) {
|
|||
std::size_t n = t->children.size();
|
||||
for (size_t i = 0 ; i < n ; i++) {
|
||||
auto descentants = getDescendants(t->children[i]);
|
||||
for (auto entry: descentants) {
|
||||
for (auto *entry: descentants) {
|
||||
nodes.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ std::vector<ParseTreeMatch> ParseTreePattern::findAll(ParseTree *tree, const std
|
|||
xpath::XPath finder(_matcher->getParser(), xpath);
|
||||
std::vector<ParseTree *> subtrees = finder.evaluate(tree);
|
||||
std::vector<ParseTreeMatch> matches;
|
||||
for (auto t : subtrees) {
|
||||
for (auto *t : subtrees) {
|
||||
ParseTreeMatch aMatch = match(t);
|
||||
if (aMatch.succeeded()) {
|
||||
matches.push_back(aMatch);
|
||||
|
|
|
@ -137,7 +137,7 @@ std::vector<ParseTree *> XPath::evaluate(ParseTree *t) {
|
|||
|
||||
while (i < elements.size()) {
|
||||
std::vector<ParseTree *> next;
|
||||
for (auto node : work) {
|
||||
for (auto *node : work) {
|
||||
if (!node->children.empty()) {
|
||||
// only try to match next element if it has children
|
||||
// e.g., //func/*/stat might have a token node for which
|
||||
|
|
|
@ -18,7 +18,7 @@ XPathRuleElement::XPathRuleElement(const std::string &ruleName, size_t ruleIndex
|
|||
std::vector<ParseTree *> XPathRuleElement::evaluate(ParseTree *t) {
|
||||
// return all children of t that match nodeName
|
||||
std::vector<ParseTree *> nodes;
|
||||
for (auto c : t->children) {
|
||||
for (auto *c : t->children) {
|
||||
if (antlrcpp::is<ParserRuleContext *>(c)) {
|
||||
ParserRuleContext *ctx = dynamic_cast<ParserRuleContext *>(c);
|
||||
if ((ctx->getRuleIndex() == _ruleIndex && !_invert) || (ctx->getRuleIndex() != _ruleIndex && _invert)) {
|
||||
|
|
|
@ -21,7 +21,7 @@ XPathTokenElement::XPathTokenElement(const std::string &tokenName, size_t tokenT
|
|||
std::vector<ParseTree *> XPathTokenElement::evaluate(ParseTree *t) {
|
||||
// return all children of t that match nodeName
|
||||
std::vector<ParseTree *> nodes;
|
||||
for (auto c : t->children) {
|
||||
for (auto *c : t->children) {
|
||||
if (antlrcpp::is<TerminalNode *>(c)) {
|
||||
TerminalNode *tnode = dynamic_cast<TerminalNode *>(c);
|
||||
if ((tnode->getSymbol()->getType() == _tokenType && !_invert) || (tnode->getSymbol()->getType() != _tokenType && _invert)) {
|
||||
|
|
Loading…
Reference in New Issue