9251165796
...to silence warnings like > In file included from C:/lo-clang/core/extensions/source/activex/SOComWindowPeer.cxx:27: > C:/lo-clang/core/extensions/source/activex/SOComWindowPeer.h(57,1): error: Replace legacy dynamic 'throw ()' exception specification with 'noexcept' [loplugin:noexcept] > BEGIN_COM_MAP(SOComWindowPeer) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > C:/PROGRA~2/MIB055~1/2019/COMMUN~1/VC/Tools/MSVC/1428~1.299/atlmfc/include\atlcom.h(2204,130): note: expanded from macro 'BEGIN_COM_MAP' > static HRESULT WINAPI _Cache(_In_ void* pv, _In_ REFIID iid, _COM_Outptr_result_maybenull_ void** ppvObject, _In_ DWORD_PTR dw) throw()\ > ^~~~~~~ Change-Id: Iee2619e000963a419b757235d86d7f87944ed46a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115748 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
83 lines
2.8 KiB
C++
83 lines
2.8 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 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/.
|
|
*/
|
|
|
|
#include "plugin.hxx"
|
|
|
|
namespace
|
|
{
|
|
class Noexcept : public loplugin::FilteringRewritePlugin<Noexcept>
|
|
{
|
|
public:
|
|
explicit Noexcept(loplugin::InstantiationData const& data)
|
|
: FilteringRewritePlugin(data)
|
|
{
|
|
}
|
|
|
|
void run() override
|
|
{
|
|
// Don't execute for < C++11, so we don't accidentally rewrite the legacy definitions of
|
|
// SAL_THROW_EXTERN_C and SAL_NOEXCEPT in include/sal/types.h e.g. when building
|
|
// CppunitTest_odk_checkapi which explicitly uses gb_CXX03FLAGS:
|
|
if (compiler.getLangOpts().CPlusPlus11)
|
|
{
|
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
|
}
|
|
}
|
|
|
|
bool VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc tloc)
|
|
{
|
|
if (ignoreLocation(tloc))
|
|
{
|
|
return true;
|
|
}
|
|
if (tloc.getTypePtr()->getExceptionSpecType() != EST_DynamicNone)
|
|
{
|
|
return true;
|
|
}
|
|
auto const r = tloc.getExceptionSpecRange();
|
|
auto r2 = r;
|
|
auto l1 = r.getBegin();
|
|
while (compiler.getSourceManager().isMacroArgExpansion(l1))
|
|
{
|
|
l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
|
|
}
|
|
if (compiler.getSourceManager().isMacroBodyExpansion(l1))
|
|
{
|
|
auto l2 = r.getEnd();
|
|
while (compiler.getSourceManager().isMacroArgExpansion(l2))
|
|
{
|
|
l2 = compiler.getSourceManager().getImmediateMacroCallerLoc(l2);
|
|
}
|
|
if (compiler.getSourceManager().isMacroBodyExpansion(l2))
|
|
{
|
|
//TODO: check l1, l2 are in same macro body expansion
|
|
auto const spl = compiler.getSourceManager().getSpellingLoc(l1);
|
|
if (ignoreLocation(spl))
|
|
{
|
|
return true;
|
|
}
|
|
r2 = { spl, compiler.getSourceManager().getSpellingLoc(l2) };
|
|
}
|
|
}
|
|
auto const repl = isInUnoIncludeFile(r.getBegin()) ? "SAL_NOEXCEPT" : "noexcept";
|
|
if (rewriter != nullptr && replaceText(r2, repl))
|
|
{
|
|
return true;
|
|
}
|
|
report(DiagnosticsEngine::Warning,
|
|
"Replace legacy dynamic 'throw ()' exception specification with '%0'", r.getBegin())
|
|
<< repl << r;
|
|
return true;
|
|
}
|
|
};
|
|
|
|
loplugin::Plugin::Registration<Noexcept> X("noexcept", true);
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|