summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-11-27 13:50:25 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-11-29 17:44:45 +0100
commite0abb6aa78a763d591834fdc7306fcabe6710121 (patch)
tree61568f4381ece2e54d25f90ad18455a01f8e895c /compilerplugins/clang
parent760835877c6d64da239cc4791bdbf786f88c8bb1 (diff)
loplugin:toolslong: Don't warn about virtual functions at all
Now that all the relevant changes in old code should already have been done anyway, excluding virtual functions nicely avoids clang-cl warnings about the use of long and unsigned long in Windows-only StreamInterface (shell/inc/types.hxx). It is implemented by BufferStream and FileStream (both shell/inc/stream_helper.hxx), of which BufferStream internally uses [U]LARGE_INTEGER-based IStream and FileStream internally uses long (fseek, ftell) resp. size_t (fread) based FILE, so basing the common interface on [unsigned] long doesn't look like too unreasonable a choice. Change-Id: I563d59a8ca8a0ee37f46e2676ae8d00f6ea24597 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106768 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/toolslong.cxx22
1 files changed, 17 insertions, 5 deletions
diff --git a/compilerplugins/clang/toolslong.cxx b/compilerplugins/clang/toolslong.cxx
index 5a3932e90dbd..fd3f2e2bd932 100644
--- a/compilerplugins/clang/toolslong.cxx
+++ b/compilerplugins/clang/toolslong.cxx
@@ -479,13 +479,18 @@ bool ToolsLong::VisitParmVarDecl(ParmVarDecl const* decl)
auto canonicalF = f->getCanonicalDecl();
if (canonicalF->isDeletedAsWritten() && isa<CXXConversionDecl>(canonicalF))
return true;
+ if (auto const d = dyn_cast<CXXMethodDecl>(canonicalF))
+ {
+ if (d->isVirtual())
+ {
+ return true;
+ }
+ }
// Only rewrite declarations in include files if a definition is
// also seen, to avoid compilation of a definition (in a main file
// only processed later) to fail with a "mismatch" error before the
- // rewriter had a chance to act upon the definition (but use the
- // heuristic of assuming pure virtual functions do not have
- // definitions):
- bool ok = canonicalF->isDefined() || canonicalF->isPure()
+ // rewriter had a chance to act upon the definition:
+ bool ok = canonicalF->isDefined()
|| compiler.getSourceManager().isInMainFile(
compiler.getSourceManager().getSpellingLoc(f->getNameInfo().getLoc()));
if (!ok)
@@ -544,7 +549,14 @@ bool ToolsLong::VisitFunctionDecl(FunctionDecl const* decl)
return true;
if (decl->isDeletedAsWritten() && isa<CXXConversionDecl>(decl))
return true;
- if (decl->isPure() || decl->isDefined()
+ if (auto const d = dyn_cast<CXXMethodDecl>(decl))
+ {
+ if (d->isVirtual())
+ {
+ return true;
+ }
+ }
+ if (decl->isDefined()
|| compiler.getSourceManager().isInMainFile(
compiler.getSourceManager().getSpellingLoc(decl->getNameInfo().getLoc())))
{