New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 45357 - clang-format: unexpected change on operator
Summary: clang-format: unexpected change on operator
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Sam McCall
URL:
Keywords: regression
Depends on:
Blocks: release-10.0.1 36294
  Show dependency tree
 
Reported: 2020-03-30 07:28 PDT by Sylvestre Ledru
Modified: 2020-05-07 11:11 PDT (History)
7 users (show)

See Also:
Fixed By Commit(s): eb85e90350e93a64279139e7eca9ca40c8fbf5eb b01dca50085768f1f1a5ad21a685906d48c38816 7ae6db9cf0c baeb500a8ca


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvestre Ledru 2020-03-30 07:28:41 PDT
with:
class UniquePtrGetterAddRefs {
  operator void **() { return reinterpret_cast<void **>(&mPtrStorage); }
}

with clang-format 10.0

$ clang-format-10 foo.cpp 
class UniquePtrGetterAddRefs {
  operator void * *() { return reinterpret_cast<void **>(&mPtrStorage); }
}

I don't think it is what we want!
Comment 1 Sylvestre Ledru 2020-03-30 07:40:54 PDT
Similar example:
---
class ReturnToGlobal {
  operator LocalRef<Object>*() { return &objRef; }
}
---

With!
$ clang-format-10 foo.cpp                                                                                                   
class ReturnToGlobal {
  operator LocalRef<Object> *() { return &objRef; }
}


Even with PointerAlignment: Left
Comment 2 Sylvestre Ledru 2020-04-14 06:44:09 PDT
@MyDeveloperDay is that something you could help with? thanks
Comment 3 MyDeveloperDay 2020-04-26 09:16:10 PDT
see https://reviews.llvm.org/D78879

The result is the following, is this that more like what is expected?

clang-format operator.cpp

class UniquePtrGetterAddRefs {
  operator void **() { return reinterpret_cast<void **>(&mPtrStorage); }
}

class ReturnToGlobal {
  operator LocalRef<Object>*() { return &objRef; }
}
Comment 4 MyDeveloperDay 2020-04-30 03:00:24 PDT
A fix for this has landed

b01dca50085768f1f1a5ad21a685906d48c38816
Comment 6 Sam McCall 2020-04-30 13:14:41 PDT
Yes, both look good!

(The second doesn't cover `operator T*&`, but that's obscure enough that we don't need a backport I think)
Comment 7 Tom Stellard 2020-05-07 11:11:55 PDT
Merged: baeb500a8ca