Recently I switched from the default vscode Microsoft C/C++ extension to clangd because of performance reasons.
I found out clangd lacks one of my most liked features from the Microsoft extension: overloaded operators are not highlighted as functions.
This is a very essential semantic indicator, because overloaded operators can have very different functionality.
This patch adds syntax highlighting for the following patterns:
- operator calls to overloaded operators, e.g.
std::cout << 42; // `<<` is highlighted as if it were a function. std::string s; s = "Hello, World!"; // `=` ditto some_map["key"] = "value"; // `[` and `]` some_functor(1, 2, 3); // `(` and `)`
- function calls to overloaded operators in function notation, e.g.
operator<<(std::cout, 42); // `operator<<` some_ptr->some_field.operator++(); // `operator++` operator delete(ptr) // `operator delete`
- any reference to an overloaded operator function, e.g.
const auto &fn = some_struct.operator<<; // `operator<<`