LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 33665 - clang-format incorrectly treats throw *this as binary operator
Summary: clang-format incorrectly treats throw *this as binary operator
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: unspecified
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-30 13:17 PDT by Erik Uhlmann
Modified: 2017-06-30 14:31 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
Proposed patch (2.30 KB, patch)
2017-06-30 14:31 PDT, Erik Uhlmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Uhlmann 2017-06-30 13:17:35 PDT
With the following code:

void Throw() { throw *this; }

c-f currently formats it as:

void Throw() { throw * this; }

I looked into this and the star token is being given the type TT_BinaryOperator instead of TT_PointerOrReference, so it gets formatted with a space before and after. I'm currently working on a fix.
Comment 1 Erik Uhlmann 2017-06-30 14:31:16 PDT
Created attachment 18739 [details]
Proposed patch

When formatting return statements like
sometype func() { return *this; }
the star gets the type TT_UnaryOperator. This patch makes `throw *x` behave the same way, and also adds a test to the bottom of FormatTest.UnderstandsUsesOfStarAndAmp