6 Commits

Author SHA1 Message Date
Stephan Bergmann
adf3cf074e Fix loplugin:flatten's skipping of if/then/else/if chains
(but which finds no new hits)

Change-Id: I5d5f351402797b662a08ec8dca301bd174e22a50
Reviewed-on: https://gerrit.libreoffice.org/44433
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-08 11:59:09 +01:00
Noel Grandin
38ccea5588 Improve performance of loplugin:flatten
...by avoiding calls to parentStmt.

Change-Id: I4f3d66a0529e9c3abf5c963bcf70db7a2afa1bf9
2017-10-06 12:44:57 +02:00
Stephan Bergmann
3d1b53a099 Also suppress loplugin:flatten in C++ class member functions...
...invovling preprocessing conditionals, to actually make the unhelpful warning
on Windows about OleEmbeddedObject::changeState go away.  And while at it, make
the check for preprocessing conditionals more targeted (similar to
1084e8be44661aaeacb8801707701013eb3fcdbc "More targeted check for preprocessing
conditionals in loplugin:blockblock").

Change-Id: I0300e0a547e969520a90cd126ea8f788cc17560f
Reviewed-on: https://gerrit.libreoffice.org/42975
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-10-05 09:38:31 +02:00
Stephan Bergmann
62274b24f9 Suppress loplugin:flatten in functions involving preprocessing conditionals
...as needed by clang-cl on Windows to avoid unhelpful warnings about
OleEmbeddedObject::changeState (embeddedobj/source/msole/oleembed.cxx)
containging an "if" in an "#ifdef _WIN32" block followed by "else throw".

Change-Id: I95bed29b9003db08499156ae7f885aeeea5a0158
Reviewed-on: https://gerrit.libreoffice.org/42963
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-30 13:28:43 +02:00
Noel Grandin
1ffba0e356 loplugin:flatten check for throw in then clause
also make the plugin ignore the case where we have var decl's in the
clause we want to flatten, which could lead to problematic extension of
variable lifetime

Change-Id: I3061f7104e8c6a460bf74f5eac325a516ec50c59
Reviewed-on: https://gerrit.libreoffice.org/42889
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-29 08:51:48 +02:00
Noel Grandin
dc97ede7cf new loplugin flatten
look for places where we can flatten the control flow in a method by
exiting early with a throw, ie. instead of

   if (cond)
       stuff();
   else
       throw ex;

we  change it to:

   if (!cond)
      throw ex;
   stuff();

Change-Id: I8b6bdf883b325807c7e3a3ef698e4f4606e7d38b
2017-09-20 12:42:33 +02:00