Skip to content

Commit 7b53e13

Browse files
authored
RuleContext: remove superfluous operator== (#4799)
The operator== in RuleContext only mildly looked like the virtual operator== in the base class: it does take a different parameter and was not const. Even if it was selected, the implementation is exactly the same as in the base class (comparing pointers). This results in warnings by the compiler complaining about a shadowed method: ``` /usr/include/antlr4-runtime/tree/ParseTree.h:50:18: warning: ‘virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const’ was hidden [-Woverloaded-virtual=] 50 | virtual bool operator == (const ParseTree &other) const; | ^~~~~~~~ /usr/include/antlr4-runtime/RuleContext.h:135:10: note: by ‘bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)’ 135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison. ``` Verdict: remove operator to not confuse humans and computers. Signed-off-by: Henner Zeller <[email protected]>
1 parent 5435f14 commit 7b53e13

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

runtime/Cpp/runtime/src/RuleContext.h

-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ namespace antlr4 {
138138

139139
virtual std::string toString(const std::vector<std::string> &ruleNames, RuleContext *stop);
140140

141-
bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
142-
143141
private:
144142
void InitializeInstanceFields();
145143
};

0 commit comments

Comments
 (0)