diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-21 15:42:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-22 08:30:10 +0200 |
commit | b63609ba5478ed9b020c113f5704f7ea8447dec8 (patch) | |
tree | e40896646675d8b462cec7a90ca1e94e902b3746 /compilerplugins | |
parent | 4af6c0948be47d7816eb1b6f2137b70aba639f0d (diff) |
loplugin:flatten in framework..package
Change-Id: Ide8a97eae6e2fdc7d2dcccba1480ac55a9b555bc
Reviewed-on: https://gerrit.libreoffice.org/42593
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/flatten.cxx | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx index adcc4972fd8f..ceff258179dd 100644 --- a/compilerplugins/clang/flatten.cxx +++ b/compilerplugins/clang/flatten.cxx @@ -153,7 +153,7 @@ bool Flatten::rewrite(const IfStmt* ifStmt) if (!replaceText(elseRange, thenString)) { return false; } - if (!removeText(elseKeywordRange, RewriteOptions(RemoveLineIfEmpty))) { + if (!removeText(elseKeywordRange)) { return false; } if (!replaceText(thenRange, elseString)) { @@ -169,22 +169,24 @@ bool Flatten::rewrite(const IfStmt* ifStmt) std::string stripOpenAndCloseBrace(std::string s) { size_t i = s.find("{"); - if (i != std::string::npos) { + if (i == std::string::npos) + throw "did not find {"; + + ++i; + // strip to line end + while (s[i] == ' ') ++i; - // strip to line end - while (s[i] == ' ') - ++i; - if (s[i] == '\n') - ++i; - s = s.substr(i); - } + if (s[i] == '\n') + ++i; + s = s.substr(i); + i = s.rfind("}"); - if (i != std::string::npos) { + if (i == std::string::npos) + throw "did not find }"; + --i; + while (s[i] == ' ') --i; - while (s[i] == ' ') - --i; - s = s.substr(0,i); - } + s = s.substr(0,i); return s; } @@ -272,7 +274,6 @@ SourceRange Flatten::extendOverComments(SourceRange range) --p1; startLoc = startLoc.getLocWithOffset(p1 - SM.getCharacterData( startLoc )); - p2 += Lexer::MeasureTokenLength( endLoc, SM, compiler.getLangOpts()); // look for trailing ";" while (*p2 == ';') ++p2; |