forked from OSchip/llvm-project
clang-format: Improve binary operator detection.
Before: *(int *)(p &~3UL) = 0; After: *(int *)(p & ~3UL) = 0; This fixes llvm.org/PR19464. llvm-svn: 207405
This commit is contained in:
parent
f8542956d3
commit
942d971c84
|
@ -682,7 +682,7 @@ private:
|
||||||
for (FormatToken *Previous = Current.Previous;
|
for (FormatToken *Previous = Current.Previous;
|
||||||
Previous && !Previous->isOneOf(tok::comma, tok::semi);
|
Previous && !Previous->isOneOf(tok::comma, tok::semi);
|
||||||
Previous = Previous->Previous) {
|
Previous = Previous->Previous) {
|
||||||
if (Previous->is(tok::r_square))
|
if (Previous->isOneOf(tok::r_square, tok::r_paren))
|
||||||
Previous = Previous->MatchingParen;
|
Previous = Previous->MatchingParen;
|
||||||
if (Previous->Type == TT_BinaryOperator &&
|
if (Previous->Type == TT_BinaryOperator &&
|
||||||
Previous->isOneOf(tok::star, tok::amp)) {
|
Previous->isOneOf(tok::star, tok::amp)) {
|
||||||
|
|
|
@ -4523,6 +4523,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
|
||||||
verifyIndependentOfContext("a * [self dostuff];");
|
verifyIndependentOfContext("a * [self dostuff];");
|
||||||
verifyIndependentOfContext("int x = a * (a + b);");
|
verifyIndependentOfContext("int x = a * (a + b);");
|
||||||
verifyIndependentOfContext("(a *)(a + b);");
|
verifyIndependentOfContext("(a *)(a + b);");
|
||||||
|
verifyIndependentOfContext("*(int *)(p & ~3UL) = 0;");
|
||||||
verifyIndependentOfContext("int *pa = (int *)&a;");
|
verifyIndependentOfContext("int *pa = (int *)&a;");
|
||||||
verifyIndependentOfContext("return sizeof(int **);");
|
verifyIndependentOfContext("return sizeof(int **);");
|
||||||
verifyIndependentOfContext("return sizeof(int ******);");
|
verifyIndependentOfContext("return sizeof(int ******);");
|
||||||
|
|
Loading…
Reference in New Issue