diff options
| author | Daniel Jasper <djasper@google.com> | 2013-07-05 13:30:40 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-07-05 13:30:40 +0000 |
| commit | 6f9c8d2148b2a031561c93e7dc09268c45a4f746 (patch) | |
| tree | e6d273643a03a2e97128134518168ccfd36c9e60 | |
| parent | 23943229f6e951f674490641f7441643862b358f (diff) | |
| download | bcm5719-llvm-6f9c8d2148b2a031561c93e7dc09268c45a4f746.tar.gz bcm5719-llvm-6f9c8d2148b2a031561c93e7dc09268c45a4f746.zip | |
Fix formatting for allocation of new pointer variables.
Before:
T **t = new T * ;
T **q = new T * ();
After:
T **t = new T *;
T **q = new T *();
llvm-svn: 185699
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index c2f89ec134c..8db28635e88 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -591,7 +591,8 @@ private: NameFound = true; } else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) { Current.Type = - determineStarAmpUsage(Current, Contexts.back().IsExpression); + determineStarAmpUsage(Current, Contexts.back().CanBeExpression && + Contexts.back().IsExpression); } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) { Current.Type = determinePlusMinusCaretUsage(Current); } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 9109781091e..96ea9de9c67 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3378,8 +3378,12 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("A = new SomeType *[Length];"); verifyIndependentOfContext("A = new SomeType *[Length]();"); + verifyIndependentOfContext("T **t = new T *;"); + verifyIndependentOfContext("T **t = new T *();"); verifyGoogleFormat("A = new SomeType* [Length]();"); verifyGoogleFormat("A = new SomeType* [Length];"); + verifyGoogleFormat("T** t = new T*;"); + verifyGoogleFormat("T** t = new T*();"); FormatStyle PointerLeft = getLLVMStyle(); PointerLeft.PointerBindsToType = true; |

