mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-04 06:17:30 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
|
|
@ -0,0 +1,72 @@
|
|||
// 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 ProtectedRefCountedDtorInHeader {
|
||||
public:
|
||||
AnonymousDerivedProtectedToPublicInImpl() {}
|
||||
~AnonymousDerivedProtectedToPublicInImpl() {}
|
||||
};
|
||||
|
||||
} // 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* protected_ok = 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;
|
||||
}
|
||||
121
media/webrtc/trunk/tools/clang/plugins/tests/base_refcounted.h
Normal file
121
media/webrtc/trunk/tools/clang/plugins/tests/base_refcounted.h
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
// 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.
|
||||
|
||||
#ifndef BASE_REFCOUNTED_H_
|
||||
#define BASE_REFCOUNTED_H_
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename T>
|
||||
class RefCounted {
|
||||
public:
|
||||
RefCounted() {}
|
||||
~RefCounted() {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class RefCountedThreadSafe {
|
||||
public:
|
||||
RefCountedThreadSafe() {}
|
||||
~RefCountedThreadSafe() {}
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
// Ignore classes whose inheritance tree ends in WebKit's RefCounted base
|
||||
// class. Though prone to error, this pattern is very prevalent in WebKit
|
||||
// code, so do not issue any warnings.
|
||||
namespace WebKit {
|
||||
|
||||
template <typename T>
|
||||
class RefCounted {
|
||||
public:
|
||||
RefCounted() {}
|
||||
~RefCounted() {}
|
||||
};
|
||||
|
||||
} // namespace WebKit
|
||||
|
||||
// Unsafe; should error.
|
||||
class PublicRefCountedDtorInHeader
|
||||
: public base::RefCounted<PublicRefCountedDtorInHeader> {
|
||||
public:
|
||||
PublicRefCountedDtorInHeader() {}
|
||||
~PublicRefCountedDtorInHeader() {}
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<PublicRefCountedDtorInHeader>;
|
||||
};
|
||||
|
||||
// Unsafe; should error.
|
||||
class PublicRefCountedThreadSafeDtorInHeader
|
||||
: public base::RefCountedThreadSafe<
|
||||
PublicRefCountedThreadSafeDtorInHeader> {
|
||||
public:
|
||||
PublicRefCountedThreadSafeDtorInHeader() {}
|
||||
~PublicRefCountedThreadSafeDtorInHeader() {}
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<
|
||||
PublicRefCountedThreadSafeDtorInHeader>;
|
||||
};
|
||||
|
||||
// Safe; should not have errors.
|
||||
class ProtectedRefCountedDtorInHeader
|
||||
: public base::RefCounted<ProtectedRefCountedDtorInHeader> {
|
||||
public:
|
||||
ProtectedRefCountedDtorInHeader() {}
|
||||
|
||||
protected:
|
||||
~ProtectedRefCountedDtorInHeader() {}
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<ProtectedRefCountedDtorInHeader>;
|
||||
};
|
||||
|
||||
// Safe; should not have errors.
|
||||
class PrivateRefCountedDtorInHeader
|
||||
: public base::RefCounted<PrivateRefCountedDtorInHeader> {
|
||||
public:
|
||||
PrivateRefCountedDtorInHeader() {}
|
||||
|
||||
private:
|
||||
~PrivateRefCountedDtorInHeader() {}
|
||||
friend class base::RefCounted<PrivateRefCountedDtorInHeader>;
|
||||
};
|
||||
|
||||
// Unsafe; A grandchild class ends up exposing their parent and grandparent's
|
||||
// destructors.
|
||||
class DerivedProtectedToPublicInHeader
|
||||
: public ProtectedRefCountedDtorInHeader {
|
||||
public:
|
||||
DerivedProtectedToPublicInHeader() {}
|
||||
~DerivedProtectedToPublicInHeader() {}
|
||||
};
|
||||
|
||||
// Unsafe; A grandchild ends up implicitly exposing their parent and
|
||||
// grantparent's destructors.
|
||||
class ImplicitDerivedProtectedToPublicInHeader
|
||||
: public ProtectedRefCountedDtorInHeader {
|
||||
public:
|
||||
ImplicitDerivedProtectedToPublicInHeader() {}
|
||||
};
|
||||
|
||||
// Unsafe-but-ignored; should not have errors.
|
||||
class WebKitPublicDtorInHeader
|
||||
: public WebKit::RefCounted<WebKitPublicDtorInHeader> {
|
||||
public:
|
||||
WebKitPublicDtorInHeader() {}
|
||||
~WebKitPublicDtorInHeader() {}
|
||||
};
|
||||
|
||||
// Unsafe-but-ignored; should not have errors.
|
||||
class WebKitDerivedPublicDtorInHeader
|
||||
: public WebKitPublicDtorInHeader {
|
||||
public:
|
||||
WebKitDerivedPublicDtorInHeader() {}
|
||||
~WebKitDerivedPublicDtorInHeader() {}
|
||||
};
|
||||
|
||||
#endif // BASE_REFCOUNTED_H_
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
In file included from base_refcounted.cpp:5:
|
||||
./base_refcounted.h:45:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors.
|
||||
~PublicRefCountedDtorInHeader() {}
|
||||
^
|
||||
./base_refcounted.h:57:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors.
|
||||
~PublicRefCountedThreadSafeDtorInHeader() {}
|
||||
^
|
||||
./base_refcounted.h:94:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors.
|
||||
~DerivedProtectedToPublicInHeader() {}
|
||||
^
|
||||
./base_refcounted.h:99:1: warning: [chromium-style] Classes that are ref-counted should have explicit destructors that are protected or private.
|
||||
class ImplicitDerivedProtectedToPublicInHeader
|
||||
^
|
||||
base_refcounted.cpp:16:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors.
|
||||
~AnonymousDerivedProtectedToPublicInImpl() {}
|
||||
^
|
||||
base_refcounted.cpp:26:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors.
|
||||
~PublicRefCountedDtorInImpl() {}
|
||||
^
|
||||
base_refcounted.cpp:52:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors.
|
||||
~UnsafeTypedefChainInImpl() {}
|
||||
^
|
||||
7 warnings generated.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// 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 "inline_copy_ctor.h"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// 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.
|
||||
|
||||
struct C {
|
||||
C();
|
||||
~C();
|
||||
|
||||
static C foo() { return C(); }
|
||||
|
||||
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p , q, r, s, t, u, v, w, x;
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
In file included from inline_copy_ctor.cpp:5:
|
||||
./inline_copy_ctor.h:5:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line copy constructor.
|
||||
struct C {
|
||||
^
|
||||
1 warning generated.
|
||||
25
media/webrtc/trunk/tools/clang/plugins/tests/inline_ctor.cpp
Normal file
25
media/webrtc/trunk/tools/clang/plugins/tests/inline_ctor.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2011 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 "inline_ctor.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// We don't warn on classes that are in CPP files.
|
||||
class InlineInCPPOK {
|
||||
public:
|
||||
InlineInCPPOK() {}
|
||||
~InlineInCPPOK() {}
|
||||
|
||||
private:
|
||||
std::vector<int> one_;
|
||||
std::vector<std::string> two_;
|
||||
};
|
||||
|
||||
int main() {
|
||||
InlineInCPPOK one;
|
||||
InlineCtorsArentOKInHeader two;
|
||||
return 0;
|
||||
}
|
||||
21
media/webrtc/trunk/tools/clang/plugins/tests/inline_ctor.h
Normal file
21
media/webrtc/trunk/tools/clang/plugins/tests/inline_ctor.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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.
|
||||
|
||||
#ifndef INLINE_CTOR_H_
|
||||
#define INLINE_CTOR_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class InlineCtorsArentOKInHeader {
|
||||
public:
|
||||
InlineCtorsArentOKInHeader() {}
|
||||
~InlineCtorsArentOKInHeader() {}
|
||||
|
||||
private:
|
||||
std::vector<int> one_;
|
||||
std::vector<std::string> two_;
|
||||
};
|
||||
|
||||
#endif // INLINE_CTOR_H_
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
In file included from inline_ctor.cpp:5:
|
||||
./inline_ctor.h:13:3: warning: [chromium-style] Complex constructor has an inlined body.
|
||||
InlineCtorsArentOKInHeader() {}
|
||||
^
|
||||
./inline_ctor.h:14:3: warning: [chromium-style] Complex destructor has an inline body.
|
||||
~InlineCtorsArentOKInHeader() {}
|
||||
^
|
||||
2 warnings generated.
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2011 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 "missing_ctor.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// We don't warn on classes that use default ctors in cpp files.
|
||||
class MissingInCPPOK {
|
||||
public:
|
||||
|
||||
private:
|
||||
std::vector<int> one_;
|
||||
std::vector<std::string> two_;
|
||||
};
|
||||
|
||||
int main() {
|
||||
MissingInCPPOK one;
|
||||
MissingCtorsArentOKInHeader two;
|
||||
return 0;
|
||||
}
|
||||
19
media/webrtc/trunk/tools/clang/plugins/tests/missing_ctor.h
Normal file
19
media/webrtc/trunk/tools/clang/plugins/tests/missing_ctor.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2011 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.
|
||||
|
||||
#ifndef MISSING_CTOR_H_
|
||||
#define MISSING_CTOR_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class MissingCtorsArentOKInHeader {
|
||||
public:
|
||||
|
||||
private:
|
||||
std::vector<int> one_;
|
||||
std::vector<std::string> two_;
|
||||
};
|
||||
|
||||
#endif // MISSING_CTOR_H_
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
In file included from missing_ctor.cpp:5:
|
||||
./missing_ctor.h:11:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line constructor.
|
||||
class MissingCtorsArentOKInHeader {
|
||||
^
|
||||
./missing_ctor.h:11:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line destructor.
|
||||
2 warnings generated.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// 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 "nested_class_inline_ctor.h"
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// 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.
|
||||
|
||||
#ifndef NESTED_CLASS_INLINE_CTOR_H_
|
||||
#define NESTED_CLASS_INLINE_CTOR_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// See crbug.com/136863.
|
||||
|
||||
class Foo {
|
||||
class Bar {
|
||||
Bar() {}
|
||||
~Bar() {}
|
||||
|
||||
std::vector<std::string> a;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // NESTED_CLASS_INLINE_CTOR_H_
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
In file included from nested_class_inline_ctor.cpp:5:
|
||||
./nested_class_inline_ctor.h:15:5: warning: [chromium-style] Complex constructor has an inlined body.
|
||||
Bar() {}
|
||||
^
|
||||
./nested_class_inline_ctor.h:16:5: warning: [chromium-style] Complex destructor has an inline body.
|
||||
~Bar() {}
|
||||
^
|
||||
2 warnings generated.
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// 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 "overridden_methods.h"
|
||||
|
||||
// Fill in the implementations
|
||||
void DerivedClass::SomeMethod() {}
|
||||
void DerivedClass::SomeOtherMethod() {}
|
||||
void DerivedClass::WebKitModifiedSomething() {}
|
||||
|
||||
class ImplementationInterimClass : public BaseClass {
|
||||
public:
|
||||
// Should not warn about pure virtual methods.
|
||||
virtual void SomeMethod() = 0;
|
||||
};
|
||||
|
||||
class ImplementationDerivedClass : public ImplementationInterimClass,
|
||||
public webkit_glue::WebKitObserverImpl {
|
||||
public:
|
||||
// Should not warn about destructors.
|
||||
virtual ~ImplementationDerivedClass() {}
|
||||
// Should warn.
|
||||
virtual void SomeMethod();
|
||||
// Should not warn if marked as override.
|
||||
virtual void SomeOtherMethod() override;
|
||||
// Should not warn for inline implementations in implementation files.
|
||||
virtual void SomeInlineMethod() {}
|
||||
// Should not warn if overriding a method whose origin is WebKit.
|
||||
virtual void WebKitModifiedSomething();
|
||||
// Should warn if overridden method isn't pure.
|
||||
virtual void SomeNonPureBaseMethod() {}
|
||||
};
|
||||
|
||||
int main() {
|
||||
DerivedClass something;
|
||||
ImplementationDerivedClass something_else;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) 2011 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.
|
||||
|
||||
#ifndef OVERRIDDEN_METHODS_H_
|
||||
#define OVERRIDDEN_METHODS_H_
|
||||
|
||||
// Should warn about overriding of methods.
|
||||
class BaseClass {
|
||||
public:
|
||||
virtual ~BaseClass() {}
|
||||
virtual void SomeMethod() = 0;
|
||||
virtual void SomeOtherMethod() = 0;
|
||||
virtual void SomeInlineMethod() = 0;
|
||||
virtual void SomeNonPureBaseMethod() {}
|
||||
};
|
||||
|
||||
class InterimClass : public BaseClass {
|
||||
// Should not warn about pure virtual methods.
|
||||
virtual void SomeMethod() = 0;
|
||||
};
|
||||
|
||||
namespace WebKit {
|
||||
class WebKitObserver {
|
||||
public:
|
||||
virtual void WebKitModifiedSomething() {};
|
||||
};
|
||||
} // namespace WebKit
|
||||
|
||||
namespace webkit_glue {
|
||||
class WebKitObserverImpl : WebKit::WebKitObserver {
|
||||
public:
|
||||
virtual void WebKitModifiedSomething() {};
|
||||
};
|
||||
} // namespace webkit_glue
|
||||
|
||||
class DerivedClass : public InterimClass,
|
||||
public webkit_glue::WebKitObserverImpl {
|
||||
public:
|
||||
// Should not warn about destructors.
|
||||
virtual ~DerivedClass() {}
|
||||
// Should warn.
|
||||
virtual void SomeMethod();
|
||||
// Should not warn if marked as override.
|
||||
virtual void SomeOtherMethod() override;
|
||||
// Should warn for inline implementations.
|
||||
virtual void SomeInlineMethod() {}
|
||||
// Should not warn if overriding a method whose origin is WebKit.
|
||||
virtual void WebKitModifiedSomething();
|
||||
// Should warn if overridden method isn't pure.
|
||||
virtual void SomeNonPureBaseMethod() {}
|
||||
};
|
||||
|
||||
#endif // OVERRIDDEN_METHODS_H_
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
In file included from overridden_methods.cpp:5:
|
||||
./overridden_methods.h:43:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE.
|
||||
virtual void SomeMethod();
|
||||
^
|
||||
./overridden_methods.h:47:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE.
|
||||
virtual void SomeInlineMethod() {}
|
||||
^
|
||||
./overridden_methods.h:51:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE.
|
||||
virtual void SomeNonPureBaseMethod() {}
|
||||
^
|
||||
overridden_methods.cpp:24:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE.
|
||||
virtual void SomeMethod();
|
||||
^
|
||||
overridden_methods.cpp:28:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE.
|
||||
virtual void SomeInlineMethod() {}
|
||||
^
|
||||
overridden_methods.cpp:32:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE.
|
||||
virtual void SomeNonPureBaseMethod() {}
|
||||
^
|
||||
6 warnings generated.
|
||||
72
media/webrtc/trunk/tools/clang/plugins/tests/test.sh
Normal file
72
media/webrtc/trunk/tools/clang/plugins/tests/test.sh
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2011 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.
|
||||
#
|
||||
# Hacky, primitive testing: This runs the style plugin for a set of input files
|
||||
# and compares the output with golden result files.
|
||||
|
||||
E_BADARGS=65
|
||||
E_FAILEDTEST=1
|
||||
|
||||
failed_any_test=
|
||||
|
||||
# Prints usage information.
|
||||
usage() {
|
||||
echo "Usage: $(basename "${0}")" \
|
||||
"<Path to the llvm build dir, usually Release+Asserts>"
|
||||
echo ""
|
||||
echo " Runs all the libFindBadConstructs unit tests"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Runs a single test case.
|
||||
do_testcase() {
|
||||
local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
|
||||
-Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \
|
||||
-Xclang -plugin -Xclang find-bad-constructs ${1} 2>&1)"
|
||||
local diffout="$(echo "${output}" | diff - "${2}")"
|
||||
if [ "${diffout}" = "" ]; then
|
||||
echo "PASS: ${1}"
|
||||
else
|
||||
failed_any_test=yes
|
||||
echo "FAIL: ${1}"
|
||||
echo "Output of compiler:"
|
||||
echo "${output}"
|
||||
echo "Expected output:"
|
||||
cat "${2}"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Validate input to the script.
|
||||
if [[ -z "${1}" ]]; then
|
||||
usage
|
||||
exit ${E_BADARGS}
|
||||
elif [[ ! -d "${1}" ]]; then
|
||||
echo "${1} is not a directory."
|
||||
usage
|
||||
exit ${E_BADARGS}
|
||||
else
|
||||
export CLANG_DIR="${PWD}/${1}"
|
||||
echo "Using clang directory ${CLANG_DIR}..."
|
||||
|
||||
# The golden files assume that the cwd is this directory. To make the script
|
||||
# work no matter what the cwd is, explicitly cd to there.
|
||||
cd "$(dirname "${0}")"
|
||||
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
export LIB=so
|
||||
elif [ "$(uname -s)" = "Darwin" ]; then
|
||||
export LIB=dylib
|
||||
fi
|
||||
fi
|
||||
|
||||
for input in *.cpp; do
|
||||
do_testcase "${input}" "${input%cpp}txt"
|
||||
done
|
||||
|
||||
if [[ "${failed_any_test}" ]]; then
|
||||
exit ${E_FAILEDTEST}
|
||||
fi
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// 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 "virtual_methods.h"
|
||||
|
||||
// Shouldn't warn about method usage in the implementation file.
|
||||
class VirtualMethodsInImplementation {
|
||||
public:
|
||||
virtual void MethodIsAbstract() = 0;
|
||||
virtual void MethodHasNoArguments();
|
||||
virtual void MethodHasEmptyDefaultImpl() {}
|
||||
virtual bool ComplainAboutThis() { return true; }
|
||||
};
|
||||
|
||||
// Stubs to fill in the abstract method
|
||||
class ConcreteVirtualMethodsInHeaders : public VirtualMethodsInHeaders {
|
||||
public:
|
||||
virtual void MethodIsAbstract() override {}
|
||||
};
|
||||
|
||||
class ConcreteVirtualMethodsInImplementation
|
||||
: public VirtualMethodsInImplementation {
|
||||
public:
|
||||
virtual void MethodIsAbstract() override {}
|
||||
};
|
||||
|
||||
// Fill in the implementations
|
||||
void VirtualMethodsInHeaders::MethodHasNoArguments() {}
|
||||
void WarnOnMissingVirtual::MethodHasNoArguments() {}
|
||||
void VirtualMethodsInImplementation::MethodHasNoArguments() {}
|
||||
|
||||
int main() {
|
||||
ConcreteVirtualMethodsInHeaders one;
|
||||
ConcreteVirtualMethodsInImplementation two;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2011 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.
|
||||
|
||||
#ifndef VIRTUAL_METHODS_H_
|
||||
#define VIRTUAL_METHODS_H_
|
||||
|
||||
// Should warn about virtual method usage.
|
||||
class VirtualMethodsInHeaders {
|
||||
public:
|
||||
// Don't complain about these.
|
||||
virtual void MethodIsAbstract() = 0;
|
||||
virtual void MethodHasNoArguments();
|
||||
virtual void MethodHasEmptyDefaultImpl() {}
|
||||
|
||||
// But complain about this:
|
||||
virtual bool ComplainAboutThis() { return true; }
|
||||
};
|
||||
|
||||
// Complain on missing 'virtual' keyword in overrides.
|
||||
class WarnOnMissingVirtual : public VirtualMethodsInHeaders {
|
||||
public:
|
||||
void MethodHasNoArguments() override;
|
||||
};
|
||||
|
||||
// Don't complain about things in a 'testing' namespace.
|
||||
namespace testing {
|
||||
struct TestStruct {};
|
||||
} // namespace testing
|
||||
|
||||
class VirtualMethodsInHeadersTesting : public VirtualMethodsInHeaders {
|
||||
public:
|
||||
// Don't complain about no virtual testing methods.
|
||||
void MethodHasNoArguments();
|
||||
private:
|
||||
testing::TestStruct tester_;
|
||||
};
|
||||
|
||||
#endif // VIRTUAL_METHODS_H_
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
In file included from virtual_methods.cpp:5:
|
||||
./virtual_methods.h:17:36: warning: [chromium-style] virtual methods with non-empty bodies shouldn't be declared inline.
|
||||
virtual bool ComplainAboutThis() { return true; }
|
||||
^
|
||||
./virtual_methods.h:23:3: warning: [chromium-style] Overriding method must have "virtual" keyword.
|
||||
void MethodHasNoArguments() override;
|
||||
^
|
||||
2 warnings generated.
|
||||
Loading…
Add table
Add a link
Reference in a new issue