hokein added inline comments.
================ Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:181 + addToken(E->getMemberLoc(), E->getQualifier() + ? HighlightingKind::StaticField + : HighlightingKind::Field); ---------------- ilya-biryukov wrote: > nridge wrote: > > hokein wrote: > > > This could be member functions, a case is like > > > > > > ``` > > > template<class T> > > > class Foo { > > > public: > > > void foo() { > > > this->foo(); > > > } > > > }; > > > ``` > > Thanks for the example. > > > > Do you have a suggestion for how to discriminate this case? To me, it would > > seem logical to do it based on syntax (highlight as a member function if > > the expression forms the function name of a function call expression). That > > would require navigating from the expression to its parent node. Is there a > > way to do that? > There is no way to do this in C++. > Even if the name is followed by a pair of parenthese, this could either be a > field with overloaded `operator()` (e.g. a `std::function<void()> field`) or > a function with the same name. > > It's much better to pick a separate highlighting kind for dependent names, > this follows the actual semantics of C++. +1, I think we should just highlight them as a dependent type. ================ Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:159 + addToken(E->getNameLoc(), E->getNamingClass() + ? HighlightingKind::StaticMethod + : HighlightingKind::Function); ---------------- I'm doubting we will encounter other exceptions. ``` struct X { template<class T> static T t; }; template<typename T> void f() { X::t<T>; // this is a `UnresolvedLookupExpr`. } ``` ================ Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:54 {HighlightingKind::StaticMethod, "StaticMethod"}, + {HighlightingKind::Typedef, "Typedef"}, + {HighlightingKind::DependentType, "DependentType"}, ---------------- thanks for catching this! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D67901/new/ https://reviews.llvm.org/D67901 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits