From owner-freebsd-toolchain@FreeBSD.ORG Sun Mar 15 00:38:55 2015 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9A4F1B8F for ; Sun, 15 Mar 2015 00:38:55 +0000 (UTC) Received: from asp.reflexion.net (outbound-241.asp.reflexion.net [69.84.129.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3FAE77E2 for ; Sun, 15 Mar 2015 00:38:54 +0000 (UTC) Received: (qmail 24288 invoked from network); 15 Mar 2015 00:38:52 -0000 Received: from unknown (HELO mail-cs-01.app.dca.reflexion.local) (10.81.19.1) by 0 (rfx-qmail) with SMTP; 15 Mar 2015 00:38:52 -0000 Received: by mail-cs-01.app.dca.reflexion.local (Reflexion email security v7.40.1) with SMTP; Sat, 14 Mar 2015 20:38:52 -0400 (EDT) Received: (qmail 1473 invoked from network); 15 Mar 2015 00:38:50 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with (DHE-RSA-AES256-SHA encrypted) SMTP; 15 Mar 2015 00:38:50 -0000 X-No-Relay: not in my network X-No-Relay: not in my network Received: from [192.168.1.8] (c-67-189-19-145.hsd1.or.comcast.net [67.189.19.145]) by iron2.pdx.net (Postfix) with ESMTPSA id 6E5411C405E; Sat, 14 Mar 2015 17:38:44 -0700 (PDT) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: contrib/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h's IntrusiveRefCntPtr and its use violates C++ privacy rules Message-Id: <8CFA382E-85D3-4A02-A448-3284C827DC29@dsl-only.net> Date: Sat, 14 Mar 2015 17:38:48 -0700 To: freebsd-toolchain@freebsd.org, FreeBSD PowerPC ML Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) X-Mailer: Apple Mail (2.2070.6) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 00:38:55 -0000 When trying to build the 11.0-CURRENT clang 3.5 on powerpc64 I ran into = a violation of C++ accessibility rules (for private) that stopped the = compile. contrib/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h has... template class IntrusiveRefCntPtr { T* Obj; public: ... template IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.get()) { S.Obj =3D 0; } ... } To first illustrate a (partial) but-simpler-to-follow example use that = would show the problem: using Ta =3D ...; using Tb =3D ...; // Note that private members of IntrusiveRefCntPtr // are not (should not be) accessible to // IntrusiveRefCntPtr methods (and vice-versa). IntrusiveRefCntPtr a{} IntrusiveRefCntPtr b{a}; // We then would have a usage where an example of: IntrusiveRefCntPtr::IntrusiveRefCntPtr is then trying to access an example of IntrusiveRefCntPtr's Obj private member. It would take a friend relationship to be established to allow the = cross-type access to Obj. The code in = contrib/llvm/tools/clang/lib/Frontend/ChainedIncludesSource.cpp has such = a use and so makes an instance of the violation of the language rules in = the actual code. The function clang::createChainedIncludesSourceIt uses classes...=20 class ChainedIncludesSource : public ExternalSemaSource where... class ExternalSemaSource : public ExternalASTSource where... class ExternalASTSource : public RefCountedBase where... template class RefCountedBase; and it uses both of the following types... IntrusiveRefCntPtr and... IntrusiveRefCntPtr In fact IntrusiveRefCntPtr is the = return-expresison type for the following routine that has return type = IntrusiveRefCntPtr... IntrusiveRefCntPtr = clang::createChainedIncludesSource( CompilerInstance &CI, IntrusiveRefCntPtr = &Reader) { ... IntrusiveRefCntPtr source(new = ChainedIncludesSource()); ... return source; } =3D=3D=3D Mark Millard markmi at dsl-only.net