From 39b64ea5fb90bd94eeb21fdb0c7bc38ff81b41a3 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 4 Jun 2014 18:06:22 +0200 Subject: [PATCH] Simplify rValue reference arguments without name (&& -> & &) --- lib/tokenize.cpp | 8 ++++++++ test/testtokenize.cpp | 3 +++ 2 files changed, 11 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ffb230b51..876afaea9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3493,6 +3493,14 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) elseif(); + // Simplify nameless rValue references - named ones are simplified later + for (Token* tok = list.front(); tok; tok = tok->next()) { + if (Token::Match(tok, "&& [,)]")) { + tok->str("&"); + tok->insertToken("&"); + } + } + validate(); return true; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 6b7a6448c..7092582cf 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4795,6 +4795,9 @@ private: tokenizeDebugListing("class C {\n" " C(int&& a);\n" "};")); + + ASSERT_EQUALS("\n\n##file 0\n" + "1: void foo ( int & & ) ;\n", tokenizeDebugListing("void foo(int&&);")); } void varid_arrayFuncPar() {