forked from OSchip/llvm-project
Correct spacing around new and delete.
This fixes llvm.org/PR14913. Before: A *a = new(placement) A; After: A *a = new (placement) A; llvm-svn: 172212
This commit is contained in:
parent
2cc2d60451
commit
d6a947f75f
|
@ -1063,7 +1063,8 @@ private:
|
||||||
return CurrentLineType == LT_ObjCDecl || Left.is(tok::kw_if) ||
|
return CurrentLineType == LT_ObjCDecl || Left.is(tok::kw_if) ||
|
||||||
Left.is(tok::kw_for) || Left.is(tok::kw_while) ||
|
Left.is(tok::kw_for) || Left.is(tok::kw_while) ||
|
||||||
Left.is(tok::kw_switch) || Left.is(tok::kw_return) ||
|
Left.is(tok::kw_switch) || Left.is(tok::kw_return) ||
|
||||||
Left.is(tok::kw_catch);
|
Left.is(tok::kw_catch) || Left.is(tok::kw_new) ||
|
||||||
|
Left.is(tok::kw_delete);
|
||||||
}
|
}
|
||||||
if (Left.is(tok::at) &&
|
if (Left.is(tok::at) &&
|
||||||
Right.FormatTok.Tok.getObjCKeywordID() != tok::objc_not_keyword)
|
Right.FormatTok.Tok.getObjCKeywordID() != tok::objc_not_keyword)
|
||||||
|
|
|
@ -980,6 +980,13 @@ TEST_F(FormatTest, UndestandsOverloadedOperators) {
|
||||||
verifyFormat("void operator delete[](void *ptr);");
|
verifyFormat("void operator delete[](void *ptr);");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FormatTest, UnderstandsNewAndDelete) {
|
||||||
|
verifyFormat("A *a = new A;");
|
||||||
|
verifyFormat("A *a = new (placement) A;");
|
||||||
|
verifyFormat("delete a;");
|
||||||
|
verifyFormat("delete (A *)a;");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
|
TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
|
||||||
verifyFormat("int *f(int *a) {}");
|
verifyFormat("int *f(int *a) {}");
|
||||||
verifyFormat("f(a, *a);");
|
verifyFormat("f(a, *a);");
|
||||||
|
|
Loading…
Reference in New Issue