[llvm-bugs] [Bug 42165] New: Clang-format Add Option to Align References Independently From Pointers

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 6 08:38:31 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42165

            Bug ID: 42165
           Summary: Clang-format Add Option to Align References
                    Independently From Pointers
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matthias.schaefer at versasec.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Though I understand that references and pointers to other types are both
technically just types, the usage of references as parameters of functions
feels much different than using pointers because a reference is automatically
created when a variable is passed to a function and a reference is also
dereferenced implicitly and can be used like a local variable inside the
function. In contrast a pointer must be obtained explicitly to pass it into a
function and it also needs to be dereferenced explicitly each time the
referenced object is accessed inside the function.

This is why the general perception of references is that they are not part of
the parameter type but rather a parameter passing convention. Hence I would
like to be able to align references independently of pointers. I propose to add
2 new settings:
- DeriveReferenceAlignment, which should have the same options as
DerivePointerAlignment, the default should be the option specified by
DerivePointerAlignment or, if DerivePointerAlignment is not configured, its
default.
- ReferenceAlignment, which should have the same options as PointerAlignment,
the default should be the option specified by PointerAlignment or, if
PointerAlignment is not configured, its default.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190606/9e343137/attachment.html>


More information about the llvm-bugs mailing list