summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
AgeCommit message (Collapse)AuthorFilesLines
2014-05-16combine the pass-by-ref clang pluginsNoel Grandin2-70/+14
Change-Id: Idac24afb7cb67fa2d539553fb9fa049c2d61ecf0
2014-05-14Find places where uno::Sequence is passed by value.Noel Grandin1-0/+63
Implement a clang plugin to find them, and clean up existing code to pass them by reference. Change-Id: If642d87407c73346d9c0164b9fc77c5c3c4354b8 Reviewed-on: https://gerrit.libreoffice.org/9351 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2014-04-15salbool: fix commentThomas Arnhold1-1/+1
accidently removed by 5babf1b9037eb283798322eecd8334e6ff1db655 maybe obsolete now Change-Id: Id1b8ce21e08ce2df5668252406bad6fb549b5206
2014-04-15Flag unreferrenced functions only declared in the main file, not an includeStephan Bergmann2-0/+172
...which appears to be a good heuristic to identify functions that are either unused or should better be declared just once in an include file. (It also filters out SAL_DLLPUBLIC extern "C" function definitions, which are most likely meant to be referenced dynamically via dlsym.) Change-Id: I7fb78cb836b971791704851535dcfbda2b2f5bc0
2014-04-15Better be specificStephan Bergmann1-2/+2
Change-Id: Ibb9b5b8f53ab8fdeba6d3db295339ead4bde7b6e
2014-04-15add "include/comphelper" to list of includes to ignoreNoel Grandin1-0/+1
since it only contains a single sal_Bool site now, and we want to leave that alone since it's a copy of similar stuff in cppuhelper. Change-Id: I3cf4cf5f67e95d5b6f70371181f77c5451fcbf50
2014-04-03remove unnecessary scope qualifier from sal_Bool usesNoel Grandin1-1/+1
i.e. convert "::sal_Bool" to "sal_Bool" Change-Id: Ie5943aee4fee617bf2670655558927ed25b7e067
2014-04-02Add compat::isInMainFileStephan Bergmann2-11/+16
Change-Id: I0e155c6c68a43020110a8e1c0cb29cabdcade454
2014-04-01Explicitly mark overriding destructors as "virtual"Stephan Bergmann1-1/+19
It appears that the C++ standard allows overriding destructors to be marked "override," but at least some MSVC versions complain about it, so at least make sure such destructors are explicitly marked "virtual." Change-Id: I0e1cafa7584fd16ebdce61f569eae2373a71b0a1
2014-03-27Plugin to warn about/fix verriding functions not marked SAL_OVERRIDEStephan Bergmann1-0/+158
Change-Id: I1d49aa9ad238cd5bd2e04479c2eb916f010417df
2014-03-27More compat stuffStephan Bergmann1-0/+16
(currently only used by a not-yet committed plugin, though) Change-Id: I4cff7eb97dbe10a44a911be9db090ea8cd10d8f0
2014-03-23fix filename detection in clang pluginsLuboš Luňák2-3/+3
SourceManager::getFilename() returns "<stdin>" whenever icecream is used. Change-Id: I4e3e1b90880c5fd2b53f20e4ce3e38e3a0486973
2014-03-19improve warning message in passstringbyref compiler pluginNoel Grandin1-2/+2
Change-Id: Ia8470bbd04c841e6c44c182493fede3dc312f635
2014-03-18Find places where OUString and OString are passed by value.Noel Grandin1-0/+71
It's not very efficient, because we generally end up copying it twice - once into the parameter and again into the destination OUString. So I create a clang plugin that finds such places and generates a warning so that we can convert them to pass-by-reference. Change-Id: I5341a6ea9e3190f4b4c05c42c85595e3dcd83361
2014-03-14More compat stuffStephan Bergmann1-0/+8
(currently only used by a not-yet committed plugin, though) Change-Id: Id62ea41031ad8ba4495ef46877ad7a10bc58fb05
2014-02-28Save the stdexception rewriter plugin used in...Stephan Bergmann1-0/+199
...5e21a413c788f839a66d9e4c14e745ed18058db8 "retrofit std::exception into overriding exception specs." Change-Id: If802bbd26b91438f3f46fe18bc763d27967bac5c
2014-02-27Remove visual noise from compilerpluginsAlexander Wilms6-9/+0
Change-Id: Ibfed0b64bd60804fa377b5e25e5f197a7772d605 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-02-25isIntegerConstantExpr is more general than IntegerLiteralStephan Bergmann1-17/+12
...and subsumes not only the use of __builtin_expect in assert, but also the use of __builtin_constant_p (nested) in htonl on Mac OS X. Change-Id: I62ab6c71c42948c4ec1e2f1e1d23223cbb13416b
2014-02-25Move plain rewriters to store/ (so they don' get built needlessly)Stephan Bergmann4-0/+0
Change-Id: I62d21e9a579bcb9c116bb272fc1236a890216cd9
2014-02-25salbool: a rewriting plugin that flags most uses of sal_BoolStephan Bergmann2-0/+584
...that would not lead to silent changes of the code. That is, it does not warn about sal_Bool parameters of virtual functions, so that (not yet rewritten) overrides do not silently become overloads instead. The plugin is in store/ for now, because not all of the code has been cleaned up yet. Change-Id: I6e9b3847eb26c3090f375045188d38097052defe
2014-02-25...but Flags parameter was plain unsigned int prior to Clang 3.4Stephan Bergmann2-5/+23
Change-Id: Ife39abda6b5274ae196dcbf591d02fa3f36f6072
2014-02-25raw_fd_ostream Flags parameter no longer defaultedStephan Bergmann1-1/+1
...at least on trunk r202077. Change-Id: Ieb59cc7ac70e2a57ac13eefdfcbb6bfa42e25218
2014-02-24implicitboolconversion: warn about implicit conversion of call args to boolStephan Bergmann1-11/+41
...to be able to find problems like 6e0bdf04add338b7d5b29fc7b3fc9f08cfd5e96f "sal_Bool arg of SetUseImagesInMenus was abused to squeeze '2' through it" earlier when converting occurrences of sal_Bool to bool. Restricting this check to function call arguments avoids too much noise while hopefully still catching all the relevant problems. (This check partially overlaps the pointertobool check, so implicit conversions from pointers to bool call arguments will now generate two loplugin warnings, but that's harmless.) Change-Id: I0b03b1d1615aaf8bc18e7a84c56fff3ef9903508
2014-02-21Adapt to Clang <= 3.4Stephan Bergmann2-1/+11
Change-Id: If9c9d63d85ce29629e6453f2d69355bd64ac2fc5
2014-02-21Special handling of __builtin_expect in boolean expressionsStephan Bergmann2-8/+16
...as found in Mac OS X' assert macro definition, __builtin_expect(!(e), 0) ? ... : ... with type long __builtin_expect(long, long) The code in literaltoboolconversion.cxx is needed for assert(false); Change-Id: I42f87482c56986af74b2ec849db9852f74c7c938
2014-02-21implicitboolconversion: support for Objective C BOOLStephan Bergmann1-2/+3
Change-Id: Id63f42fa8875211af9f41c21f3fa128403f8a880
2014-02-21Handle ImplicitCastExpr w/ invalid loc from Objective C codeStephan Bergmann1-1/+3
Change-Id: I82cb8aa53ea5fd86d6ff46af876dd3f55e1123d1
2014-02-21ParentBuilder needs support for ObjCMethodDeclStephan Bergmann1-0/+15
Change-Id: I8883649da31eabbc5a0f9780fb953ad58f154e1e
2014-02-20Don't attempt to actually do double code removalsStephan Bergmann4-12/+27
...that easily works around the problem that in a rewriter rewriting types of VarDecls like T x, y; it would try to replace T twice. Also, keep the list of removals globally with the (global) rewriter. Change-Id: I55b8d11986c2a29e09ff40132fd114a0cc48dc90
2014-02-17Run the non-rewriter plugins even when rewriters are specifiedStephan Bergmann2-24/+11
Change-Id: I8262091c52522c54f84c0fac5fd180871d4a3a9f
2014-02-14const improvementStephan Bergmann2-2/+2
Change-Id: I03815f33117a2927b1882d221f159a5de8d3ba78
2014-02-14one more -Werror,-Wsign-compareMatúš Kukan1-1/+1
Change-Id: I3139021c07db6efe16895e10c0539a8bc60aac9c
2014-02-14-Wsign-compareStephan Bergmann1-1/+3
Change-Id: I81a7fac291c46a0ee6da76ab3e29c53ad0678b66
2014-02-14Store compilerplugin warning about classes derived from a specific class.Matúš Kukan1-0/+71
Useful in case someone wants to find all classes deriving from "foo" and "bar". Change-Id: I7b12882881712d37976eb8c96fad6e9c9ac01370
2014-02-13Adapt ImplicitBoolConversion to 32-bit builds (where sal_Int32 is long)Stephan Bergmann1-6/+17
Change-Id: I64480e6026e7e39fe89f90c7d269f6bb1d02968d
2014-02-12convert SvStream::operator>> methods to ReadXXX methodsNoel Grandin1-49/+93
First, I updated the clang rewriter to do the conversion. Then I lightly hand-tweaked the output for the few places where the rewriter messed up, mostly when dealing with calls on "this". Change-Id: I40a6a977959cd97415c678eafc8507de8aa3b1a9 Reviewed-on: https://gerrit.libreoffice.org/7879 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2014-01-31DiagnosticsEngine::getCustomDiagID isn't const, so don't pass in const engine.Andrzej Hunt1-1/+1
Change-Id: I7e4494b7f1cb62ab27851e34ab4dc6be8e04e1fa Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-01-31sbergman's typoJesús Corrius1-1/+1
Change-Id: I36dc29659d0d6965c28e5fe0bb03759476de4781
2014-01-31clang::DiagnosticsEnginge::getCustomDiagID now needs a literal FormatStringStephan Bergmann2-2/+18
...at least in trunk 200400 towards Clang 3.5. Change-Id: Ibe956a7f28c16510506bd354582b3fe5a72582e5
2014-01-31Clang API function terminology got changedStephan Bergmann2-6/+58
...at least in trunk 200400 towards Clang 3.5. Change-Id: I6e295e3a4cf721fbda9df8e7c5bed3993ee78216
2014-01-30literaltobool conversion plugin, reduce spurious warnings with clang 3.3Noel Grandin1-1/+1
It appears that clang 3.3 also generates spurious warnings, so adjust the ifdef Change-Id: Idb57f7eafd55effd4c7c8b1f96c03c2ea6ddaba3
2014-01-29implicitboolconversion: also warn about redundant explicit castsStephan Bergmann1-0/+16
Change-Id: Ib89b4c12d2cdca873a9fe9a509d7a123977652a7
2014-01-29Further fix for old Clang versionsStephan Bergmann1-0/+9
...maybe this needs adaption for 3.3 or 3.4 too, known to work with trunk towards 3.5. Change-Id: I9f05ae44e4a49ae51df69d5a3c1df5eb371a1c87
2014-01-29Fix for old Clang versionsStephan Bergmann1-5/+35
Change-Id: Ib902535c03a9f1b93a2c4ff3dd61d29e316bfd49
2014-01-28Clang plugin to warn about implicit conversion of literals to boolStephan Bergmann1-0/+140
...which warns about apparent errors like n == KIND_FOO || KIND_BAR that should have read n == KIND_FOO || n == KIND_BAR It also warns about trivial (mis-)uses of 0/1 and sal_False/True like while (1) { ... } instead of while (true) { ... } which it can automatically rewrite. It does not warn if the relevant code is inside a macro in a .h (i.e., C) include file, nor when a string literal is used in the assert macro like assert(!"this cannot happen"); Change-Id: If8c305a25e5da15e78f6139b5b0c0e868f06d4f3
2014-01-27Prepare dual-mode compiler plugin featureStephan Bergmann18-94/+124
...which can act as either a rewriter or a non-rewriter that emits warnings. Also added COMPILER_PLUGIN_WARNINGS_ONLY=X to demote warnings from plugin X from errors to warnings, even under --enable-werror. Change-Id: I05361936240a890515c6bba2459565417c1746b7
2014-01-26implicitboolconversion: warn about mixing bool with integerStephan Bergmann1-0/+30
...in &=, |=, ^=, as does MSVC, too. Change-Id: I57ecc9d784dd483e04ae561c62595b1d0380517f
2014-01-22implicitboolconversion: also warn about mixing bool/sal_Bool in &=, |=, ^=Stephan Bergmann1-3/+3
...as MSVC would warn about those anyway. Change-Id: If22dfd35bc01aff1a1bef68702c616e711db42fb
2014-01-22implicitboolconversion: also warn about mixing bool/sal_Bool in == etc.Stephan Bergmann1-13/+16
...as MSVC would warn about those anyway (at least about cases that do not compare against literal sal_True/sal_False, but warning even about those helped clean up lots of redundant if (foo == true) instead of just if (foo) etc. across the code base). Change-Id: Iad4b335c35c5411070f04f87f974db7942c288d4
2014-01-22Improve Clang 3.2 hasCLanguageLinkageType workaroundStephan Bergmann1-1/+1
Change-Id: If5c104adc05aa362d15cedf6f8953bda478897bc