aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-02 17:21:36 +0000
committerDaniel Jasper <djasper@google.com>2013-01-02 17:21:36 +0000
commitba3d3074e8ef4c4c05ac062b073b2e082e6a0206 (patch)
tree89ecc35d662b1e650f5c56ae12e8b9a68c07c9f6 /unittests/Format/FormatTest.cpp
parenta080a187fa7e538da3212c7d5e678e4b7ae03253 (diff)
Format */& as binary operator if followed by a unary operator.
This fixes llvm.org/PR14687. Also fixes segfault for lines starting with * or &. Before: a *~b; *a = 1; // <- this segfaulted After: a * ~b; *a = 1; // no segfault :-) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index daae94bb13..574d685fbd 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -28,6 +28,7 @@ protected:
CharSourceRange::getCharRange(Start, Start.getLocWithOffset(Length)));
LangOptions LangOpts;
LangOpts.CPlusPlus = 1;
+ LangOpts.CPlusPlus11 = 1;
Lexer Lex(ID, Context.Sources.getBuffer(ID), Context.Sources, LangOpts);
tooling::Replacements Replace =
reformat(Style, Lex, Context.Sources, Ranges);
@@ -676,7 +677,9 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) {
verifyFormat("a-- > b;");
verifyFormat("b ? -a : c;");
verifyFormat("n * sizeof char16;");
+ verifyFormat("n * alignof char16;");
verifyFormat("sizeof(char);");
+ verifyFormat("alignof(char);");
verifyFormat("return -1;");
verifyFormat("switch (a) {\n"
@@ -724,6 +727,13 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("return a & ~b;");
verifyFormat("f(b ? *c : *d);");
verifyFormat("int a = b ? *c : *d;");
+ verifyFormat("*b = a;");
+ verifyFormat("a * ~b;");
+ verifyFormat("a * !b;");
+ verifyFormat("a * +b;");
+ verifyFormat("a * -b;");
+ verifyFormat("a * ++b;");
+ verifyFormat("a * --b;");
// FIXME: Is this desired for LLVM? Fix if not.
verifyFormat("A<int *> a;");