fixes for some loplugins

ran the ones in store/ just for fun, but didn't find anything useful

Change-Id: I2bb251e8d99b5d88e11b2ca74e99672d75f0a1fd
This commit is contained in:
Noel Grandin
2017-03-28 13:38:04 +02:00
parent 659cb84664
commit 0d199688fb
3 changed files with 12 additions and 2 deletions

View File

@@ -258,7 +258,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
std::string assignValue;
// check for field being returned by non-const ref eg. Foo& getFoo() { return f; }
if (parent && isa<ReturnStmt>(parent)) {
if (parentFunction && parent && isa<ReturnStmt>(parent)) {
const Stmt* parent2 = parentStmt(parent);
if (parent2 && isa<CompoundStmt>(parent2)) {
QualType qt = compat::getReturnType(*parentFunction).getDesugaredType(compiler.getASTContext());

View File

@@ -67,6 +67,12 @@ bool ConstantFunction::VisitFunctionDecl(const FunctionDecl * pFunctionDecl) {
if (pFunctionDecl->isExternC()) {
return true;
}
if (pFunctionDecl->isConstexpr()) {
return true;
}
if (pFunctionDecl->isMain()) {
return true;
}
StringRef aFileName = getFilename(pFunctionDecl);
@@ -151,7 +157,6 @@ bool ConstantFunction::VisitFunctionDecl(const FunctionDecl * pFunctionDecl) {
if (isa<CXXConstructorDecl>(pFunctionDecl) || isa<CXXDestructorDecl>(pFunctionDecl) || isa<CXXConversionDecl>(pFunctionDecl)) {
return true;
}
SourceLocation canonicalLoc = pFunctionDecl->getCanonicalDecl()->getNameInfo().getLoc();
if (isInUnoIncludeFile(pFunctionDecl)) {
return true;
}
@@ -429,6 +434,7 @@ bool ConstantFunction::VisitFunctionDecl(const FunctionDecl * pFunctionDecl) {
std::string aImmediateMacro = "";
if (compiler.getSourceManager().isMacroBodyExpansion(pFunctionDecl->getLocStart()) ) {
StringRef name { Lexer::getImmediateMacroName(

View File

@@ -73,6 +73,10 @@ bool ReturnByRef::VisitCXXMethodDecl(const CXXMethodDecl * functionDecl) {
if ( functionDecl->getNameAsString() == "operator->") {
return true;
}
std::string aFunctionName = functionDecl->getQualifiedNameAsString();
if (aFunctionName == "SbxValue::data") {
return true;
}
/*
std::string aParentName = functionDecl->getParent()->getQualifiedNameAsString();
std::string fqn = aParentName + "::" + functionDecl->getNameAsString();