[Libreoffice-commits] core.git: compilerplugins/clang

Noel Grandin noel.grandin at collabora.co.uk
Tue Mar 28 11:41:05 UTC 2017


 compilerplugins/clang/singlevalfields.cxx        |    2 +-
 compilerplugins/clang/store/constantfunction.cxx |    8 +++++++-
 compilerplugins/clang/store/returnbyref.cxx      |    4 ++++
 3 files changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 0d199688fbd32b6c5aba126d394dae23d4deb0a2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Mar 28 13:38:04 2017 +0200

    fixes for some loplugins
    
    ran the ones in store/ just for fun, but didn't find anything useful
    
    Change-Id: I2bb251e8d99b5d88e11b2ca74e99672d75f0a1fd

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();


More information about the Libreoffice-commits mailing list