office-gobmx/solenv/CompilerTest_compilerplugins_clang.mk
Stephan Bergmann d2ba5d98ec Fix some tautological std::type_info (in-)equality comparisons
...which could never succeed.

I became aware of this when Clang 15 trunk -std=c++2b, implementing
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1328r1.html> "Making
std::type_info::operator== constexpr", pointed at two of the broken comparisons
with

> sw/source/uibase/app/docsh2.cxx:478:25: error: code will never be executed [-Werror,-Wunreachable-code]
>                         pTmpFrame->GetFrame().Appear();
>                         ^~~~~~~~~
> sw/source/uibase/app/docsh2.cxx:475:33: error: code will never be executed [-Werror,-Wunreachable-code]
>                         bOnly = false;
>                                 ^~~~~

(It didn't emit warnings pointing at any of the other broken comparisons,
though.)

All of these broken comparisons were regressions introduced with
89d39bc100 "tdf#94559: 4th step to remove
rtti.hxx", replacing uses of the IS_TYPE macro (from include/tools/rtti.hxx,
meanwhile removed with d64e535fe9 "Remove unused
rtti.hxx").

I now added loplugin:typeidcomparison to also find the other broken comparisons
introduced by that commit.  (The remaining cases where that commit replaced uses
of TYPE_INFO with typeid comparisons were correct and/or have meanwhile been
replaced with code not using typeid, see
553ee72041 "simplify some use of typeid" and
d656da9bc4 "~SwModify: do not silently tolerate
clients registered past death".)

The original IS_TYPE macro made sure not to dereference null pointers,

> #define IS_TYPE(T,pObj) \
>         ( pObj && (pObj)->Type() == TYPE(T) )

I don't know if any of the pointers now dereferenced in those typeid expressions
can legitimately be null.  But to be on the safe side, I replicated that check
in the newly introduced isType (sw/inc/istype.hxx).

(It is interesting to note that none of the static analysis that we routinely
employ seems to have noticed these broken comparisons.)

Change-Id: I65baffdd27bac1abf744283ff98c2dc864fa63b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129865
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-02-12 19:37:43 +01:00

130 lines
5.7 KiB
Makefile

# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CompilerTest_CompilerTest,compilerplugins_clang))
$(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/badstatics \
compilerplugins/clang/test/blockblock \
compilerplugins/clang/test/bufferadd \
compilerplugins/clang/test/buriedassign \
compilerplugins/clang/test/casttovoid \
compilerplugins/clang/test/classmemaccess \
compilerplugins/clang/test/collapseif \
compilerplugins/clang/test/commaoperator \
compilerplugins/clang/test/conditionalstring \
$(if $(filter-out WNT,$(OS)),compilerplugins/clang/test/constfields) \
compilerplugins/clang/test/constmethod \
compilerplugins/clang/test/constparams \
compilerplugins/clang/test/consttobool \
compilerplugins/clang/test/constvars \
compilerplugins/clang/test/convertlong \
compilerplugins/clang/test/cow_wrapper \
compilerplugins/clang/test/cppunitassertequals \
compilerplugins/clang/test/cstylecast \
compilerplugins/clang/test/datamembershadow \
compilerplugins/clang/test/dbgunhandledexception \
compilerplugins/clang/test/dodgyswitch \
compilerplugins/clang/test/doubleconvert \
compilerplugins/clang/test/elidestringvar \
compilerplugins/clang/test/emptyif \
compilerplugins/clang/test/expressionalwayszero \
compilerplugins/clang/test/external \
compilerplugins/clang/test/faileddyncast \
compilerplugins/clang/test/fakebool \
compilerplugins/clang/test/flatten \
compilerplugins/clang/test/fragiledestructor \
compilerplugins/clang/test/getstr \
compilerplugins/clang/test/implicitboolconversion \
compilerplugins/clang/test/indentation \
compilerplugins/clang/test/intvsfloat \
compilerplugins/clang/test/logexceptionnicely \
compilerplugins/clang/test/loopvartoosmall \
compilerplugins/clang/test/mapindex \
compilerplugins/clang/test/makeshared \
compilerplugins/clang/test/moveparam \
compilerplugins/clang/test/namespaceindentation \
compilerplugins/clang/test/noexcept \
compilerplugins/clang/test/noexceptmove \
compilerplugins/clang/test/nullptr \
compilerplugins/clang/test/oncevar \
compilerplugins/clang/test/oslendian-1 \
compilerplugins/clang/test/oslendian-2 \
compilerplugins/clang/test/oslendian-3 \
compilerplugins/clang/test/overridevirtual \
compilerplugins/clang/test/passparamsbyref \
compilerplugins/clang/test/passstuffbyref \
compilerplugins/clang/test/pointerbool \
compilerplugins/clang/test/reducevarscope \
compilerplugins/clang/test/redundantcast \
compilerplugins/clang/test/redundantfcast \
compilerplugins/clang/test/redundantinline \
compilerplugins/clang/test/redundantpointerops \
compilerplugins/clang/test/redundantpreprocessor \
compilerplugins/clang/test/refcounting \
compilerplugins/clang/test/referencecasting \
compilerplugins/clang/test/returnconstval \
compilerplugins/clang/test/salcall \
compilerplugins/clang/test/sallogareas \
compilerplugins/clang/test/salunicodeliteral \
compilerplugins/clang/test/selfinit \
compilerplugins/clang/test/sequentialassign \
compilerplugins/clang/test/shouldreturnbool \
compilerplugins/clang/test/simplifyconstruct \
compilerplugins/clang/test/simplifydynamiccast \
compilerplugins/clang/test/simplifypointertobool \
compilerplugins/clang/test/singlevalfields \
compilerplugins/clang/test/staticconstfield \
compilerplugins/clang/test/staticdynamic \
compilerplugins/clang/test/staticvar \
compilerplugins/clang/test/stdfunction \
compilerplugins/clang/test/stringadd \
compilerplugins/clang/test/stringconcatauto \
compilerplugins/clang/test/stringconcatliterals \
compilerplugins/clang/test/stringconstant \
compilerplugins/clang/test/stringliteralvar \
compilerplugins/clang/test/stringliteraldefine \
compilerplugins/clang/test/stringloop \
compilerplugins/clang/test/stringstatic \
compilerplugins/clang/test/stringview \
compilerplugins/clang/test/stringviewparam \
compilerplugins/clang/test/typedefparam \
compilerplugins/clang/test/typeidcomparison \
compilerplugins/clang/test/unnecessarycatchthrow \
compilerplugins/clang/test/unnecessaryoverride \
compilerplugins/clang/test/unnecessaryoverride-dtor \
compilerplugins/clang/test/unnecessaryparen \
compilerplugins/clang/test/unoany \
compilerplugins/clang/test/unoquery \
compilerplugins/clang/test/unreffun \
compilerplugins/clang/test/unsignedcompare \
compilerplugins/clang/test/unusedcapturedefault \
compilerplugins/clang/test/unusedenumconstants \
compilerplugins/clang/test/unusedfields \
compilerplugins/clang/test/unusedindex \
compilerplugins/clang/test/unusedmember \
compilerplugins/clang/test/unusedvariablecheck \
compilerplugins/clang/test/unusedvariablemore \
compilerplugins/clang/test/unusedvarsglobal \
compilerplugins/clang/test/useuniqueptr \
compilerplugins/clang/test/vclwidgets \
compilerplugins/clang/test/weakbase \
compilerplugins/clang/test/weakobject \
compilerplugins/clang/test/writeonlyvars \
compilerplugins/clang/test/xmlimport \
))
$(eval $(call gb_CompilerTest_use_externals,compilerplugins_clang, \
boost_headers \
cppunit \
))
$(eval $(call gb_CompilerTest_use_udk_api,compilerplugins_clang))
# vim: set noet sw=4 ts=4: