diff options
| author | Andi-Bogdan Postelnicu <andi@mozilla.com> | 2017-03-07 14:48:02 +0000 |
|---|---|---|
| committer | Andi-Bogdan Postelnicu <andi@mozilla.com> | 2017-03-07 14:48:02 +0000 |
| commit | 67329896374fa52b3b73716c03c9267cd309b0e6 (patch) | |
| tree | 571edb10380c70d5357765eb20a5e6a64d5b1087 | |
| parent | eba9fdac7e131c6c99824cfd763989cc74965007 (diff) | |
| download | bcm5719-llvm-67329896374fa52b3b73716c03c9267cd309b0e6.tar.gz bcm5719-llvm-67329896374fa52b3b73716c03c9267cd309b0e6.zip | |
[clang-format] Fixed indent issue when adding a comment at the end of a return type in named function declaration.
Differential Revision: https://reviews.llvm.org/D30646
llvm-svn: 297143
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 42c92c4eca9..1a3b3520494 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1166,9 +1166,9 @@ private: return false; // Skip "const" as it does not have an influence on whether this is a name. - FormatToken *PreviousNotConst = Tok.Previous; + FormatToken *PreviousNotConst = Tok.getPreviousNonComment(); while (PreviousNotConst && PreviousNotConst->is(tok::kw_const)) - PreviousNotConst = PreviousNotConst->Previous; + PreviousNotConst = PreviousNotConst->getPreviousNonComment(); if (!PreviousNotConst) return false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 7ab0c752d12..54c5f27978f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5325,6 +5325,11 @@ TEST_F(FormatTest, BreaksLongDeclarations) { " vector<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>>\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + + verifyFormat("template<typename T> // Templates on own line.\n" + "static int // Some comment.\n" + "MyFunction(int a);", + getLLVMStyle()); } TEST_F(FormatTest, FormatsArrays) { |

