Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: tools/clang/plugins/tests/base_refcounted.cpp

Issue 1385193002: Bisect clang Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 246985 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/clang/plugins/tests/base_refcounted.h ('k') | tools/clang/plugins/tests/base_refcounted.flags » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/plugins/tests/base_refcounted.cpp
diff --git a/tools/clang/plugins/tests/base_refcounted.cpp b/tools/clang/plugins/tests/base_refcounted.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..46e8975c597c46558be8728c094bf68d8db310fa
--- /dev/null
+++ b/tools/clang/plugins/tests/base_refcounted.cpp
@@ -0,0 +1,79 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base_refcounted.h"
+
+#include <cstddef>
+
+namespace {
+
+// Unsafe; should error.
+class AnonymousDerivedProtectedToPublicInImpl
+ : public ProtectedRefCountedVirtualDtorInHeader {
+ public:
+ AnonymousDerivedProtectedToPublicInImpl() {}
+ ~AnonymousDerivedProtectedToPublicInImpl() override {}
+};
+
+// Unsafe; but we should only warn on the base class.
+class AnonymousDerivedProtectedOnDerived
+ : public ProtectedRefCountedDtorInHeader {
+ protected:
+ ~AnonymousDerivedProtectedOnDerived() {}
+};
+
+} // namespace
+
+// Unsafe; should error.
+class PublicRefCountedDtorInImpl
+ : public base::RefCounted<PublicRefCountedDtorInImpl> {
+ public:
+ PublicRefCountedDtorInImpl() {}
+ ~PublicRefCountedDtorInImpl() {}
+
+ private:
+ friend class base::RefCounted<PublicRefCountedDtorInImpl>;
+};
+
+class Foo {
+ public:
+ class BarInterface {
+ protected:
+ virtual ~BarInterface() {}
+ };
+
+ typedef base::RefCounted<BarInterface> RefCountedBar;
+ typedef RefCountedBar AnotherTypedef;
+};
+
+class Baz {
+ public:
+ typedef typename Foo::AnotherTypedef MyLocalTypedef;
+};
+
+// Unsafe; should error.
+class UnsafeTypedefChainInImpl : public Baz::MyLocalTypedef {
+ public:
+ UnsafeTypedefChainInImpl() {}
+ ~UnsafeTypedefChainInImpl() {}
+};
+
+int main() {
+ PublicRefCountedDtorInHeader bad;
+ PublicRefCountedDtorInImpl also_bad;
+
+ ProtectedRefCountedDtorInHeader* even_badder = NULL;
+ PrivateRefCountedDtorInHeader* private_ok = NULL;
+
+ DerivedProtectedToPublicInHeader still_bad;
+ PublicRefCountedThreadSafeDtorInHeader another_bad_variation;
+ AnonymousDerivedProtectedToPublicInImpl and_this_is_bad_too;
+ ImplicitDerivedProtectedToPublicInHeader bad_yet_again;
+ UnsafeTypedefChainInImpl and_again_this_is_bad;
+
+ WebKitPublicDtorInHeader ignored;
+ WebKitDerivedPublicDtorInHeader still_ignored;
+
+ return 0;
+}
« no previous file with comments | « tools/clang/plugins/tests/base_refcounted.h ('k') | tools/clang/plugins/tests/base_refcounted.flags » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698