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

Stephan Bergmann sbergman at redhat.com
Mon Jul 3 08:36:37 UTC 2017


 compilerplugins/clang/oncevar.cxx |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 33ee8e61292af05627f5f72ea2f93ad80e715e46
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jul 3 10:33:13 2017 +0200

    Work around bug in Clang 3.8
    
    ...that causes
    
    > clang/lib/AST/Type.cpp:1878: bool clang::Type::isConstantSizeType() const: Assertion `!isDependentType() && "This doesn't make sense for dependent types"' failed.
    
    compilation failure in PCodeBufferWalker in basic/source/comp/codegen.cxx
    
    >    static T readParam( sal_uInt8 const *& pCode )
    >    {
    >        short nBytes = sizeof( T );
    >        T nOp1=0;
    >        for ( int i=0; i<nBytes; ++i )
    >            nOp1 |= *pCode++ << ( i * 8);
    >        return nOp1;
    >    }
    
    with loplugin:oncevar.
    
    Change-Id: I25417076549ea538adf013282f3657e0d642d776

diff --git a/compilerplugins/clang/oncevar.cxx b/compilerplugins/clang/oncevar.cxx
index 1fa6cd53acf0..41feb23b3280 100644
--- a/compilerplugins/clang/oncevar.cxx
+++ b/compilerplugins/clang/oncevar.cxx
@@ -162,10 +162,26 @@ bool OnceVar::VisitVarDecl( const VarDecl* varDecl )
             }
         }
     }
-    if (!foundStringLiteral
-        && !varDecl->getInit()->isConstantInitializer(compiler.getASTContext(), false/*ForRef*/))
-    {
-        return true;
+    if (!foundStringLiteral) {
+        auto const init = varDecl->getInit();
+#if CLANG_VERSION < 30900
+        // Work around missing Clang 3.9 fix <https://reviews.llvm.org/rL271762>
+        // "Sema: do not attempt to sizeof a dependent type" (while an
+        // initializer expression of the form
+        //
+        //   sizeof (T)
+        //
+        // with dependent type T /is/ constant, keep consistent here with the
+        // (arguably broken) behavior of isConstantInitalizer returning false in
+        // Clang >= 3.9):
+        if (init->isValueDependent()) {
+            return true;
+        }
+#endif
+        if (!init->isConstantInitializer(compiler.getASTContext(), false/*ForRef*/))
+        {
+            return true;
+        }
     }
 
     maVarDeclSet.insert(varDecl);


More information about the Libreoffice-commits mailing list