clang-format: Fix left pointer alignment after delctype/typeof
Change 272124* introduced a regression in spaceRequiredBetween for left aligned pointers to decltype and typeof expressions. This fix adds logic to fix this. The test added is based on a related test in determineStarAmpUsage. Also add test cases for the regression.
http://llvm.org/viewvc/llvm-project?view=revision&revision=272124
LLVM bug tracker: https://bugs.llvm.org/show_bug.cgi?id=30407
Differential revision: https://reviews.llvm.org/D35847
Fix contributed by euhlmann!
llvm-svn: 310831
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0b3ecf5..9c0c5c6 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5448,6 +5448,10 @@
verifyFormat("for (;; *a = b) {\n}", Left);
verifyFormat("return *this += 1;", Left);
verifyFormat("throw *x;", Left);
+ verifyFormat("delete *x;", Left);
+ verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+ verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+ verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
verifyIndependentOfContext("a = *(x + y);");
verifyIndependentOfContext("a = &(x + y);");
@@ -5494,9 +5498,6 @@
verifyGoogleFormat("T** t = new T*;");
verifyGoogleFormat("T** t = new T*();");
- FormatStyle PointerLeft = getLLVMStyle();
- PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
- verifyFormat("delete *x;", PointerLeft);
verifyFormat("STATIC_ASSERT((a & b) == 0);");
verifyFormat("STATIC_ASSERT(0 == (a & b));");
verifyFormat("template <bool a, bool b> "