diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 41bf10dd800..d3a973b591b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1994,7 +1994,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return false; if (Right.is(TT_PointerOrReference)) return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) || - (Left.Tok.isLiteral() || Left.is(tok::kw_const) || + (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous && + Left.Previous->is(tok::r_paren)) || (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) && (Style.PointerAlignment != FormatStyle::PAS_Left || Line.IsMultiVariableDeclStmt))); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3b580b5ae24..218243380c3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5755,6 +5755,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + verifyGoogleFormat("int const* a = &b;"); verifyGoogleFormat("**outparam = 1;"); verifyGoogleFormat("*outparam = a * b;"); verifyGoogleFormat("int main(int argc, char** argv) {}"); |

