summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-11 16:09:04 +0000
committerDaniel Jasper <djasper@google.com>2013-01-11 16:09:04 +0000
commitd6a947f75fb02f0537596e4815700172e5b3fc6a (patch)
tree147c966bd02ef56ee73198d1948943b96930c01d
parent2cc2d60451b46cef0e05abbf9bd0aa05d2a0c4ee (diff)
downloadbcm5719-llvm-d6a947f75fb02f0537596e4815700172e5b3fc6a.tar.gz
bcm5719-llvm-d6a947f75fb02f0537596e4815700172e5b3fc6a.zip
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
-rw-r--r--clang/lib/Format/Format.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp7
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 56bb6ec426a..38d39bca635 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1063,7 +1063,8 @@ private:
return CurrentLineType == LT_ObjCDecl || Left.is(tok::kw_if) ||
Left.is(tok::kw_for) || Left.is(tok::kw_while) ||
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) &&
Right.FormatTok.Tok.getObjCKeywordID() != tok::objc_not_keyword)
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 47e6bdd114f..cb634fc7e18 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -980,6 +980,13 @@ TEST_F(FormatTest, UndestandsOverloadedOperators) {
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) {
verifyFormat("int *f(int *a) {}");
verifyFormat("f(a, *a);");
OpenPOWER on IntegriCloud