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

Stephan Bergmann sbergman at redhat.com
Tue Mar 8 17:17:35 UTC 2016


 compilerplugins/clang/salbool.cxx |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

New commits:
commit 1316543eb89a8c30edf547c76852f3e0f8ae848e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Mar 8 18:16:58 2016 +0100

    TODO: Work around loplugin:salbool in cppu/source/uno/data.cxx for now
    
    Change-Id: I1730c09669426e049aba941ef27341581ce31887

diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx
index dfead35..7712033 100644
--- a/compilerplugins/clang/salbool.cxx
+++ b/compilerplugins/clang/salbool.cxx
@@ -293,7 +293,10 @@ bool SalBool::VisitCXXStaticCastExpr(CXXStaticCastExpr * expr) {
     if (ignoreLocation(expr)) {
         return true;
     }
-    if (isSalBool(expr->getType())) {
+    if (isSalBool(expr->getType())
+        && !isInSpecialMainFile(
+            compiler.getSourceManager().getSpellingLoc(expr->getLocStart())))
+    {
         report(
             DiagnosticsEngine::Warning,
             "CXXStaticCastExpr, suspicious cast from %0 to %1",
@@ -440,7 +443,10 @@ bool SalBool::VisitFieldDecl(FieldDecl const * decl) {
     if (ignoreLocation(decl)) {
         return true;
     }
-    if (isSalBool(decl->getType())) {
+    if (isSalBool(decl->getType())
+        && !isInSpecialMainFile(
+            compiler.getSourceManager().getSpellingLoc(decl->getLocStart())))
+    {
         TagDecl const * td = dyn_cast<TagDecl>(decl->getDeclContext());
         assert(td != nullptr);
         if (!(((td->isStruct() || td->isUnion())
@@ -573,9 +579,12 @@ bool SalBool::VisitValueDecl(ValueDecl const * decl) {
 }
 
 bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const {
-    return compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
-        && (compiler.getSourceManager().getFilename(spellingLocation)
-            == SRCDIR "/cppu/qa/test_any.cxx");
+    if (!compat::isInMainFile(compiler.getSourceManager(), spellingLocation)) {
+        return false;
+    }
+    auto f = compiler.getSourceManager().getFilename(spellingLocation);
+    return f == SRCDIR "/cppu/qa/test_any.cxx"
+        || f == SRCDIR "/cppu/source/uno/data.cxx"; // TODO: the offset checks
 }
 
 bool SalBool::rewrite(SourceLocation location) {


More information about the Libreoffice-commits mailing list