[PATCH] D103678: [Format] Fix incorrect pointer/reference detection
Yilong Guo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 8 00:51:05 PDT 2021
Nuullll marked an inline comment as done.
Nuullll added inline comments.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:243
+ bool OperatorCalledAsMemberFunction =
+ Prev->Previous && Prev->Previous->isOneOf(tok::period, tok::arrow);
+ Contexts.back().IsExpression = OperatorCalledAsMemberFunction;
----------------
MyDeveloperDay wrote:
> feels like we are not testing this situation, please add those tests
I added some in `FormatTest.UnderstandsOverloadedOperators`
================
Comment at: clang/unittests/Format/FormatTest.cpp:8283-8286
+ // TODO:
+ // Calling an operator as a non-member function is hard to distinguish
+ // verifyFormat("void f() { operator*(a & a); }");
+ // verifyFormat("void f() { operator&(a, b * b); }");
----------------
This patch doesn't fix these, i.e. when operators are called as non-member functions.
The call sites seem to be marked as function declarations.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103678/new/
https://reviews.llvm.org/D103678
More information about the cfe-commits
mailing list