summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-05-18 14:47:42 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-05-19 07:27:59 +0200
commit92511657969ff93abd31a1368082d3c4dc42d479 (patch)
tree9663074d6d2614f1241ef7dbd0a223c8fc25e863 /compilerplugins/clang
parent95e26d3dce4f5a3b2d010d5ca47b4e450905a100 (diff)
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@redhat.com>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/noexcept.cxx41
1 files changed, 21 insertions, 20 deletions
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())