summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-25 13:59:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-25 14:35:24 +0100
commitace70dae44eea914ea460cc2feb49202b61a20fc (patch)
tree4559c0ff67367b54925e2acd6c5a7cb13e30153d /compilerplugins
parent2029b2f6dd0109c5892e5ac5640022b31fe42fd2 (diff)
loplugins ignoreLocation() is unreliable with PCH
Change-Id: Ic12cacb6e058a8725ea6d722399e3afe6ea458c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132115 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/singlevalfields.cxx13
-rw-r--r--compilerplugins/clang/unnecessaryvirtual.cxx14
-rw-r--r--compilerplugins/clang/virtualdead.cxx2
3 files changed, 11 insertions, 18 deletions
diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx
index 81fa76da885e..3d966c9e9be3 100644
--- a/compilerplugins/clang/singlevalfields.cxx
+++ b/compilerplugins/clang/singlevalfields.cxx
@@ -180,8 +180,7 @@ bool SingleValFields::VisitFieldDecl( const FieldDecl* fieldDecl )
{
auto canonicalDecl = fieldDecl->getCanonicalDecl();
- if( ignoreLocation( canonicalDecl )
- || isInUnoIncludeFile( compiler.getSourceManager().getSpellingLoc(canonicalDecl->getLocation())) )
+ if( isInUnoIncludeFile( compiler.getSourceManager().getSpellingLoc(canonicalDecl->getLocation())) )
return true;
MyFieldInfo aInfo;
@@ -212,8 +211,7 @@ bool SingleValFields::VisitVarDecl( const VarDecl* varDecl )
if (!canonicalDecl->getLocation().isValid())
return true;
- if( ignoreLocation( canonicalDecl )
- || isInUnoIncludeFile( compiler.getSourceManager().getSpellingLoc(canonicalDecl->getLocation())) )
+ if( isInUnoIncludeFile( compiler.getSourceManager().getSpellingLoc(canonicalDecl->getLocation())) )
return true;
MyFieldInfo aInfo;
@@ -233,9 +231,6 @@ bool SingleValFields::VisitVarDecl( const VarDecl* varDecl )
bool SingleValFields::VisitCXXConstructorDecl( const CXXConstructorDecl* decl )
{
- if( ignoreLocation( decl ) )
- return true;
-
// doesn't count as a write to fields because it's self->self
if (decl->isCopyOrMoveConstructor())
return true;
@@ -266,8 +261,6 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
const FieldDecl* fieldDecl = dyn_cast<FieldDecl>(decl);
if (!fieldDecl)
return true;
- if (ignoreLocation(memberExpr))
- return true;
walkPotentialAssign(fieldDecl, memberExpr);
return true;
}
@@ -283,8 +276,6 @@ bool SingleValFields::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
return true;
if (!(varDecl->isStaticLocal() || varDecl->isStaticDataMember() || varDecl->hasGlobalStorage()))
return true;
- if (ignoreLocation(declRefExpr))
- return true;
walkPotentialAssign(varDecl, declRefExpr);
return true;
}
diff --git a/compilerplugins/clang/unnecessaryvirtual.cxx b/compilerplugins/clang/unnecessaryvirtual.cxx
index eb3df3b1524f..c3c73923b3ae 100644
--- a/compilerplugins/clang/unnecessaryvirtual.cxx
+++ b/compilerplugins/clang/unnecessaryvirtual.cxx
@@ -108,9 +108,6 @@ std::string niceName(const CXXMethodDecl* cxxMethodDecl)
bool UnnecessaryVirtual::VisitCXXMethodDecl( const CXXMethodDecl* methodDecl )
{
- if (ignoreLocation(methodDecl)) {
- return true;
- }
if (!methodDecl->isVirtual() || methodDecl->isDeleted()) {
return true;
}
@@ -132,6 +129,8 @@ bool UnnecessaryVirtual::VisitCXXMethodDecl( const CXXMethodDecl* methodDecl )
return true;
methodDecl = methodDecl->getCanonicalDecl();
+ if (!methodDecl)
+ return true;
std::string aNiceName = niceName(methodDecl);
// for destructors, we need to check if any of the superclass' destructors are virtual
@@ -147,8 +146,11 @@ bool UnnecessaryVirtual::VisitCXXMethodDecl( const CXXMethodDecl* methodDecl )
if (baseSpecifier->getType()->isRecordType())
{
const CXXRecordDecl* superclassCXXRecordDecl = baseSpecifier->getType()->getAsCXXRecordDecl();
- std::string aOverriddenNiceName = niceName(superclassCXXRecordDecl->getDestructor());
- overridingSet.insert(aOverriddenNiceName);
+ if (superclassCXXRecordDecl->getDestructor())
+ {
+ std::string aOverriddenNiceName = niceName(superclassCXXRecordDecl->getDestructor());
+ overridingSet.insert(aOverriddenNiceName);
+ }
}
}
return true;
@@ -174,6 +176,8 @@ bool UnnecessaryVirtual::VisitCXXMethodDecl( const CXXMethodDecl* methodDecl )
void UnnecessaryVirtual::MarkRootOverridesNonEmpty( const CXXMethodDecl* methodDecl )
{
+ if (!methodDecl)
+ return;
if (methodDecl->size_overridden_methods() == 0) {
nonEmptySet.insert(niceName(methodDecl));
return;
diff --git a/compilerplugins/clang/virtualdead.cxx b/compilerplugins/clang/virtualdead.cxx
index ca117d7f60ef..1a63363aaaf2 100644
--- a/compilerplugins/clang/virtualdead.cxx
+++ b/compilerplugins/clang/virtualdead.cxx
@@ -117,8 +117,6 @@ std::string niceName(const CXXMethodDecl* cxxMethodDecl)
bool VirtualDead::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
{
- if (ignoreLocation(methodDecl))
- return true;
if (!methodDecl->isVirtual() || methodDecl->isDeleted())
return true;
if (isa<CXXDestructorDecl>(methodDecl))