[PATCH] D119077: clangd SemanticHighlighting: added support for highlighting overloaded operators
Iannis de Zwart via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 6 05:54:18 PST 2022
iannisdezwart created this revision.
iannisdezwart added a reviewer: nridge.
iannisdezwart added a project: clang-tools-extra.
Herald added subscribers: usaxena95, kadircet, arphaman.
iannisdezwart requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
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:
1. 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 `)`
2. 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[]`
3. any reference to an overloaded operator function, e.g.
const auto &fn = some_struct.operator<<; // `operator<<`
Before:
F22005275: Screenshot 2022-02-06 at 14.33.20.png <https://reviews.llvm.org/F22005275>
After:
F22005248: Screenshot 2022-02-06 at 14.31.03.png <https://reviews.llvm.org/F22005248>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119077
Files:
clang-tools-extra/clangd/SemanticHighlighting.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119077.406242.patch
Type: text/x-patch
Size: 9080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220206/53bfee19/attachment.bin>
More information about the cfe-commits
mailing list