[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 2 19:46:07 UTC 2021
compilerplugins/clang/stringviewparam.cxx | 4 ++++
compilerplugins/clang/test/stringviewparam.cxx | 2 ++
2 files changed, 6 insertions(+)
New commits:
commit dec14c4a074b4e4b156b932155e73647d6ebd519
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Feb 2 18:29:41 2021 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Feb 2 20:45:24 2021 +0100
Avoid --disable-assert-always-abort loplugin:stringviewparam false positives
...like
> l10ntools/source/helper.cxx:19:69: error: replace function parameter of type 'const rtl::OString &' with 'std::string_view' [loplugin:stringviewparam]
> const OString& rText, const OString& rUnEscaped, const OString& rEscaped )
> ~~~~~~~~~~~~~~~^~~~~~~~
where the call to rEscaped.getLength(), which would otherwise suppress the
warning, is hidden inside an assert.
(Similar to aab0322580c87864a4f0c0af1fed07282c8dccbb "Disable
loplugin:casttovoid when --disable-assert-always-abort".)
Change-Id: Ie054f75317707757b1c6243c593f539d445a9fee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110331
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx
index 9182bf449bbe..862e9f331133 100644
--- a/compilerplugins/clang/stringviewparam.cxx
+++ b/compilerplugins/clang/stringviewparam.cxx
@@ -504,6 +504,10 @@ private:
{
return;
}
+ if (compiler.getPreprocessor().getIdentifierInfo("NDEBUG")->hasMacroDefinition())
+ {
+ return;
+ }
StringRef fn(handler.getMainFileName());
// leave the string QA tests alone
if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/"))
diff --git a/compilerplugins/clang/test/stringviewparam.cxx b/compilerplugins/clang/test/stringviewparam.cxx
index a9fcab3ac3a0..db57c8ac415f 100644
--- a/compilerplugins/clang/test/stringviewparam.cxx
+++ b/compilerplugins/clang/test/stringviewparam.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#undef NDEBUG
+
#include "sal/config.h"
#include <string_view>
More information about the Libreoffice-commits
mailing list