summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-03-28 13:38:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-28 13:40:25 +0200
commit0d199688fbd32b6c5aba126d394dae23d4deb0a2 (patch)
treee39c760b49afc5a874bd6cc2dc987982f2ea2fae /compilerplugins
parent659cb8466495a15a680f684ec4aa1f1d3c4225cc (diff)
fixes for some loplugins
ran the ones in store/ just for fun, but didn't find anything useful Change-Id: I2bb251e8d99b5d88e11b2ca74e99672d75f0a1fd
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/singlevalfields.cxx2
-rw-r--r--compilerplugins/clang/store/constantfunction.cxx8
-rw-r--r--compilerplugins/clang/store/returnbyref.cxx4
3 files changed, 12 insertions, 2 deletions
diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx
index 491d260d6d31..c858954745f9 100644
--- a/compilerplugins/clang/singlevalfields.cxx
+++ b/compilerplugins/clang/singlevalfields.cxx
@@ -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());
diff --git a/compilerplugins/clang/store/constantfunction.cxx b/compilerplugins/clang/store/constantfunction.cxx
index cd14c48d981a..20f69712fa07 100644
--- a/compilerplugins/clang/store/constantfunction.cxx
+++ b/compilerplugins/clang/store/constantfunction.cxx
@@ -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(
diff --git a/compilerplugins/clang/store/returnbyref.cxx b/compilerplugins/clang/store/returnbyref.cxx
index aacfd7d833cf..9fa66131a880 100644
--- a/compilerplugins/clang/store/returnbyref.cxx
+++ b/compilerplugins/clang/store/returnbyref.cxx
@@ -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();