[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Wed May 19 05:28:45 UTC 2021
compilerplugins/clang/noexcept.cxx | 41 ++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 20 deletions(-)
New commits:
commit 92511657969ff93abd31a1368082d3c4dc42d479
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue May 18 14:47:42 2021 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed May 19 07:27:59 2021 +0200
Adapt loplugin:noexcept to system macro BEGIN_COM_MAP (clang-cl)
...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 at redhat.com>
diff --git a/compilerplugins/clang/noexcept.cxx b/compilerplugins/clang/noexcept.cxx
index ae0bfdf95207..de956839e827 100644
--- a/compilerplugins/clang/noexcept.cxx
+++ b/compilerplugins/clang/noexcept.cxx
@@ -41,33 +41,34 @@ public:
return true;
}
auto const r = tloc.getExceptionSpecRange();
- auto const repl = isInUnoIncludeFile(r.getBegin()) ? "SAL_NOEXCEPT" : "noexcept";
- if (rewriter != nullptr)
+ auto r2 = r;
+ auto l1 = r.getBegin();
+ while (compiler.getSourceManager().isMacroArgExpansion(l1))
+ {
+ l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
+ }
+ if (compiler.getSourceManager().isMacroBodyExpansion(l1))
{
- auto r2 = r;
- auto l1 = r.getBegin();
- while (compiler.getSourceManager().isMacroArgExpansion(l1))
+ auto l2 = r.getEnd();
+ while (compiler.getSourceManager().isMacroArgExpansion(l2))
{
- l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
+ l2 = compiler.getSourceManager().getImmediateMacroCallerLoc(l2);
}
- if (compiler.getSourceManager().isMacroBodyExpansion(l1))
+ if (compiler.getSourceManager().isMacroBodyExpansion(l2))
{
- auto l2 = r.getEnd();
- while (compiler.getSourceManager().isMacroArgExpansion(l2))
+ //TODO: check l1, l2 are in same macro body expansion
+ auto const spl = compiler.getSourceManager().getSpellingLoc(l1);
+ if (ignoreLocation(spl))
{
- l2 = compiler.getSourceManager().getImmediateMacroCallerLoc(l2);
- }
- if (compiler.getSourceManager().isMacroBodyExpansion(l2))
- {
- //TODO: check l1, l2 are in same macro body expansion
- r2 = { compiler.getSourceManager().getSpellingLoc(l1),
- compiler.getSourceManager().getSpellingLoc(l2) };
+ return true;
}
+ r2 = { spl, compiler.getSourceManager().getSpellingLoc(l2) };
}
- if (replaceText(r2, repl))
- {
- return true;
- }
+ }
+ 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())
More information about the Libreoffice-commits
mailing list